Mercurial > hg > xemacs-beta
comparison src/symbols.c @ 371:cc15677e0335 r21-2b1
Import from CVS: tag r21-2b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:03:08 +0200 |
parents | 972bbb6d6ca2 |
children | 8626e4521993 |
comparison
equal
deleted
inserted
replaced
370:bd866891f083 | 371:cc15677e0335 |
---|---|
96 struct Lisp_Symbol *sym = XSYMBOL (obj); | 96 struct Lisp_Symbol *sym = XSYMBOL (obj); |
97 Lisp_Object pname; | 97 Lisp_Object pname; |
98 | 98 |
99 ((markobj) (sym->value)); | 99 ((markobj) (sym->value)); |
100 ((markobj) (sym->function)); | 100 ((markobj) (sym->function)); |
101 /* No need to mark through ->obarray, because it only holds nil or t. */ | |
102 /*((markobj) (sym->obarray));*/ | |
101 XSETSTRING (pname, sym->name); | 103 XSETSTRING (pname, sym->name); |
102 ((markobj) (pname)); | 104 ((markobj) (pname)); |
103 if (!symbol_next (sym)) | 105 if (!symbol_next (sym)) |
104 return sym->plist; | 106 return sym->plist; |
105 else | 107 else |
188 ptr = &XVECTOR_DATA (obarray)[XINT (sym)]; | 190 ptr = &XVECTOR_DATA (obarray)[XINT (sym)]; |
189 | 191 |
190 if (purify_flag && ! purified (str)) | 192 if (purify_flag && ! purified (str)) |
191 str = make_pure_pname (XSTRING_DATA (str), len, 0); | 193 str = make_pure_pname (XSTRING_DATA (str), len, 0); |
192 sym = Fmake_symbol (str); | 194 sym = Fmake_symbol (str); |
193 /* FSFmacs places OBARRAY here, but it we know better. See lisp.h | 195 /* FSFmacs places OBARRAY here, but it is pointless because we do |
194 for a little explanation. */ | 196 not mark through this slot, so it is not usable later (because |
195 XSYMBOL_OBARRAY_FLAGS (sym) = 1 | (2 * EQ (Vobarray, obarray)); | 197 the obarray might have been collected). Marking through the |
198 ->obarray slot is an even worse idea, because it would keep | |
199 obarrays from being collected because of symbols pointed to them. | |
200 | |
201 NOTE: We place Qt here only if OBARRAY is actually Vobarray. It | |
202 is safer to do it this way, to avoid hosing with symbols within | |
203 pure objects. */ | |
204 if (EQ (obarray, Vobarray)) | |
205 XSYMBOL (sym)->obarray = Qt; | |
196 | 206 |
197 if (SYMBOLP (*ptr)) | 207 if (SYMBOLP (*ptr)) |
198 symbol_next (XSYMBOL (sym)) = XSYMBOL (*ptr); | 208 symbol_next (XSYMBOL (sym)) = XSYMBOL (*ptr); |
199 else | 209 else |
200 symbol_next (XSYMBOL (sym)) = 0; | 210 symbol_next (XSYMBOL (sym)) = 0; |
275 XSYMBOL (tail)->next = XSYMBOL (following)->next; | 285 XSYMBOL (tail)->next = XSYMBOL (following)->next; |
276 break; | 286 break; |
277 } | 287 } |
278 } | 288 } |
279 } | 289 } |
280 if (XSYMBOL_OBARRAY_FLAGS (tem) & 4) | 290 XSYMBOL (tem)->obarray = Qnil; |
281 { | |
282 /* Symbol was stored somewhere in a pure structure, so it needs | |
283 at least one existing reference. Make one. */ | |
284 Fputhash (tem, Qnil, Vpure_uninterned_symbol_table); | |
285 } | |
286 XSYMBOL_OBARRAY_FLAGS (tem) &= ~3; | |
287 return Qt; | 291 return Qt; |
288 } | 292 } |
289 | 293 |
290 /* Return the symbol in OBARRAY whose names matches the string | 294 /* Return the symbol in OBARRAY whose names matches the string |
291 of SIZE characters at PTR. If there is no such symbol in OBARRAY, | 295 of SIZE characters at PTR. If there is no such symbol in OBARRAY, |
409 Call FUNCTION on every symbol in OBARRAY. | 413 Call FUNCTION on every symbol in OBARRAY. |
410 OBARRAY defaults to the value of `obarray'. | 414 OBARRAY defaults to the value of `obarray'. |
411 */ | 415 */ |
412 (function, obarray)) | 416 (function, obarray)) |
413 { | 417 { |
414 struct gcpro gcpro1; | |
415 | |
416 if (NILP (obarray)) | 418 if (NILP (obarray)) |
417 obarray = Vobarray; | 419 obarray = Vobarray; |
418 obarray = check_obarray (obarray); | 420 obarray = check_obarray (obarray); |
419 | 421 |
420 GCPRO1 (obarray); | |
421 map_obarray (obarray, mapatoms_1, &function); | 422 map_obarray (obarray, mapatoms_1, &function); |
422 UNGCPRO; | |
423 return Qnil; | 423 return Qnil; |
424 } | 424 } |
425 | 425 |
426 | 426 |
427 /**********************************************************************/ | 427 /**********************************************************************/ |
459 Return list of symbols found. | 459 Return list of symbols found. |
460 */ | 460 */ |
461 (regexp, predicate)) | 461 (regexp, predicate)) |
462 { | 462 { |
463 struct appropos_mapper_closure closure; | 463 struct appropos_mapper_closure closure; |
464 struct gcpro gcpro1; | |
465 | 464 |
466 CHECK_STRING (regexp); | 465 CHECK_STRING (regexp); |
467 | 466 |
468 closure.regexp = regexp; | 467 closure.regexp = regexp; |
469 closure.predicate = predicate; | 468 closure.predicate = predicate; |
470 closure.accumulation = Qnil; | 469 closure.accumulation = Qnil; |
471 GCPRO1 (closure.accumulation); | |
472 map_obarray (Vobarray, apropos_mapper, &closure); | 470 map_obarray (Vobarray, apropos_mapper, &closure); |
473 closure.accumulation = Fsort (closure.accumulation, Qstring_lessp); | 471 closure.accumulation = Fsort (closure.accumulation, Qstring_lessp); |
474 UNGCPRO; | |
475 return closure.accumulation; | 472 return closure.accumulation; |
476 } | 473 } |
477 | 474 |
478 | 475 |
479 /* Extract and set components of symbols */ | 476 /* Extract and set components of symbols */ |
562 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", |
563 sym); | 560 sym); |
564 | 561 |
565 if (symbol_is_constant (sym, val) | 562 if (symbol_is_constant (sym, val) |
566 || (SYMBOL_IS_KEYWORD (sym) && !EQ (newval, sym) | 563 || (SYMBOL_IS_KEYWORD (sym) && !EQ (newval, sym) |
567 && (XSYMBOL_OBARRAY_FLAGS (sym) & 2))) | 564 && !NILP (XSYMBOL (sym)->obarray))) |
568 signal_error (Qsetting_constant, | 565 signal_error (Qsetting_constant, |
569 UNBOUNDP (newval) ? list1 (sym) : list2 (sym, newval)); | 566 UNBOUNDP (newval) ? list1 (sym) : list2 (sym, newval)); |
570 } | 567 } |
571 | 568 |
572 /* 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 |
3163 /* Bootstrapping problem: Qnil isn't set when make_pure_pname is | 3160 /* Bootstrapping problem: Qnil isn't set when make_pure_pname is |
3164 called the first time. */ | 3161 called the first time. */ |
3165 XSYMBOL (Qnil)->name->plist = Qnil; | 3162 XSYMBOL (Qnil)->name->plist = Qnil; |
3166 XSYMBOL (Qnil)->value = Qnil; /* Nihil ex nihil */ | 3163 XSYMBOL (Qnil)->value = Qnil; /* Nihil ex nihil */ |
3167 XSYMBOL (Qnil)->plist = Qnil; | 3164 XSYMBOL (Qnil)->plist = Qnil; |
3168 XSYMBOL_OBARRAY_FLAGS (Qnil) = 1 | 2; | |
3169 | 3165 |
3170 Vobarray = make_vector (OBARRAY_SIZE, Qzero); | 3166 Vobarray = make_vector (OBARRAY_SIZE, Qzero); |
3171 initial_obarray = Vobarray; | 3167 initial_obarray = Vobarray; |
3172 staticpro (&initial_obarray); | 3168 staticpro (&initial_obarray); |
3173 /* Intern nil in the obarray */ | 3169 /* Intern nil in the obarray */ |
3174 { | 3170 { |
3175 int hash = hash_string (string_data (XSYMBOL (Qnil)->name), 3); | 3171 int hash = hash_string (string_data (XSYMBOL (Qnil)->name), 3); |
3176 XVECTOR_DATA (Vobarray)[hash % OBARRAY_SIZE] = Qnil; | 3172 XVECTOR_DATA (Vobarray)[hash % OBARRAY_SIZE] = Qnil; |
3173 XSYMBOL (Qnil)->obarray = Qt; | |
3177 } | 3174 } |
3178 | 3175 |
3179 { | 3176 { |
3180 /* Required to get around a GCC syntax error on certain | 3177 /* Required to get around a GCC syntax error on certain |
3181 architectures */ | 3178 architectures */ |