comparison src/symbols.c @ 267:966663fcf606 r20-5b32

Import from CVS: tag r20-5b32
author cvs
date Mon, 13 Aug 2007 10:26:29 +0200
parents 677f6a0ee643
children c5d627a313b1
comparison
equal deleted inserted replaced
266:18d185df8c54 267:966663fcf606
197 sym = Fmake_symbol (str); 197 sym = Fmake_symbol (str);
198 /* FSFmacs places OBARRAY here, but it is pointless because we do 198 /* FSFmacs places OBARRAY here, but it is pointless because we do
199 not mark through this slot, so it is not usable later (because 199 not mark through this slot, so it is not usable later (because
200 the obarray might have been collected). Marking through the 200 the obarray might have been collected). Marking through the
201 ->obarray slot is an even worse idea, because it would keep 201 ->obarray slot is an even worse idea, because it would keep
202 obarrays from being collected because of symbols pointed to them. */ 202 obarrays from being collected because of symbols pointed to them.
203 XSYMBOL (sym)->obarray = Qt; 203
204 NOTE: We place Qt here only if OBARRAY is actually Vobarray. It
205 is safer to do it this way, to avoid hosing with symbols within
206 pure objects. */
207 if (EQ (obarray, Vobarray))
208 XSYMBOL (sym)->obarray = Qt;
204 209
205 if (SYMBOLP (*ptr)) 210 if (SYMBOLP (*ptr))
206 symbol_next (XSYMBOL (sym)) = XSYMBOL (*ptr); 211 symbol_next (XSYMBOL (sym)) = XSYMBOL (*ptr);
207 else 212 else
208 symbol_next (XSYMBOL (sym)) = 0; 213 symbol_next (XSYMBOL (sym)) = 0;
529 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_SPECIFIER_FORWARD || 534 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_SPECIFIER_FORWARD ||
530 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_FIXNUM_FORWARD || 535 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_FIXNUM_FORWARD ||
531 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_BOOLEAN_FORWARD || 536 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_BOOLEAN_FORWARD ||
532 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_CURRENT_BUFFER_FORWARD || 537 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_CURRENT_BUFFER_FORWARD ||
533 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_SELECTED_CONSOLE_FORWARD)) 538 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_SELECTED_CONSOLE_FORWARD))
534 #if 0 539 /* We don't return true for keywords here because they are handled
535 /* #### - This is disabled until a new magic symbol_value for 540 specially by reject_constant_symbols(). */
536 constants is added */
537 || SYMBOL_IS_KEYWORD (sym)
538 #endif
539 ; 541 ;
540 } 542 }
541 543
542 /* We are setting SYM's value slot (or function slot, if FUNCTION_P is 544 /* We are setting SYM's value slot (or function slot, if FUNCTION_P is
543 non-zero) to NEWVAL. Make sure this is allowed. NEWVAL is only 545 non-zero) to NEWVAL. Make sure this is allowed.
544 used in the error message. FOLLOW_PAST_LISP_MAGIC specifies 546 FOLLOW_PAST_LISP_MAGIC specifies whether we delve past
545 whether we delve past symbol-value-lisp-magic objects. 547 symbol-value-lisp-magic objects. */
546 */
547 548
548 static void 549 static void
549 reject_constant_symbols (Lisp_Object sym, Lisp_Object newval, int function_p, 550 reject_constant_symbols (Lisp_Object sym, Lisp_Object newval, int function_p,
550 Lisp_Object follow_past_lisp_magic) 551 Lisp_Object follow_past_lisp_magic)
551 { 552 {
556 if (SYMBOL_VALUE_MAGIC_P (val) && 557 if (SYMBOL_VALUE_MAGIC_P (val) &&
557 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_SPECIFIER_FORWARD) 558 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_SPECIFIER_FORWARD)
558 signal_simple_error ("Use `set-specifier' to change a specifier's value", 559 signal_simple_error ("Use `set-specifier' to change a specifier's value",
559 sym); 560 sym);
560 561
561 if (symbol_is_constant (sym, val)) 562 if (symbol_is_constant (sym, val)
563 || (SYMBOL_IS_KEYWORD (sym) && !EQ (newval, sym)
564 && !NILP (XSYMBOL (sym)->obarray)))
562 signal_error (Qsetting_constant, 565 signal_error (Qsetting_constant,
563 UNBOUNDP (newval) ? list1 (sym) : list2 (sym, newval)); 566 UNBOUNDP (newval) ? list1 (sym) : list2 (sym, newval));
564 } 567 }
565 568
566 /* Verify that it's ok to make SYM buffer-local. This rejects 569 /* Verify that it's ok to make SYM buffer-local. This rejects
1615 1618
1616 CHECK_SYMBOL (sym); 1619 CHECK_SYMBOL (sym);
1617 1620
1618 retry: 1621 retry:
1619 valcontents = XSYMBOL (sym)->value; 1622 valcontents = XSYMBOL (sym)->value;
1620 if (NILP (sym) || EQ (sym, Qt) || SYMBOL_VALUE_MAGIC_P (valcontents)) 1623 if (NILP (sym) || EQ (sym, Qt) || SYMBOL_VALUE_MAGIC_P (valcontents)
1624 || SYMBOL_IS_KEYWORD (sym))
1621 reject_constant_symbols (sym, newval, 0, 1625 reject_constant_symbols (sym, newval, 0,
1622 UNBOUNDP (newval) ? Qmakunbound : Qset); 1626 UNBOUNDP (newval) ? Qmakunbound : Qset);
1623 else 1627 else
1624 { 1628 {
1625 XSYMBOL (sym)->value = newval; 1629 XSYMBOL (sym)->value = newval;