X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/63655c83146b773b4ef3d9220b4a9d61545fd050..7014398e612e9aef2c14ac1b1db515a7efb3d98c:/src/data.c diff --git a/src/data.c b/src/data.c index 81cffcb38d..54c0d7c211 100644 --- a/src/data.c +++ b/src/data.c @@ -1,13 +1,14 @@ /* Primitive operations on Lisp data types for GNU Emacs Lisp interpreter. Copyright (C) 1985, 1986, 1988, 1993, 1994, 1995, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 + Free Software Foundation, Inc. This file is part of GNU Emacs. -GNU Emacs is free software; you can redistribute it and/or modify +GNU Emacs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3, or (at your option) -any later version. +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,9 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with GNU Emacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -Boston, MA 02110-1301, USA. */ +along with GNU Emacs. If not, see . */ #include @@ -46,16 +45,6 @@ Boston, MA 02110-1301, USA. */ #endif #endif -/* Work around a problem that happens because math.h on hpux 7 - defines two static variables--which, in Emacs, are not really static, - because `static' is defined as nothing. The problem is that they are - here, in floatfns.c, and in lread.c. - These macros prevent the name conflict. */ -#if defined (HPUX) && !defined (HPUX8) -#define _MAXLDBL data_c_maxldbl -#define _NMAXLDBL data_c_nmaxldbl -#endif - #include #if !defined (atof) @@ -584,8 +573,7 @@ DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0, valcontents = SYMBOL_VALUE (symbol); - if (BUFFER_LOCAL_VALUEP (valcontents) - || SOME_BUFFER_LOCAL_VALUEP (valcontents)) + if (BUFFER_LOCAL_VALUEP (valcontents)) valcontents = swap_in_symval_forwarding (symbol, valcontents); return (EQ (valcontents, Qunbound) ? Qnil : Qt); @@ -815,25 +803,29 @@ Value, if non-nil, is a list \(interactive SPEC). */) `cyclic-variable-indirection' if SYMBOL's chain of variable indirections contains a loop. */ -Lisp_Object +struct Lisp_Symbol * indirect_variable (symbol) - Lisp_Object symbol; + struct Lisp_Symbol *symbol; { - Lisp_Object tortoise, hare; + struct Lisp_Symbol *tortoise, *hare; hare = tortoise = symbol; - while (XSYMBOL (hare)->indirect_variable) + while (hare->indirect_variable) { - hare = XSYMBOL (hare)->value; - if (!XSYMBOL (hare)->indirect_variable) + hare = XSYMBOL (hare->value); + if (!hare->indirect_variable) break; - hare = XSYMBOL (hare)->value; - tortoise = XSYMBOL (tortoise)->value; + hare = XSYMBOL (hare->value); + tortoise = XSYMBOL (tortoise->value); - if (EQ (hare, tortoise)) - xsignal1 (Qcyclic_variable_indirection, symbol); + if (hare == tortoise) + { + Lisp_Object tem; + XSETSYMBOL (tem, symbol); + xsignal1 (Qcyclic_variable_indirection, tem); + } } return hare; @@ -850,7 +842,7 @@ variable chain of symbols. */) Lisp_Object object; { if (SYMBOLP (object)) - object = indirect_variable (object); + XSETSYMBOL (object, indirect_variable (XSYMBOL (object))); return object; } @@ -865,7 +857,6 @@ do_symval_forwarding (valcontents) register Lisp_Object valcontents; { register Lisp_Object val; - int offset; if (MISCP (valcontents)) switch (XMISCTYPE (valcontents)) { @@ -880,11 +871,10 @@ do_symval_forwarding (valcontents) return *XOBJFWD (valcontents)->objvar; case Lisp_Misc_Buffer_Objfwd: - offset = XBUFFER_OBJFWD (valcontents)->offset; - return PER_BUFFER_VALUE (current_buffer, offset); + return PER_BUFFER_VALUE (current_buffer, + XBUFFER_OBJFWD (valcontents)->offset); case Lisp_Misc_Kboard_Objfwd: - offset = XKBOARD_OBJFWD (valcontents)->offset; /* We used to simply use current_kboard here, but from Lisp code, it's value is often unexpected. It seems nicer to allow constructions like this to work as intuitively expected: @@ -896,7 +886,8 @@ do_symval_forwarding (valcontents) last-command and real-last-command, and people may rely on that. I took a quick look at the Lisp codebase, and I don't think anything will break. --lorentey */ - return *(Lisp_Object *)(offset + (char *)FRAME_KBOARD (SELECTED_FRAME ())); + return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset + + (char *)FRAME_KBOARD (SELECTED_FRAME ())); } return valcontents; } @@ -923,13 +914,15 @@ store_symval_forwarding (symbol, valcontents, newval, buf) case Lisp_Misc_Intfwd: CHECK_NUMBER (newval); *XINTFWD (valcontents)->intvar = XINT (newval); - if (*XINTFWD (valcontents)->intvar != XINT (newval)) - error ("Value out of range for variable `%s'", - SDATA (SYMBOL_NAME (symbol))); + /* This can never happen since intvar points to an EMACS_INT + which is at least large enough to hold a Lisp_Object. + if (*XINTFWD (valcontents)->intvar != XINT (newval)) + error ("Value out of range for variable `%s'", + SDATA (SYMBOL_NAME (symbol))); */ break; case Lisp_Misc_Boolfwd: - *XBOOLFWD (valcontents)->boolvar = NILP (newval) ? 0 : 1; + *XBOOLFWD (valcontents)->boolvar = !NILP (newval); break; case Lisp_Misc_Objfwd: @@ -969,12 +962,11 @@ store_symval_forwarding (symbol, valcontents, newval, buf) case Lisp_Misc_Buffer_Objfwd: { int offset = XBUFFER_OBJFWD (valcontents)->offset; - Lisp_Object type; + Lisp_Object type = XBUFFER_OBJFWD (valcontents)->slottype; - type = PER_BUFFER_TYPE (offset); if (! NILP (type) && ! NILP (newval) && XTYPE (newval) != XINT (type)) - buffer_slot_type_mismatch (offset); + buffer_slot_type_mismatch (newval, XINT (type)); if (buf == NULL) buf = current_buffer; @@ -998,8 +990,7 @@ store_symval_forwarding (symbol, valcontents, newval, buf) default: def: valcontents = SYMBOL_VALUE (symbol); - if (BUFFER_LOCAL_VALUEP (valcontents) - || SOME_BUFFER_LOCAL_VALUEP (valcontents)) + if (BUFFER_LOCAL_VALUEP (valcontents)) XBUFFER_LOCAL_VALUE (valcontents)->realvalue = newval; else SET_SYMBOL_VALUE (symbol, newval); @@ -1013,27 +1004,23 @@ void swap_in_global_binding (symbol) Lisp_Object symbol; { - Lisp_Object valcontents, cdr; - - valcontents = SYMBOL_VALUE (symbol); - if (!BUFFER_LOCAL_VALUEP (valcontents) - && !SOME_BUFFER_LOCAL_VALUEP (valcontents)) - abort (); - cdr = XBUFFER_LOCAL_VALUE (valcontents)->cdr; + Lisp_Object valcontents = SYMBOL_VALUE (symbol); + struct Lisp_Buffer_Local_Value *blv = XBUFFER_LOCAL_VALUE (valcontents); + Lisp_Object cdr = blv->cdr; /* Unload the previously loaded binding. */ Fsetcdr (XCAR (cdr), - do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); + do_symval_forwarding (blv->realvalue)); /* Select the global binding in the symbol. */ XSETCAR (cdr, cdr); - store_symval_forwarding (symbol, valcontents, XCDR (cdr), NULL); + store_symval_forwarding (symbol, blv->realvalue, XCDR (cdr), NULL); /* Indicate that the global binding is set up now. */ - XBUFFER_LOCAL_VALUE (valcontents)->frame = Qnil; - XBUFFER_LOCAL_VALUE (valcontents)->buffer = Qnil; - XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 0; - XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; + blv->frame = Qnil; + blv->buffer = Qnil; + blv->found_for_frame = 0; + blv->found_for_buffer = 0; } /* Set up the buffer-local symbol SYMBOL for validity in the current buffer. @@ -1056,8 +1043,12 @@ swap_in_symval_forwarding (symbol, valcontents) || (XBUFFER_LOCAL_VALUE (valcontents)->check_frame && ! EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame))) { - if (XSYMBOL (symbol)->indirect_variable) - symbol = indirect_variable (symbol); + struct Lisp_Symbol *sym = XSYMBOL (symbol); + if (sym->indirect_variable) + { + sym = indirect_variable (sym); + XSETSYMBOL (symbol, sym); + } /* Unload the previously loaded binding. */ tem1 = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr); @@ -1106,35 +1097,10 @@ find_symbol_value (symbol) CHECK_SYMBOL (symbol); valcontents = SYMBOL_VALUE (symbol); - if (BUFFER_LOCAL_VALUEP (valcontents) - || SOME_BUFFER_LOCAL_VALUEP (valcontents)) + if (BUFFER_LOCAL_VALUEP (valcontents)) valcontents = swap_in_symval_forwarding (symbol, valcontents); - if (MISCP (valcontents)) - { - switch (XMISCTYPE (valcontents)) - { - case Lisp_Misc_Intfwd: - XSETINT (val, *XINTFWD (valcontents)->intvar); - return val; - - case Lisp_Misc_Boolfwd: - return (*XBOOLFWD (valcontents)->boolvar ? Qt : Qnil); - - case Lisp_Misc_Objfwd: - return *XOBJFWD (valcontents)->objvar; - - case Lisp_Misc_Buffer_Objfwd: - return PER_BUFFER_VALUE (current_buffer, - XBUFFER_OBJFWD (valcontents)->offset); - - case Lisp_Misc_Kboard_Objfwd: - return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset - + (char *)FRAME_KBOARD (SELECTED_FRAME ())); - } - } - - return valcontents; + return do_symval_forwarding (valcontents); } DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0, @@ -1164,7 +1130,7 @@ DEFUN ("set", Fset, Sset, 2, 2, 0, static int let_shadows_buffer_binding_p (symbol) - Lisp_Object symbol; + struct Lisp_Symbol *symbol; { volatile struct specbinding *p; @@ -1172,10 +1138,10 @@ let_shadows_buffer_binding_p (symbol) if (p->func == NULL && CONSP (p->symbol)) { - Lisp_Object let_bound_symbol = XCAR (p->symbol); - if ((EQ (symbol, let_bound_symbol) - || (XSYMBOL (let_bound_symbol)->indirect_variable - && EQ (symbol, indirect_variable (let_bound_symbol)))) + struct Lisp_Symbol *let_bound_symbol = XSYMBOL (XCAR (p->symbol)); + if ((symbol == let_bound_symbol + || (let_bound_symbol->indirect_variable + && symbol == indirect_variable (let_bound_symbol))) && XBUFFER (XCDR (XCDR (p->symbol))) == current_buffer) break; } @@ -1222,15 +1188,14 @@ set_internal (symbol, newval, buf, bindflag) int idx = PER_BUFFER_IDX (offset); if (idx > 0 && !bindflag - && !let_shadows_buffer_binding_p (symbol)) + && !let_shadows_buffer_binding_p (XSYMBOL (symbol))) SET_PER_BUFFER_VALUE_P (buf, idx, 1); } - else if (BUFFER_LOCAL_VALUEP (valcontents) - || SOME_BUFFER_LOCAL_VALUEP (valcontents)) + else if (BUFFER_LOCAL_VALUEP (valcontents)) { /* valcontents is a struct Lisp_Buffer_Local_Value. */ if (XSYMBOL (symbol)->indirect_variable) - symbol = indirect_variable (symbol); + XSETSYMBOL (symbol, indirect_variable (XSYMBOL (symbol))); /* What binding is loaded right now? */ current_alist_element @@ -1245,9 +1210,9 @@ set_internal (symbol, newval, buf, bindflag) || buf != XBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer) || (XBUFFER_LOCAL_VALUE (valcontents)->check_frame && !EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame)) - || (BUFFER_LOCAL_VALUEP (valcontents) - && EQ (XCAR (current_alist_element), - current_alist_element))) + /* Also unload a global binding (if the var is local_if_set). */ + || (EQ (XCAR (current_alist_element), + current_alist_element))) { /* The currently loaded binding is not necessarily valid. We need to unload it, and choose a new binding. */ @@ -1265,14 +1230,14 @@ set_internal (symbol, newval, buf, bindflag) { /* This buffer still sees the default value. */ - /* If the variable is a Lisp_Some_Buffer_Local_Value, + /* If the variable is not local_if_set, or if this is `let' rather than `set', make CURRENT-ALIST-ELEMENT point to itself, indicating that we're seeing the default value. Likewise if the variable has been let-bound in the current buffer. */ - if (bindflag || SOME_BUFFER_LOCAL_VALUEP (valcontents) - || let_shadows_buffer_binding_p (symbol)) + if (bindflag || !XBUFFER_LOCAL_VALUE (valcontents)->local_if_set + || let_shadows_buffer_binding_p (XSYMBOL (symbol))) { XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; @@ -1299,14 +1264,16 @@ set_internal (symbol, newval, buf, bindflag) } /* Record which binding is now loaded. */ - XSETCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr, - tem1); + XSETCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr, tem1); /* Set `buffer' and `frame' slots for the binding now loaded. */ XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, buf); XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame; } innercontents = XBUFFER_LOCAL_VALUE (valcontents)->realvalue; + + /* Store the new value in the cons-cell. */ + XSETCDR (XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr), newval); } /* If storing void (making the symbol void), forward only through @@ -1316,25 +1283,6 @@ set_internal (symbol, newval, buf, bindflag) else store_symval_forwarding (symbol, innercontents, newval, buf); - /* If we just set a variable whose current binding is frame-local, - store the new value in the frame parameter too. */ - - if (BUFFER_LOCAL_VALUEP (valcontents) - || SOME_BUFFER_LOCAL_VALUEP (valcontents)) - { - /* What binding is loaded right now? */ - current_alist_element - = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr); - - /* If the current buffer is not the buffer whose binding is - loaded, or if there may be frame-local bindings and the frame - isn't the right one, or if it's a Lisp_Buffer_Local_Value and - the default binding is loaded, the loaded binding may be the - wrong one. */ - if (XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame) - XSETCDR (current_alist_element, newval); - } - return newval; } @@ -1362,8 +1310,7 @@ default_value (symbol) } /* Handle user-created local variables. */ - if (BUFFER_LOCAL_VALUEP (valcontents) - || SOME_BUFFER_LOCAL_VALUEP (valcontents)) + if (BUFFER_LOCAL_VALUEP (valcontents)) { /* If var is set up for a buffer that lacks a local value for it, the current value is nominally the default value. @@ -1447,8 +1394,7 @@ for this variable. */) return value; } - if (!BUFFER_LOCAL_VALUEP (valcontents) - && !SOME_BUFFER_LOCAL_VALUEP (valcontents)) + if (!BUFFER_LOCAL_VALUEP (valcontents)) return Fset (symbol, value); /* Store new value into the DEFAULT-VALUE slot. */ @@ -1525,35 +1471,41 @@ The function `default-value' gets the default value and `set-default' sets it. register Lisp_Object variable; { register Lisp_Object tem, valcontents, newval; + struct Lisp_Symbol *sym; CHECK_SYMBOL (variable); - variable = indirect_variable (variable); + sym = indirect_variable (XSYMBOL (variable)); - valcontents = SYMBOL_VALUE (variable); - if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents)) - error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable))); + valcontents = sym->value; + if (sym->constant || KBOARD_OBJFWDP (valcontents)) + error ("Symbol %s may not be buffer-local", SDATA (sym->xname)); - if (BUFFER_LOCAL_VALUEP (valcontents) || BUFFER_OBJFWDP (valcontents)) + if (BUFFER_OBJFWDP (valcontents)) return variable; - if (SOME_BUFFER_LOCAL_VALUEP (valcontents)) + else if (BUFFER_LOCAL_VALUEP (valcontents)) { - XMISCTYPE (SYMBOL_VALUE (variable)) = Lisp_Misc_Buffer_Local_Value; - return variable; + if (XBUFFER_LOCAL_VALUE (valcontents)->check_frame) + error ("Symbol %s may not be buffer-local", SDATA (sym->xname)); + newval = valcontents; } - if (EQ (valcontents, Qunbound)) - SET_SYMBOL_VALUE (variable, Qnil); - tem = Fcons (Qnil, Fsymbol_value (variable)); - XSETCAR (tem, tem); - newval = allocate_misc (); - XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; - XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); - XBUFFER_LOCAL_VALUE (newval)->buffer = Fcurrent_buffer (); - XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; - XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; - XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; - XBUFFER_LOCAL_VALUE (newval)->check_frame = 0; - XBUFFER_LOCAL_VALUE (newval)->cdr = tem; - SET_SYMBOL_VALUE (variable, newval); + else + { + if (EQ (valcontents, Qunbound)) + sym->value = Qnil; + tem = Fcons (Qnil, Fsymbol_value (variable)); + XSETCAR (tem, tem); + newval = allocate_misc (); + XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; + XBUFFER_LOCAL_VALUE (newval)->realvalue = sym->value; + XBUFFER_LOCAL_VALUE (newval)->buffer = Fcurrent_buffer (); + XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; + XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; + XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; + XBUFFER_LOCAL_VALUE (newval)->check_frame = 0; + XBUFFER_LOCAL_VALUE (newval)->cdr = tem; + sym->value = newval; + } + XBUFFER_LOCAL_VALUE (newval)->local_if_set = 1; return variable; } @@ -1581,15 +1533,20 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) register Lisp_Object variable; { register Lisp_Object tem, valcontents; + struct Lisp_Symbol *sym; CHECK_SYMBOL (variable); - variable = indirect_variable (variable); + sym = indirect_variable (XSYMBOL (variable)); - valcontents = SYMBOL_VALUE (variable); - if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents)) - error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable))); + valcontents = sym->value; + if (sym->constant || KBOARD_OBJFWDP (valcontents) + || (BUFFER_LOCAL_VALUEP (valcontents) + && (XBUFFER_LOCAL_VALUE (valcontents)->check_frame))) + error ("Symbol %s may not be buffer-local", SDATA (sym->xname)); - if (BUFFER_LOCAL_VALUEP (valcontents) || BUFFER_OBJFWDP (valcontents)) + if ((BUFFER_LOCAL_VALUEP (valcontents) + && XBUFFER_LOCAL_VALUE (valcontents)->local_if_set) + || BUFFER_OBJFWDP (valcontents)) { tem = Fboundp (variable); @@ -1599,23 +1556,25 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) return variable; } /* Make sure symbol is set up to hold per-buffer values. */ - if (!SOME_BUFFER_LOCAL_VALUEP (valcontents)) + if (!BUFFER_LOCAL_VALUEP (valcontents)) { Lisp_Object newval; tem = Fcons (Qnil, do_symval_forwarding (valcontents)); XSETCAR (tem, tem); newval = allocate_misc (); - XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; - XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); + XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; + XBUFFER_LOCAL_VALUE (newval)->realvalue = sym->value; XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; + XBUFFER_LOCAL_VALUE (newval)->local_if_set = 0; XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; XBUFFER_LOCAL_VALUE (newval)->check_frame = 0; XBUFFER_LOCAL_VALUE (newval)->cdr = tem; - SET_SYMBOL_VALUE (variable, newval); + sym->value = newval; } /* Make sure this buffer has its own value of symbol. */ + XSETSYMBOL (variable, sym); /* Propagate variable indirections. */ tem = Fassq (variable, current_buffer->local_var_alist); if (NILP (tem)) { @@ -1625,7 +1584,7 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) find_symbol_value (variable); current_buffer->local_var_alist - = Fcons (Fcons (variable, XCDR (XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (variable))->cdr)), + = Fcons (Fcons (variable, XCDR (XBUFFER_LOCAL_VALUE (sym->value)->cdr)), current_buffer->local_var_alist); /* Make sure symbol does not think it is set up for this buffer; @@ -1633,7 +1592,7 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) { Lisp_Object *pvalbuf; - valcontents = SYMBOL_VALUE (variable); + valcontents = sym->value; pvalbuf = &XBUFFER_LOCAL_VALUE (valcontents)->buffer; if (current_buffer == XBUFFER (*pvalbuf)) @@ -1646,9 +1605,9 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) for this buffer now. If C code modifies the variable before we load the binding in, then that new value will clobber the default binding the next time we unload it. */ - valcontents = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (variable))->realvalue; + valcontents = XBUFFER_LOCAL_VALUE (sym->value)->realvalue; if (INTFWDP (valcontents) || BOOLFWDP (valcontents) || OBJFWDP (valcontents)) - swap_in_symval_forwarding (variable, SYMBOL_VALUE (variable)); + swap_in_symval_forwarding (variable, sym->value); return variable; } @@ -1661,11 +1620,12 @@ From now on the default value will apply in this buffer. Return VARIABLE. */) register Lisp_Object variable; { register Lisp_Object tem, valcontents; + struct Lisp_Symbol *sym; CHECK_SYMBOL (variable); - variable = indirect_variable (variable); + sym = indirect_variable (XSYMBOL (variable)); - valcontents = SYMBOL_VALUE (variable); + valcontents = sym->value; if (BUFFER_OBJFWDP (valcontents)) { @@ -1681,12 +1641,11 @@ From now on the default value will apply in this buffer. Return VARIABLE. */) return variable; } - if (!BUFFER_LOCAL_VALUEP (valcontents) - && !SOME_BUFFER_LOCAL_VALUEP (valcontents)) + if (!BUFFER_LOCAL_VALUEP (valcontents)) return variable; /* Get rid of this buffer's alist element, if any. */ - + XSETSYMBOL (variable, sym); /* Propagate variable indirection. */ tem = Fassq (variable, current_buffer->local_var_alist); if (!NILP (tem)) current_buffer->local_var_alist @@ -1697,7 +1656,7 @@ From now on the default value will apply in this buffer. Return VARIABLE. */) forwarded objects won't work right. */ { Lisp_Object *pvalbuf, buf; - valcontents = SYMBOL_VALUE (variable); + valcontents = sym->value; pvalbuf = &XBUFFER_LOCAL_VALUE (valcontents)->buffer; XSETBUFFER (buf, current_buffer); if (EQ (buf, *pvalbuf)) @@ -1734,36 +1693,38 @@ Buffer-local bindings take precedence over frame-local bindings. */) register Lisp_Object variable; { register Lisp_Object tem, valcontents, newval; + struct Lisp_Symbol *sym; CHECK_SYMBOL (variable); - variable = indirect_variable (variable); + sym = indirect_variable (XSYMBOL (variable)); - valcontents = SYMBOL_VALUE (variable); - if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents) + valcontents = sym->value; + if (sym->constant || KBOARD_OBJFWDP (valcontents) || BUFFER_OBJFWDP (valcontents)) - error ("Symbol %s may not be frame-local", SDATA (SYMBOL_NAME (variable))); + error ("Symbol %s may not be frame-local", SDATA (sym->xname)); - if (BUFFER_LOCAL_VALUEP (valcontents) - || SOME_BUFFER_LOCAL_VALUEP (valcontents)) + if (BUFFER_LOCAL_VALUEP (valcontents)) { - XBUFFER_LOCAL_VALUE (valcontents)->check_frame = 1; + if (!XBUFFER_LOCAL_VALUE (valcontents)->check_frame) + error ("Symbol %s may not be frame-local", SDATA (sym->xname)); return variable; } if (EQ (valcontents, Qunbound)) - SET_SYMBOL_VALUE (variable, Qnil); + sym->value = Qnil; tem = Fcons (Qnil, Fsymbol_value (variable)); XSETCAR (tem, tem); newval = allocate_misc (); - XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; - XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); + XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; + XBUFFER_LOCAL_VALUE (newval)->realvalue = sym->value; XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; + XBUFFER_LOCAL_VALUE (newval)->local_if_set = 0; XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; XBUFFER_LOCAL_VALUE (newval)->check_frame = 1; XBUFFER_LOCAL_VALUE (newval)->cdr = tem; - SET_SYMBOL_VALUE (variable, newval); + sym->value = newval; return variable; } @@ -1776,6 +1737,7 @@ BUFFER defaults to the current buffer. */) { Lisp_Object valcontents; register struct buffer *buf; + struct Lisp_Symbol *sym; if (NILP (buffer)) buf = current_buffer; @@ -1786,11 +1748,11 @@ BUFFER defaults to the current buffer. */) } CHECK_SYMBOL (variable); - variable = indirect_variable (variable); - - valcontents = SYMBOL_VALUE (variable); - if (BUFFER_LOCAL_VALUEP (valcontents) - || SOME_BUFFER_LOCAL_VALUEP (valcontents)) + sym = indirect_variable (XSYMBOL (variable)); + XSETSYMBOL (variable, sym); + + valcontents = sym->value; + if (BUFFER_LOCAL_VALUEP (valcontents)) { Lisp_Object tail, elt; @@ -1824,6 +1786,7 @@ BUFFER defaults to the current buffer. */) { Lisp_Object valcontents; register struct buffer *buf; + struct Lisp_Symbol *sym; if (NILP (buffer)) buf = current_buffer; @@ -1834,19 +1797,19 @@ BUFFER defaults to the current buffer. */) } CHECK_SYMBOL (variable); - variable = indirect_variable (variable); + sym = indirect_variable (XSYMBOL (variable)); + XSETSYMBOL (variable, sym); - valcontents = SYMBOL_VALUE (variable); + valcontents = sym->value; - /* This means that make-variable-buffer-local was done. */ - if (BUFFER_LOCAL_VALUEP (valcontents)) - return Qt; - /* All these slots become local if they are set. */ if (BUFFER_OBJFWDP (valcontents)) + /* All these slots become local if they are set. */ return Qt; - if (SOME_BUFFER_LOCAL_VALUEP (valcontents)) + else if (BUFFER_LOCAL_VALUEP (valcontents)) { Lisp_Object tail, elt; + if (XBUFFER_LOCAL_VALUE (valcontents)->local_if_set) + return Qt; for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) { elt = XCAR (tail); @@ -1867,24 +1830,24 @@ If the current binding is global (the default), the value is nil. */) register Lisp_Object variable; { Lisp_Object valcontents; + struct Lisp_Symbol *sym; CHECK_SYMBOL (variable); - variable = indirect_variable (variable); + sym = indirect_variable (XSYMBOL (variable)); /* Make sure the current binding is actually swapped in. */ find_symbol_value (variable); - valcontents = XSYMBOL (variable)->value; + valcontents = sym->value; if (BUFFER_LOCAL_VALUEP (valcontents) - || SOME_BUFFER_LOCAL_VALUEP (valcontents) || BUFFER_OBJFWDP (valcontents)) { /* For a local variable, record both the symbol and which buffer's or frame's value we are saving. */ if (!NILP (Flocal_variable_p (variable, Qnil))) return Fcurrent_buffer (); - else if (!BUFFER_OBJFWDP (valcontents) + else if (BUFFER_LOCAL_VALUEP (valcontents) && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame) return XBUFFER_LOCAL_VALUE (valcontents)->frame; } @@ -2143,7 +2106,17 @@ bool-vector. IDX starts at 0. */) CHECK_NUMBER (newelt); if (XINT (newelt) >= 0 && ! SINGLE_BYTE_CHAR_P (XINT (newelt))) - args_out_of_range (array, newelt); + { + int i; + + for (i = SBYTES (array) - 1; i >= 0; i--) + if (SREF (array, i) >= 0x80) + args_out_of_range (array, newelt); + /* ARRAY is an ASCII string. Convert it to a multibyte + string, and try `aset' again. */ + STRING_SET_MULTIBYTE (array); + return Faset (array, idx, newelt); + } SSET (array, idxval, XINT (newelt)); } @@ -2329,7 +2302,7 @@ NUMBER may be an integer or a floating point number. */) } if (sizeof (int) == sizeof (EMACS_INT)) - sprintf (buffer, "%d", XINT (number)); + sprintf (buffer, "%d", (int) XINT (number)); else if (sizeof (long) == sizeof (EMACS_INT)) sprintf (buffer, "%ld", (long) XINT (number)); else @@ -3281,10 +3254,12 @@ syms_of_data () DEFVAR_LISP ("most-positive-fixnum", &Vmost_positive_fixnum, doc: /* The largest value that is representable in a Lisp integer. */); Vmost_positive_fixnum = make_number (MOST_POSITIVE_FIXNUM); + XSYMBOL (intern ("most-positive-fixnum"))->constant = 1; DEFVAR_LISP ("most-negative-fixnum", &Vmost_negative_fixnum, doc: /* The smallest value that is representable in a Lisp integer. */); Vmost_negative_fixnum = make_number (MOST_NEGATIVE_FIXNUM); + XSYMBOL (intern ("most-negative-fixnum"))->constant = 1; } SIGTYPE @@ -3296,15 +3271,7 @@ arith_error (signo) must reestablish each time */ signal (signo, arith_error); #endif /* USG */ -#ifdef VMS - /* VMS systems are like USG. */ - signal (signo, arith_error); -#endif /* VMS */ -#ifdef BSD4_1 - sigrelse (SIGFPE); -#else /* not BSD4_1 */ sigsetmask (SIGEMPTYMASK); -#endif /* not BSD4_1 */ SIGNAL_THREAD_CHECK (signo); xsignal0 (Qarith_error);