X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/be24eadf24015c02838ff3e0dfa35f030c6dc9b3..8030369ccb5c871d3ce11b96c220f318bc741ed8:/src/data.c diff --git a/src/data.c b/src/data.c index 266a1946fa..dc0ddc5108 100644 --- a/src/data.c +++ b/src/data.c @@ -96,7 +96,7 @@ static Lisp_Object Qsubrp, Qmany, Qunevalled; static Lisp_Object swap_in_symval_forwarding P_ ((Lisp_Object, Lisp_Object)); -int most_positive_fixnum, most_negative_fixnum; +Lisp_Object Vmost_positive_fixnum, Vmost_negative_fixnum; void @@ -114,15 +114,6 @@ wrong_type_argument (predicate, value) register Lisp_Object tem; do { - if (!EQ (Vmocklisp_arguments, Qt)) - { - if (STRINGP (value) && - (EQ (predicate, Qintegerp) || EQ (predicate, Qinteger_or_marker_p))) - return Fstring_to_number (value, Qnil); - if (INTEGERP (value) && EQ (predicate, Qstringp)) - return Fnumber_to_string (value); - } - /* If VALUE is not even a valid Lisp object, abort here where we can get a backtrace showing where it came from. */ if ((unsigned int) XGCTYPE (value) >= Lisp_Type_Limit) @@ -320,7 +311,7 @@ interned in the initial obarray. */) Lisp_Object object; { if (SYMBOLP (object) - && XSYMBOL (object)->name->data[0] == ':' + && SREF (SYMBOL_NAME (object), 0) == ':' && SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (object)) return Qt; return Qnil; @@ -688,7 +679,7 @@ DEFUN ("symbol-name", Fsymbol_name, Ssymbol_name, 1, 1, 0, register Lisp_Object name; CHECK_SYMBOL (symbol); - XSETSTRING (name, XSYMBOL (symbol)->name); + name = SYMBOL_NAME (symbol); return name; } @@ -713,14 +704,21 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0, return definition; } -DEFUN ("defalias", Fdefalias, Sdefalias, 2, 2, 0, +extern Lisp_Object Qfunction_documentation; + +DEFUN ("defalias", Fdefalias, Sdefalias, 2, 3, 0, doc: /* Set SYMBOL's function definition to DEFINITION, and return DEFINITION. -Associates the function with the current load file, if any. */) - (symbol, definition) - register Lisp_Object symbol, definition; +Associates the function with the current load file, if any. +The optional third argument DOCSTRING specifies the documentation string +for SYMBOL; if it is omitted or nil, SYMBOL uses the documentation string +determined by DEFINITION. */) + (symbol, definition, docstring) + register Lisp_Object symbol, definition, docstring; { definition = Ffset (symbol, definition); LOADHIST_ATTACH (symbol); + if (!NILP (docstring)) + Fput (symbol, Qfunction_documentation, docstring); return definition; } @@ -878,7 +876,7 @@ store_symval_forwarding (symbol, valcontents, newval, buf) *XINTFWD (valcontents)->intvar = XINT (newval); if (*XINTFWD (valcontents)->intvar != XINT (newval)) error ("Value out of range for variable `%s'", - XSYMBOL (symbol)->name->data); + SDATA (SYMBOL_NAME (symbol))); break; case Lisp_Misc_Boolfwd: @@ -896,7 +894,7 @@ store_symval_forwarding (symbol, valcontents, newval, buf) type = PER_BUFFER_TYPE (offset); if (XINT (type) == -1) - error ("Variable %s is read-only", XSYMBOL (symbol)->name->data); + error ("Variable %s is read-only", SDATA (SYMBOL_NAME (symbol))); if (! NILP (type) && ! NILP (newval) && XTYPE (newval) != XINT (type)) @@ -1218,7 +1216,7 @@ set_internal (symbol, newval, buf, bindflag) and load that binding. */ else { - tem1 = Fcons (symbol, Fcdr (current_alist_element)); + tem1 = Fcons (symbol, XCDR (current_alist_element)); buf->local_var_alist = Fcons (tem1, buf->local_var_alist); } @@ -1420,9 +1418,9 @@ usage: (setq-default SYMBOL VALUE [SYMBOL VALUE...]) */) do { val = Feval (Fcar (Fcdr (args_left))); - symbol = Fcar (args_left); + symbol = XCAR (args_left); Fset_default (symbol, val); - args_left = Fcdr (Fcdr (args_left)); + args_left = Fcdr (XCDR (args_left)); } while (!NILP (args_left)); @@ -1452,7 +1450,7 @@ The function `default-value' gets the default value and `set-default' sets it. valcontents = SYMBOL_VALUE (variable); if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents)) - error ("Symbol %s may not be buffer-local", XSYMBOL (variable)->name->data); + error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable))); if (BUFFER_LOCAL_VALUEP (valcontents) || BUFFER_OBJFWDP (valcontents)) return variable; @@ -1505,7 +1503,7 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) valcontents = SYMBOL_VALUE (variable); if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents)) - error ("Symbol %s may not be buffer-local", XSYMBOL (variable)->name->data); + error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable))); if (BUFFER_LOCAL_VALUEP (valcontents) || BUFFER_OBJFWDP (valcontents)) { @@ -1634,10 +1632,10 @@ DEFUN ("make-variable-frame-local", Fmake_variable_frame_local, Smake_variable_f doc: /* Enable VARIABLE to have frame-local bindings. When a frame-local binding exists in the current frame, it is in effect whenever the current buffer has no buffer-local binding. -A frame-local binding is actual a frame parameter value; +A frame-local binding is actually a frame parameter value; thus, any given frame has a local binding for VARIABLE if it has a value for the frame parameter named VARIABLE. -See `modify-frame-parameters'. */) +See `modify-frame-parameters' for how to set frame parameters. */) (variable) register Lisp_Object variable; { @@ -1648,7 +1646,7 @@ See `modify-frame-parameters'. */) valcontents = SYMBOL_VALUE (variable); if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents) || BUFFER_OBJFWDP (valcontents)) - error ("Symbol %s may not be frame-local", XSYMBOL (variable)->name->data); + error ("Symbol %s may not be frame-local", SDATA (SYMBOL_NAME (variable))); if (BUFFER_LOCAL_VALUEP (valcontents) || SOME_BUFFER_LOCAL_VALUEP (valcontents)) @@ -1832,14 +1830,14 @@ or a byte-code object. IDX starts at 0. */) { int c, idxval_byte; - if (idxval < 0 || idxval >= XSTRING (array)->size) + if (idxval < 0 || idxval >= SCHARS (array)) args_out_of_range (array, idx); if (! STRING_MULTIBYTE (array)) - return make_number ((unsigned char) XSTRING (array)->data[idxval]); + return make_number ((unsigned char) SREF (array, idxval)); idxval_byte = string_char_to_byte (array, idxval); - c = STRING_CHAR (&XSTRING (array)->data[idxval_byte], - STRING_BYTES (XSTRING (array)) - idxval_byte); + c = STRING_CHAR (SDATA (array) + idxval_byte, + SBYTES (array) - idxval_byte); return make_number (c); } else if (BOOL_VECTOR_P (array)) @@ -2031,29 +2029,29 @@ IDX starts at 0. */) int idxval_byte, prev_bytes, new_bytes; unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; - if (idxval < 0 || idxval >= XSTRING (array)->size) + if (idxval < 0 || idxval >= SCHARS (array)) args_out_of_range (array, idx); CHECK_NUMBER (newelt); idxval_byte = string_char_to_byte (array, idxval); - p1 = &XSTRING (array)->data[idxval_byte]; + p1 = SDATA (array) + idxval_byte; PARSE_MULTIBYTE_SEQ (p1, nbytes - idxval_byte, prev_bytes); new_bytes = CHAR_STRING (XINT (newelt), p0); if (prev_bytes != new_bytes) { /* We must relocate the string data. */ - int nchars = XSTRING (array)->size; - int nbytes = STRING_BYTES (XSTRING (array)); + int nchars = SCHARS (array); + int nbytes = SBYTES (array); unsigned char *str; str = (nbytes <= MAX_ALLOCA ? (unsigned char *) alloca (nbytes) : (unsigned char *) xmalloc (nbytes)); - bcopy (XSTRING (array)->data, str, nbytes); + bcopy (SDATA (array), str, nbytes); allocate_string_data (XSTRING (array), nchars, nbytes + new_bytes - prev_bytes); - bcopy (str, XSTRING (array)->data, idxval_byte); - p1 = XSTRING (array)->data + idxval_byte; + bcopy (str, SDATA (array), idxval_byte); + p1 = SDATA (array) + idxval_byte; bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes, nbytes - (idxval_byte + prev_bytes)); if (nbytes > MAX_ALLOCA) @@ -2065,36 +2063,36 @@ IDX starts at 0. */) } else { - if (idxval < 0 || idxval >= XSTRING (array)->size) + if (idxval < 0 || idxval >= SCHARS (array)) args_out_of_range (array, idx); CHECK_NUMBER (newelt); if (XINT (newelt) < 0 || SINGLE_BYTE_CHAR_P (XINT (newelt))) - XSTRING (array)->data[idxval] = XINT (newelt); + SSET (array, idxval, XINT (newelt)); else { /* We must relocate the string data while converting it to multibyte. */ int idxval_byte, prev_bytes, new_bytes; unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; - unsigned char *origstr = XSTRING (array)->data, *str; + unsigned char *origstr = SDATA (array), *str; int nchars, nbytes; - nchars = XSTRING (array)->size; + nchars = SCHARS (array); nbytes = idxval_byte = count_size_as_multibyte (origstr, idxval); nbytes += count_size_as_multibyte (origstr + idxval, nchars - idxval); str = (nbytes <= MAX_ALLOCA ? (unsigned char *) alloca (nbytes) : (unsigned char *) xmalloc (nbytes)); - copy_text (XSTRING (array)->data, str, nchars, 0, 1); + copy_text (SDATA (array), str, nchars, 0, 1); PARSE_MULTIBYTE_SEQ (str + idxval_byte, nbytes - idxval_byte, prev_bytes); new_bytes = CHAR_STRING (XINT (newelt), p0); allocate_string_data (XSTRING (array), nchars, nbytes + new_bytes - prev_bytes); - bcopy (str, XSTRING (array)->data, idxval_byte); - p1 = XSTRING (array)->data + idxval_byte; + bcopy (str, SDATA (array), idxval_byte); + p1 = SDATA (array) + idxval_byte; while (new_bytes--) *p1++ = *p0++; bcopy (str + idxval_byte + prev_bytes, p1, @@ -2344,7 +2342,7 @@ If the base used is not 10, floating point is not recognized. */) /* Skip any whitespace at the front of the number. Some versions of atoi do this anyway, so we might as well make Emacs lisp consistent. */ - p = XSTRING (string)->data; + p = SDATA (string); while (*p == ' ' || *p == '\t') p++; @@ -3208,13 +3206,13 @@ syms_of_data () XSYMBOL (Qwholenump)->function = XSYMBOL (Qnatnump)->function; - DEFVAR_INT ("most-positive-fixnum", &most_positive_fixnum, - doc: /* The largest value that is representable in a Lisp integer. */); - most_positive_fixnum = MOST_POSITIVE_FIXNUM; + 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); - DEFVAR_INT ("most-negative-fixnum", &most_negative_fixnum, - doc: /* The smallest value that is representable in a Lisp integer. */); - most_negative_fixnum = MOST_NEGATIVE_FIXNUM; + 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); } SIGTYPE