Mercurial > emacs
annotate src/data.c @ 695:e3fac20d3015
*** empty log message ***
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Sun, 07 Jun 1992 02:36:01 +0000 |
| parents | 70b112526394 |
| children | 62dd28940dc6 |
| rev | line source |
|---|---|
| 298 | 1 /* Primitive operations on Lisp data types for GNU Emacs Lisp interpreter. |
| 591 | 2 Copyright (C) 1985, 1986, 1988, 1992 Free Software Foundation, Inc. |
| 298 | 3 |
| 4 This file is part of GNU Emacs. | |
| 5 | |
| 6 GNU Emacs is free software; you can redistribute it and/or modify | |
| 7 it under the terms of the GNU General Public License as published by | |
| 8 the Free Software Foundation; either version 1, or (at your option) | |
| 9 any later version. | |
| 10 | |
| 11 GNU Emacs is distributed in the hope that it will be useful, | |
| 12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 GNU General Public License for more details. | |
| 15 | |
| 16 You should have received a copy of the GNU General Public License | |
| 17 along with GNU Emacs; see the file COPYING. If not, write to | |
| 18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
| 19 | |
| 20 | |
| 21 #include <signal.h> | |
| 22 | |
| 23 #include "config.h" | |
| 24 #include "lisp.h" | |
| 336 | 25 #include "puresize.h" |
| 298 | 26 |
| 27 #ifndef standalone | |
| 28 #include "buffer.h" | |
| 29 #endif | |
| 30 | |
| 552 | 31 #include "syssignal.h" |
| 348 | 32 |
| 298 | 33 #ifdef LISP_FLOAT_TYPE |
| 34 #include <math.h> | |
| 35 #endif /* LISP_FLOAT_TYPE */ | |
| 36 | |
| 37 Lisp_Object Qnil, Qt, Qquote, Qlambda, Qsubr, Qunbound; | |
| 38 Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; | |
| 39 Lisp_Object Qerror, Qquit, Qwrong_type_argument, Qargs_out_of_range; | |
| 648 | 40 Lisp_Object Qvoid_variable, Qvoid_function, Qcyclic_function_indirection; |
| 298 | 41 Lisp_Object Qsetting_constant, Qinvalid_read_syntax; |
| 42 Lisp_Object Qinvalid_function, Qwrong_number_of_arguments, Qno_catch; | |
| 43 Lisp_Object Qend_of_file, Qarith_error; | |
| 44 Lisp_Object Qbeginning_of_buffer, Qend_of_buffer, Qbuffer_read_only; | |
| 45 Lisp_Object Qintegerp, Qnatnump, Qsymbolp, Qlistp, Qconsp; | |
| 46 Lisp_Object Qstringp, Qarrayp, Qsequencep, Qbufferp; | |
| 47 Lisp_Object Qchar_or_string_p, Qmarkerp, Qinteger_or_marker_p, Qvectorp; | |
| 48 Lisp_Object Qboundp, Qfboundp; | |
| 49 Lisp_Object Qcdr; | |
| 50 | |
| 51 #ifdef LISP_FLOAT_TYPE | |
|
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
52 Lisp_Object Qfloatp; |
| 298 | 53 Lisp_Object Qnumberp, Qnumber_or_marker_p; |
| 54 #endif | |
| 55 | |
| 56 static Lisp_Object swap_in_symval_forwarding (); | |
| 57 | |
| 58 Lisp_Object | |
| 59 wrong_type_argument (predicate, value) | |
| 60 register Lisp_Object predicate, value; | |
| 61 { | |
| 62 register Lisp_Object tem; | |
| 63 do | |
| 64 { | |
| 65 if (!EQ (Vmocklisp_arguments, Qt)) | |
| 66 { | |
| 67 if (XTYPE (value) == Lisp_String && | |
| 68 (EQ (predicate, Qintegerp) || EQ (predicate, Qinteger_or_marker_p))) | |
| 69 return Fstring_to_int (value, Qt); | |
| 70 if (XTYPE (value) == Lisp_Int && EQ (predicate, Qstringp)) | |
| 71 return Fint_to_string (value); | |
| 72 } | |
| 73 value = Fsignal (Qwrong_type_argument, Fcons (predicate, Fcons (value, Qnil))); | |
| 74 tem = call1 (predicate, value); | |
| 75 } | |
| 490 | 76 while (NILP (tem)); |
| 298 | 77 return value; |
| 78 } | |
| 79 | |
| 80 pure_write_error () | |
| 81 { | |
| 82 error ("Attempt to modify read-only object"); | |
| 83 } | |
| 84 | |
| 85 void | |
| 86 args_out_of_range (a1, a2) | |
| 87 Lisp_Object a1, a2; | |
| 88 { | |
| 89 while (1) | |
| 90 Fsignal (Qargs_out_of_range, Fcons (a1, Fcons (a2, Qnil))); | |
| 91 } | |
| 92 | |
| 93 void | |
| 94 args_out_of_range_3 (a1, a2, a3) | |
| 95 Lisp_Object a1, a2, a3; | |
| 96 { | |
| 97 while (1) | |
| 98 Fsignal (Qargs_out_of_range, Fcons (a1, Fcons (a2, Fcons (a3, Qnil)))); | |
| 99 } | |
| 100 | |
| 101 Lisp_Object | |
| 102 make_number (num) | |
| 103 int num; | |
| 104 { | |
| 105 register Lisp_Object val; | |
| 106 XSET (val, Lisp_Int, num); | |
| 107 return val; | |
| 108 } | |
| 109 | |
| 110 /* On some machines, XINT needs a temporary location. | |
| 111 Here it is, in case it is needed. */ | |
| 112 | |
| 113 int sign_extend_temp; | |
| 114 | |
| 115 /* On a few machines, XINT can only be done by calling this. */ | |
| 116 | |
| 117 int | |
| 118 sign_extend_lisp_int (num) | |
| 119 int num; | |
| 120 { | |
| 121 if (num & (1 << (VALBITS - 1))) | |
| 122 return num | ((-1) << VALBITS); | |
| 123 else | |
| 124 return num & ((1 << VALBITS) - 1); | |
| 125 } | |
| 126 | |
| 127 /* Data type predicates */ | |
| 128 | |
| 129 DEFUN ("eq", Feq, Seq, 2, 2, 0, | |
| 130 "T if the two args are the same Lisp object.") | |
| 131 (obj1, obj2) | |
| 132 Lisp_Object obj1, obj2; | |
| 133 { | |
| 134 if (EQ (obj1, obj2)) | |
| 135 return Qt; | |
| 136 return Qnil; | |
| 137 } | |
| 138 | |
| 139 DEFUN ("null", Fnull, Snull, 1, 1, 0, "T if OBJECT is nil.") | |
| 140 (obj) | |
| 141 Lisp_Object obj; | |
| 142 { | |
| 490 | 143 if (NILP (obj)) |
| 298 | 144 return Qt; |
| 145 return Qnil; | |
| 146 } | |
| 147 | |
| 148 DEFUN ("consp", Fconsp, Sconsp, 1, 1, 0, "T if OBJECT is a cons cell.") | |
| 149 (obj) | |
| 150 Lisp_Object obj; | |
| 151 { | |
| 152 if (XTYPE (obj) == Lisp_Cons) | |
| 153 return Qt; | |
| 154 return Qnil; | |
| 155 } | |
| 156 | |
| 157 DEFUN ("atom", Fatom, Satom, 1, 1, 0, "T if OBJECT is not a cons cell. This includes nil.") | |
| 158 (obj) | |
| 159 Lisp_Object obj; | |
| 160 { | |
| 161 if (XTYPE (obj) == Lisp_Cons) | |
| 162 return Qnil; | |
| 163 return Qt; | |
| 164 } | |
| 165 | |
| 166 DEFUN ("listp", Flistp, Slistp, 1, 1, 0, "T if OBJECT is a list. This includes nil.") | |
| 167 (obj) | |
| 168 Lisp_Object obj; | |
| 169 { | |
| 490 | 170 if (XTYPE (obj) == Lisp_Cons || NILP (obj)) |
| 298 | 171 return Qt; |
| 172 return Qnil; | |
| 173 } | |
| 174 | |
| 175 DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0, "T if OBJECT is not a list. Lists include nil.") | |
| 176 (obj) | |
| 177 Lisp_Object obj; | |
| 178 { | |
| 490 | 179 if (XTYPE (obj) == Lisp_Cons || NILP (obj)) |
| 298 | 180 return Qnil; |
| 181 return Qt; | |
| 182 } | |
| 183 | |
| 184 DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0, "T if OBJECT is a symbol.") | |
| 185 (obj) | |
| 186 Lisp_Object obj; | |
| 187 { | |
| 188 if (XTYPE (obj) == Lisp_Symbol) | |
| 189 return Qt; | |
| 190 return Qnil; | |
| 191 } | |
| 192 | |
| 193 DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, "T if OBJECT is a vector.") | |
| 194 (obj) | |
| 195 Lisp_Object obj; | |
| 196 { | |
| 197 if (XTYPE (obj) == Lisp_Vector) | |
| 198 return Qt; | |
| 199 return Qnil; | |
| 200 } | |
| 201 | |
| 202 DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0, "T if OBJECT is a string.") | |
| 203 (obj) | |
| 204 Lisp_Object obj; | |
| 205 { | |
| 206 if (XTYPE (obj) == Lisp_String) | |
| 207 return Qt; | |
| 208 return Qnil; | |
| 209 } | |
| 210 | |
| 211 DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0, "T if OBJECT is an array (string or vector).") | |
| 212 (obj) | |
| 213 Lisp_Object obj; | |
| 214 { | |
| 215 if (XTYPE (obj) == Lisp_Vector || XTYPE (obj) == Lisp_String) | |
| 216 return Qt; | |
| 217 return Qnil; | |
| 218 } | |
| 219 | |
| 220 DEFUN ("sequencep", Fsequencep, Ssequencep, 1, 1, 0, | |
| 221 "T if OBJECT is a sequence (list or array).") | |
| 222 (obj) | |
| 223 register Lisp_Object obj; | |
| 224 { | |
| 490 | 225 if (CONSP (obj) || NILP (obj) || |
| 298 | 226 XTYPE (obj) == Lisp_Vector || XTYPE (obj) == Lisp_String) |
| 227 return Qt; | |
| 228 return Qnil; | |
| 229 } | |
| 230 | |
| 231 DEFUN ("bufferp", Fbufferp, Sbufferp, 1, 1, 0, "T if OBJECT is an editor buffer.") | |
| 232 (obj) | |
| 233 Lisp_Object obj; | |
| 234 { | |
| 235 if (XTYPE (obj) == Lisp_Buffer) | |
| 236 return Qt; | |
| 237 return Qnil; | |
| 238 } | |
| 239 | |
| 240 DEFUN ("markerp", Fmarkerp, Smarkerp, 1, 1, 0, "T if OBJECT is a marker (editor pointer).") | |
| 241 (obj) | |
| 242 Lisp_Object obj; | |
| 243 { | |
| 244 if (XTYPE (obj) == Lisp_Marker) | |
| 245 return Qt; | |
| 246 return Qnil; | |
| 247 } | |
| 248 | |
| 249 DEFUN ("subrp", Fsubrp, Ssubrp, 1, 1, 0, "T if OBJECT is a built-in function.") | |
| 250 (obj) | |
| 251 Lisp_Object obj; | |
| 252 { | |
| 253 if (XTYPE (obj) == Lisp_Subr) | |
| 254 return Qt; | |
| 255 return Qnil; | |
| 256 } | |
| 257 | |
| 258 DEFUN ("compiled-function-p", Fcompiled_function_p, Scompiled_function_p, | |
| 259 1, 1, 0, "T if OBJECT is a compiled function object.") | |
| 260 (obj) | |
| 261 Lisp_Object obj; | |
| 262 { | |
| 263 if (XTYPE (obj) == Lisp_Compiled) | |
| 264 return Qt; | |
| 265 return Qnil; | |
| 266 } | |
| 267 | |
| 268 DEFUN ("char-or-string-p", Fchar_or_string_p, Schar_or_string_p, 1, 1, 0, "T if OBJECT is a character (a number) or a string.") | |
| 269 (obj) | |
| 270 register Lisp_Object obj; | |
| 271 { | |
| 272 if (XTYPE (obj) == Lisp_Int || XTYPE (obj) == Lisp_String) | |
| 273 return Qt; | |
| 274 return Qnil; | |
| 275 } | |
| 276 | |
| 277 DEFUN ("integerp", Fintegerp, Sintegerp, 1, 1, 0, "T if OBJECT is a number.") | |
| 278 (obj) | |
| 279 Lisp_Object obj; | |
| 280 { | |
| 281 if (XTYPE (obj) == Lisp_Int) | |
| 282 return Qt; | |
| 283 return Qnil; | |
| 284 } | |
| 285 | |
|
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
286 DEFUN ("integer-or-marker-p", Finteger_or_marker_p, Sinteger_or_marker_p, 1, 1, 0, |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
287 "T if OBJECT is an integer or a marker (editor pointer).") |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
288 (obj) |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
289 register Lisp_Object obj; |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
290 { |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
291 if (XTYPE (obj) == Lisp_Marker || XTYPE (obj) == Lisp_Int) |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
292 return Qt; |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
293 return Qnil; |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
294 } |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
295 |
| 298 | 296 DEFUN ("natnump", Fnatnump, Snatnump, 1, 1, 0, "T if OBJECT is a nonnegative number.") |
| 297 (obj) | |
| 298 Lisp_Object obj; | |
| 299 { | |
| 300 if (XTYPE (obj) == Lisp_Int && XINT (obj) >= 0) | |
| 301 return Qt; | |
| 302 return Qnil; | |
| 303 } | |
| 304 | |
|
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
305 DEFUN ("numberp", Fnumberp, Snumberp, 1, 1, 0, |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
306 "T if OBJECT is a number (floating point or integer).") |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
307 (obj) |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
308 Lisp_Object obj; |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
309 { |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
310 if (0 |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
311 #ifdef LISP_FLOAT_TYPE |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
312 || XTYPE (obj) == Lisp_Float |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
313 #endif |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
314 || XTYPE (obj) == Lisp_Int) |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
315 return Qt; |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
316 return Qnil; |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
317 } |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
318 |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
319 DEFUN ("number-or-marker-p", Fnumber_or_marker_p, |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
320 Snumber_or_marker_p, 1, 1, 0, |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
321 "T if OBJECT is a number or a marker.") |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
322 (obj) |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
323 Lisp_Object obj; |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
324 { |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
325 if (XTYPE (obj) == Lisp_Int |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
326 #ifdef LISP_FLOAT_TYPE |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
327 || XTYPE (obj) == Lisp_Float |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
328 #endif |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
329 || XTYPE (obj) == Lisp_Marker) |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
330 return Qt; |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
331 return Qnil; |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
332 } |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
333 |
| 298 | 334 #ifdef LISP_FLOAT_TYPE |
| 335 DEFUN ("floatp", Ffloatp, Sfloatp, 1, 1, 0, | |
| 336 "T if OBJECT is a floating point number.") | |
| 337 (obj) | |
| 338 Lisp_Object obj; | |
| 339 { | |
| 340 if (XTYPE (obj) == Lisp_Float) | |
| 341 return Qt; | |
| 342 return Qnil; | |
| 343 } | |
| 344 #endif /* LISP_FLOAT_TYPE */ | |
| 345 | |
| 346 /* Extract and set components of lists */ | |
| 347 | |
| 348 DEFUN ("car", Fcar, Scar, 1, 1, 0, | |
| 349 "Return the car of CONSCELL. If arg is nil, return nil.\n\ | |
| 350 Error if arg is not nil and not a cons cell. See also `car-safe'.") | |
| 351 (list) | |
| 352 register Lisp_Object list; | |
| 353 { | |
| 354 while (1) | |
| 355 { | |
| 356 if (XTYPE (list) == Lisp_Cons) | |
| 357 return XCONS (list)->car; | |
| 358 else if (EQ (list, Qnil)) | |
| 359 return Qnil; | |
| 360 else | |
| 361 list = wrong_type_argument (Qlistp, list); | |
| 362 } | |
| 363 } | |
| 364 | |
| 365 DEFUN ("car-safe", Fcar_safe, Scar_safe, 1, 1, 0, | |
| 366 "Return the car of OBJECT if it is a cons cell, or else nil.") | |
| 367 (object) | |
| 368 Lisp_Object object; | |
| 369 { | |
| 370 if (XTYPE (object) == Lisp_Cons) | |
| 371 return XCONS (object)->car; | |
| 372 else | |
| 373 return Qnil; | |
| 374 } | |
| 375 | |
| 376 DEFUN ("cdr", Fcdr, Scdr, 1, 1, 0, | |
| 377 "Return the cdr of CONSCELL. If arg is nil, return nil.\n\ | |
| 378 Error if arg is not nil and not a cons cell. See also `cdr-safe'.") | |
| 379 | |
| 380 (list) | |
| 381 register Lisp_Object list; | |
| 382 { | |
| 383 while (1) | |
| 384 { | |
| 385 if (XTYPE (list) == Lisp_Cons) | |
| 386 return XCONS (list)->cdr; | |
| 387 else if (EQ (list, Qnil)) | |
| 388 return Qnil; | |
| 389 else | |
| 390 list = wrong_type_argument (Qlistp, list); | |
| 391 } | |
| 392 } | |
| 393 | |
| 394 DEFUN ("cdr-safe", Fcdr_safe, Scdr_safe, 1, 1, 0, | |
| 395 "Return the cdr of OBJECT if it is a cons cell, or else nil.") | |
| 396 (object) | |
| 397 Lisp_Object object; | |
| 398 { | |
| 399 if (XTYPE (object) == Lisp_Cons) | |
| 400 return XCONS (object)->cdr; | |
| 401 else | |
| 402 return Qnil; | |
| 403 } | |
| 404 | |
| 405 DEFUN ("setcar", Fsetcar, Ssetcar, 2, 2, 0, | |
| 406 "Set the car of CONSCELL to be NEWCAR. Returns NEWCAR.") | |
| 407 (cell, newcar) | |
| 408 register Lisp_Object cell, newcar; | |
| 409 { | |
| 410 if (XTYPE (cell) != Lisp_Cons) | |
| 411 cell = wrong_type_argument (Qconsp, cell); | |
| 412 | |
| 413 CHECK_IMPURE (cell); | |
| 414 XCONS (cell)->car = newcar; | |
| 415 return newcar; | |
| 416 } | |
| 417 | |
| 418 DEFUN ("setcdr", Fsetcdr, Ssetcdr, 2, 2, 0, | |
| 419 "Set the cdr of CONSCELL to be NEWCDR. Returns NEWCDR.") | |
| 420 (cell, newcdr) | |
| 421 register Lisp_Object cell, newcdr; | |
| 422 { | |
| 423 if (XTYPE (cell) != Lisp_Cons) | |
| 424 cell = wrong_type_argument (Qconsp, cell); | |
| 425 | |
| 426 CHECK_IMPURE (cell); | |
| 427 XCONS (cell)->cdr = newcdr; | |
| 428 return newcdr; | |
| 429 } | |
| 430 | |
| 431 /* Extract and set components of symbols */ | |
| 432 | |
| 433 DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0, "T if SYMBOL's value is not void.") | |
| 434 (sym) | |
| 435 register Lisp_Object sym; | |
| 436 { | |
| 437 Lisp_Object valcontents; | |
| 438 CHECK_SYMBOL (sym, 0); | |
| 439 | |
| 440 valcontents = XSYMBOL (sym)->value; | |
| 441 | |
| 442 #ifdef SWITCH_ENUM_BUG | |
| 443 switch ((int) XTYPE (valcontents)) | |
| 444 #else | |
| 445 switch (XTYPE (valcontents)) | |
| 446 #endif | |
| 447 { | |
| 448 case Lisp_Buffer_Local_Value: | |
| 449 case Lisp_Some_Buffer_Local_Value: | |
| 450 valcontents = swap_in_symval_forwarding (sym, valcontents); | |
| 451 } | |
| 452 | |
| 453 return (XTYPE (valcontents) == Lisp_Void || EQ (valcontents, Qunbound) | |
| 454 ? Qnil : Qt); | |
| 455 } | |
| 456 | |
| 457 DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0, "T if SYMBOL's function definition is not void.") | |
| 458 (sym) | |
| 459 register Lisp_Object sym; | |
| 460 { | |
| 461 CHECK_SYMBOL (sym, 0); | |
| 462 return (XTYPE (XSYMBOL (sym)->function) == Lisp_Void | |
| 463 || EQ (XSYMBOL (sym)->function, Qunbound)) | |
| 464 ? Qnil : Qt; | |
| 465 } | |
| 466 | |
| 467 DEFUN ("makunbound", Fmakunbound, Smakunbound, 1, 1, 0, "Make SYMBOL's value be void.") | |
| 468 (sym) | |
| 469 register Lisp_Object sym; | |
| 470 { | |
| 471 CHECK_SYMBOL (sym, 0); | |
| 490 | 472 if (NILP (sym) || EQ (sym, Qt)) |
| 298 | 473 return Fsignal (Qsetting_constant, Fcons (sym, Qnil)); |
| 474 Fset (sym, Qunbound); | |
| 475 return sym; | |
| 476 } | |
| 477 | |
| 478 DEFUN ("fmakunbound", Ffmakunbound, Sfmakunbound, 1, 1, 0, "Make SYMBOL's function definition be void.") | |
| 479 (sym) | |
| 480 register Lisp_Object sym; | |
| 481 { | |
| 482 CHECK_SYMBOL (sym, 0); | |
| 483 XSYMBOL (sym)->function = Qunbound; | |
| 484 return sym; | |
| 485 } | |
| 486 | |
| 487 DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0, | |
| 488 "Return SYMBOL's function definition. Error if that is void.") | |
| 648 | 489 (symbol) |
| 490 register Lisp_Object symbol; | |
| 298 | 491 { |
| 648 | 492 CHECK_SYMBOL (symbol, 0); |
| 493 if (EQ (XSYMBOL (symbol)->function, Qunbound)) | |
| 494 return Fsignal (Qvoid_function, Fcons (symbol, Qnil)); | |
| 495 return XSYMBOL (symbol)->function; | |
| 298 | 496 } |
| 497 | |
| 498 DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0, "Return SYMBOL's property list.") | |
| 499 (sym) | |
| 500 register Lisp_Object sym; | |
| 501 { | |
| 502 CHECK_SYMBOL (sym, 0); | |
| 503 return XSYMBOL (sym)->plist; | |
| 504 } | |
| 505 | |
| 506 DEFUN ("symbol-name", Fsymbol_name, Ssymbol_name, 1, 1, 0, "Return SYMBOL's name, a string.") | |
| 507 (sym) | |
| 508 register Lisp_Object sym; | |
| 509 { | |
| 510 register Lisp_Object name; | |
| 511 | |
| 512 CHECK_SYMBOL (sym, 0); | |
| 513 XSET (name, Lisp_String, XSYMBOL (sym)->name); | |
| 514 return name; | |
| 515 } | |
| 516 | |
| 517 DEFUN ("fset", Ffset, Sfset, 2, 2, 0, | |
| 518 "Set SYMBOL's function definition to NEWVAL, and return NEWVAL.") | |
| 519 (sym, newdef) | |
| 520 register Lisp_Object sym, newdef; | |
| 521 { | |
| 522 CHECK_SYMBOL (sym, 0); | |
| 490 | 523 if (!NILP (Vautoload_queue) && !EQ (XSYMBOL (sym)->function, Qunbound)) |
| 298 | 524 Vautoload_queue = Fcons (Fcons (sym, XSYMBOL (sym)->function), |
| 525 Vautoload_queue); | |
| 526 XSYMBOL (sym)->function = newdef; | |
| 527 return newdef; | |
| 528 } | |
| 529 | |
| 530 DEFUN ("setplist", Fsetplist, Ssetplist, 2, 2, 0, | |
| 531 "Set SYMBOL's property list to NEWVAL, and return NEWVAL.") | |
| 532 (sym, newplist) | |
| 533 register Lisp_Object sym, newplist; | |
| 534 { | |
| 535 CHECK_SYMBOL (sym, 0); | |
| 536 XSYMBOL (sym)->plist = newplist; | |
| 537 return newplist; | |
| 538 } | |
| 648 | 539 |
| 298 | 540 |
| 541 /* Getting and setting values of symbols */ | |
| 542 | |
| 543 /* Given the raw contents of a symbol value cell, | |
| 544 return the Lisp value of the symbol. | |
| 545 This does not handle buffer-local variables; use | |
| 546 swap_in_symval_forwarding for that. */ | |
| 547 | |
| 548 Lisp_Object | |
| 549 do_symval_forwarding (valcontents) | |
| 550 register Lisp_Object valcontents; | |
| 551 { | |
| 552 register Lisp_Object val; | |
| 553 #ifdef SWITCH_ENUM_BUG | |
| 554 switch ((int) XTYPE (valcontents)) | |
| 555 #else | |
| 556 switch (XTYPE (valcontents)) | |
| 557 #endif | |
| 558 { | |
| 559 case Lisp_Intfwd: | |
| 560 XSET (val, Lisp_Int, *XINTPTR (valcontents)); | |
| 561 return val; | |
| 562 | |
| 563 case Lisp_Boolfwd: | |
| 564 if (*XINTPTR (valcontents)) | |
| 565 return Qt; | |
| 566 return Qnil; | |
| 567 | |
| 568 case Lisp_Objfwd: | |
| 569 return *XOBJFWD (valcontents); | |
| 570 | |
| 571 case Lisp_Buffer_Objfwd: | |
| 572 return *(Lisp_Object *)(XUINT (valcontents) + (char *)current_buffer); | |
| 573 } | |
| 574 return valcontents; | |
| 575 } | |
| 576 | |
| 577 /* Store NEWVAL into SYM, where VALCONTENTS is found in the value cell | |
| 578 of SYM. If SYM is buffer-local, VALCONTENTS should be the | |
| 579 buffer-independent contents of the value cell: forwarded just one | |
| 580 step past the buffer-localness. */ | |
| 581 | |
| 582 void | |
| 583 store_symval_forwarding (sym, valcontents, newval) | |
| 584 Lisp_Object sym; | |
| 585 register Lisp_Object valcontents, newval; | |
| 586 { | |
| 587 #ifdef SWITCH_ENUM_BUG | |
| 588 switch ((int) XTYPE (valcontents)) | |
| 589 #else | |
| 590 switch (XTYPE (valcontents)) | |
| 591 #endif | |
| 592 { | |
| 593 case Lisp_Intfwd: | |
| 594 CHECK_NUMBER (newval, 1); | |
| 595 *XINTPTR (valcontents) = XINT (newval); | |
| 596 break; | |
| 597 | |
| 598 case Lisp_Boolfwd: | |
| 490 | 599 *XINTPTR (valcontents) = NILP(newval) ? 0 : 1; |
| 298 | 600 break; |
| 601 | |
| 602 case Lisp_Objfwd: | |
| 603 *XOBJFWD (valcontents) = newval; | |
| 604 break; | |
| 605 | |
| 606 case Lisp_Buffer_Objfwd: | |
| 607 *(Lisp_Object *)(XUINT (valcontents) + (char *)current_buffer) = newval; | |
| 608 break; | |
| 609 | |
| 610 default: | |
| 611 valcontents = XSYMBOL (sym)->value; | |
| 612 if (XTYPE (valcontents) == Lisp_Buffer_Local_Value | |
| 613 || XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value) | |
| 614 XCONS (XSYMBOL (sym)->value)->car = newval; | |
| 615 else | |
| 616 XSYMBOL (sym)->value = newval; | |
| 617 } | |
| 618 } | |
| 619 | |
| 620 /* Set up the buffer-local symbol SYM for validity in the current | |
| 621 buffer. VALCONTENTS is the contents of its value cell. | |
| 622 Return the value forwarded one step past the buffer-local indicator. */ | |
| 623 | |
| 624 static Lisp_Object | |
| 625 swap_in_symval_forwarding (sym, valcontents) | |
| 626 Lisp_Object sym, valcontents; | |
| 627 { | |
| 628 /* valcontents is a list | |
| 629 (REALVALUE BUFFER CURRENT-ALIST-ELEMENT . DEFAULT-VALUE)). | |
| 630 | |
| 631 CURRENT-ALIST-ELEMENT is a pointer to an element of BUFFER's | |
| 632 local_var_alist, that being the element whose car is this variable. | |
| 633 Or it can be a pointer to the (CURRENT-ALIST-ELEMENT . DEFAULT-VALUE), if BUFFER | |
| 634 does not have an element in its alist for this variable. | |
| 635 | |
| 636 If the current buffer is not BUFFER, we store the current REALVALUE value into | |
| 637 CURRENT-ALIST-ELEMENT, then find the appropriate alist element for | |
| 638 the buffer now current and set up CURRENT-ALIST-ELEMENT. | |
| 639 Then we set REALVALUE out of that element, and store into BUFFER. | |
| 640 Note that REALVALUE can be a forwarding pointer. */ | |
| 641 | |
| 642 register Lisp_Object tem1; | |
| 643 tem1 = XCONS (XCONS (valcontents)->cdr)->car; | |
| 644 | |
| 490 | 645 if (NILP (tem1) || current_buffer != XBUFFER (tem1)) |
| 298 | 646 { |
| 647 tem1 = XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car; | |
| 648 Fsetcdr (tem1, do_symval_forwarding (XCONS (valcontents)->car)); | |
| 649 tem1 = assq_no_quit (sym, current_buffer->local_var_alist); | |
| 490 | 650 if (NILP (tem1)) |
| 298 | 651 tem1 = XCONS (XCONS (valcontents)->cdr)->cdr; |
| 652 XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car = tem1; | |
| 653 XSET (XCONS (XCONS (valcontents)->cdr)->car, Lisp_Buffer, current_buffer); | |
| 654 store_symval_forwarding (sym, XCONS (valcontents)->car, Fcdr (tem1)); | |
| 655 } | |
| 656 return XCONS (valcontents)->car; | |
| 657 } | |
| 658 | |
| 514 | 659 /* Find the value of a symbol, returning Qunbound if it's not bound. |
| 660 This is helpful for code which just wants to get a variable's value | |
| 661 if it has one, without signalling an error. | |
| 662 Note that it must not be possible to quit | |
| 663 within this function. Great care is required for this. */ | |
| 298 | 664 |
| 514 | 665 Lisp_Object |
| 666 find_symbol_value (sym) | |
| 298 | 667 Lisp_Object sym; |
| 668 { | |
| 669 register Lisp_Object valcontents, tem1; | |
| 670 register Lisp_Object val; | |
| 671 CHECK_SYMBOL (sym, 0); | |
| 672 valcontents = XSYMBOL (sym)->value; | |
| 673 | |
| 674 retry: | |
| 675 #ifdef SWITCH_ENUM_BUG | |
| 676 switch ((int) XTYPE (valcontents)) | |
| 677 #else | |
| 678 switch (XTYPE (valcontents)) | |
| 679 #endif | |
| 680 { | |
| 681 case Lisp_Buffer_Local_Value: | |
| 682 case Lisp_Some_Buffer_Local_Value: | |
| 683 valcontents = swap_in_symval_forwarding (sym, valcontents); | |
| 684 goto retry; | |
| 685 | |
| 686 case Lisp_Intfwd: | |
| 687 XSET (val, Lisp_Int, *XINTPTR (valcontents)); | |
| 688 return val; | |
| 689 | |
| 690 case Lisp_Boolfwd: | |
| 691 if (*XINTPTR (valcontents)) | |
| 692 return Qt; | |
| 693 return Qnil; | |
| 694 | |
| 695 case Lisp_Objfwd: | |
| 696 return *XOBJFWD (valcontents); | |
| 697 | |
| 698 case Lisp_Buffer_Objfwd: | |
| 699 return *(Lisp_Object *)(XUINT (valcontents) + (char *)current_buffer); | |
| 700 | |
| 701 case Lisp_Void: | |
| 514 | 702 return Qunbound; |
| 298 | 703 } |
| 704 | |
| 705 return valcontents; | |
| 706 } | |
| 707 | |
| 514 | 708 DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0, |
| 709 "Return SYMBOL's value. Error if that is void.") | |
| 710 (sym) | |
| 711 Lisp_Object sym; | |
| 712 { | |
| 713 Lisp_Object val = find_symbol_value (sym); | |
| 714 | |
| 715 if (EQ (val, Qunbound)) | |
| 716 return Fsignal (Qvoid_variable, Fcons (sym, Qnil)); | |
| 717 else | |
| 718 return val; | |
| 719 } | |
| 720 | |
| 298 | 721 DEFUN ("set", Fset, Sset, 2, 2, 0, |
| 722 "Set SYMBOL's value to NEWVAL, and return NEWVAL.") | |
| 723 (sym, newval) | |
| 724 register Lisp_Object sym, newval; | |
| 725 { | |
| 726 int voide = (XTYPE (newval) == Lisp_Void || EQ (newval, Qunbound)); | |
| 727 | |
| 728 #ifndef RTPC_REGISTER_BUG | |
| 729 register Lisp_Object valcontents, tem1, current_alist_element; | |
| 730 #else /* RTPC_REGISTER_BUG */ | |
| 731 register Lisp_Object tem1; | |
| 732 Lisp_Object valcontents, current_alist_element; | |
| 733 #endif /* RTPC_REGISTER_BUG */ | |
| 734 | |
| 735 CHECK_SYMBOL (sym, 0); | |
| 490 | 736 if (NILP (sym) || EQ (sym, Qt)) |
| 298 | 737 return Fsignal (Qsetting_constant, Fcons (sym, Qnil)); |
| 738 valcontents = XSYMBOL (sym)->value; | |
| 739 | |
| 740 if (XTYPE (valcontents) == Lisp_Buffer_Objfwd) | |
| 741 { | |
| 742 register int idx = XUINT (valcontents); | |
| 743 register int mask = *(int *)(idx + (char *) &buffer_local_flags); | |
| 744 if (mask > 0) | |
| 745 current_buffer->local_var_flags |= mask; | |
| 746 } | |
| 747 | |
| 748 if (XTYPE (valcontents) == Lisp_Buffer_Local_Value | |
| 749 || XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value) | |
| 750 { | |
| 751 /* valcontents is a list | |
| 752 (REALVALUE BUFFER CURRENT-ALIST-ELEMENT . DEFAULT-VALUE)). | |
| 753 | |
| 754 CURRENT-ALIST-ELEMENT is a pointer to an element of BUFFER's | |
| 755 local_var_alist, that being the element whose car is this variable. | |
| 756 Or it can be a pointer to the (CURRENT-ALIST-ELEMENT . DEFAULT-VALUE), if BUFFER | |
| 757 does not have an element in its alist for this variable. | |
| 758 | |
| 759 If the current buffer is not BUFFER, we store the current REALVALUE value into | |
| 760 CURRENT-ALIST-ELEMENT, then find the appropriate alist element for | |
| 761 the buffer now current and set up CURRENT-ALIST-ELEMENT. | |
| 762 Then we set REALVALUE out of that element, and store into BUFFER. | |
| 763 Note that REALVALUE can be a forwarding pointer. */ | |
| 764 | |
| 765 current_alist_element = XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car; | |
| 766 if (current_buffer != ((XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value) | |
| 767 ? XBUFFER (XCONS (XCONS (valcontents)->cdr)->car) | |
| 768 : XBUFFER (XCONS (current_alist_element)->car))) | |
| 769 { | |
| 770 Fsetcdr (current_alist_element, do_symval_forwarding (XCONS (valcontents)->car)); | |
| 771 | |
| 772 tem1 = Fassq (sym, current_buffer->local_var_alist); | |
| 490 | 773 if (NILP (tem1)) |
| 298 | 774 /* This buffer sees the default value still. |
| 775 If type is Lisp_Some_Buffer_Local_Value, set the default value. | |
| 776 If type is Lisp_Buffer_Local_Value, give this buffer a local value | |
| 777 and set that. */ | |
| 778 if (XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value) | |
| 779 tem1 = XCONS (XCONS (valcontents)->cdr)->cdr; | |
| 780 else | |
| 781 { | |
| 782 tem1 = Fcons (sym, Fcdr (current_alist_element)); | |
| 783 current_buffer->local_var_alist = Fcons (tem1, current_buffer->local_var_alist); | |
| 784 } | |
| 785 XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car = tem1; | |
| 786 XSET (XCONS (XCONS (valcontents)->cdr)->car, Lisp_Buffer, current_buffer); | |
| 787 } | |
| 788 valcontents = XCONS (valcontents)->car; | |
| 789 } | |
| 790 /* If storing void (making the symbol void), forward only through | |
| 791 buffer-local indicator, not through Lisp_Objfwd, etc. */ | |
| 792 if (voide) | |
| 793 store_symval_forwarding (sym, Qnil, newval); | |
| 794 else | |
| 795 store_symval_forwarding (sym, valcontents, newval); | |
| 796 return newval; | |
| 797 } | |
| 798 | |
| 799 /* Access or set a buffer-local symbol's default value. */ | |
| 800 | |
| 801 /* Return the default value of SYM, but don't check for voidness. | |
| 802 Return Qunbound or a Lisp_Void object if it is void. */ | |
| 803 | |
| 804 Lisp_Object | |
| 805 default_value (sym) | |
| 806 Lisp_Object sym; | |
| 807 { | |
| 808 register Lisp_Object valcontents; | |
| 809 | |
| 810 CHECK_SYMBOL (sym, 0); | |
| 811 valcontents = XSYMBOL (sym)->value; | |
| 812 | |
| 813 /* For a built-in buffer-local variable, get the default value | |
| 814 rather than letting do_symval_forwarding get the current value. */ | |
| 815 if (XTYPE (valcontents) == Lisp_Buffer_Objfwd) | |
| 816 { | |
| 817 register int idx = XUINT (valcontents); | |
| 818 | |
| 819 if (*(int *) (idx + (char *) &buffer_local_flags) != 0) | |
| 820 return *(Lisp_Object *)(idx + (char *) &buffer_defaults); | |
| 821 } | |
| 822 | |
| 823 /* Handle user-created local variables. */ | |
| 824 if (XTYPE (valcontents) == Lisp_Buffer_Local_Value | |
| 825 || XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value) | |
| 826 { | |
| 827 /* If var is set up for a buffer that lacks a local value for it, | |
| 828 the current value is nominally the default value. | |
| 829 But the current value slot may be more up to date, since | |
| 830 ordinary setq stores just that slot. So use that. */ | |
| 831 Lisp_Object current_alist_element, alist_element_car; | |
| 832 current_alist_element | |
| 833 = XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car; | |
| 834 alist_element_car = XCONS (current_alist_element)->car; | |
| 835 if (EQ (alist_element_car, current_alist_element)) | |
| 836 return do_symval_forwarding (XCONS (valcontents)->car); | |
| 837 else | |
| 838 return XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->cdr; | |
| 839 } | |
| 840 /* For other variables, get the current value. */ | |
| 841 return do_symval_forwarding (valcontents); | |
| 842 } | |
| 843 | |
| 844 DEFUN ("default-boundp", Fdefault_boundp, Sdefault_boundp, 1, 1, 0, | |
| 845 "Return T if SYMBOL has a non-void default value.\n\ | |
| 846 This is the value that is seen in buffers that do not have their own values\n\ | |
| 847 for this variable.") | |
| 848 (sym) | |
| 849 Lisp_Object sym; | |
| 850 { | |
| 851 register Lisp_Object value; | |
| 852 | |
| 853 value = default_value (sym); | |
| 854 return (XTYPE (value) == Lisp_Void || EQ (value, Qunbound) | |
| 855 ? Qnil : Qt); | |
| 856 } | |
| 857 | |
| 858 DEFUN ("default-value", Fdefault_value, Sdefault_value, 1, 1, 0, | |
| 859 "Return SYMBOL's default value.\n\ | |
| 860 This is the value that is seen in buffers that do not have their own values\n\ | |
| 861 for this variable. The default value is meaningful for variables with\n\ | |
| 862 local bindings in certain buffers.") | |
| 863 (sym) | |
| 864 Lisp_Object sym; | |
| 865 { | |
| 866 register Lisp_Object value; | |
| 867 | |
| 868 value = default_value (sym); | |
| 869 if (XTYPE (value) == Lisp_Void || EQ (value, Qunbound)) | |
| 870 return Fsignal (Qvoid_variable, Fcons (sym, Qnil)); | |
| 871 return value; | |
| 872 } | |
| 873 | |
| 874 DEFUN ("set-default", Fset_default, Sset_default, 2, 2, 0, | |
| 875 "Set SYMBOL's default value to VAL. SYMBOL and VAL are evaluated.\n\ | |
| 876 The default value is seen in buffers that do not have their own values\n\ | |
| 877 for this variable.") | |
| 878 (sym, value) | |
| 879 Lisp_Object sym, value; | |
| 880 { | |
| 881 register Lisp_Object valcontents, current_alist_element, alist_element_buffer; | |
| 882 | |
| 883 CHECK_SYMBOL (sym, 0); | |
| 884 valcontents = XSYMBOL (sym)->value; | |
| 885 | |
| 886 /* Handle variables like case-fold-search that have special slots | |
| 887 in the buffer. Make them work apparently like Lisp_Buffer_Local_Value | |
| 888 variables. */ | |
| 889 if (XTYPE (valcontents) == Lisp_Buffer_Objfwd) | |
| 890 { | |
| 891 register int idx = XUINT (valcontents); | |
| 892 #ifndef RTPC_REGISTER_BUG | |
| 893 register struct buffer *b; | |
| 894 #else | |
| 895 struct buffer *b; | |
| 896 #endif | |
| 897 register int mask = *(int *) (idx + (char *) &buffer_local_flags); | |
| 898 | |
| 899 if (mask > 0) | |
| 900 { | |
| 901 *(Lisp_Object *)(idx + (char *) &buffer_defaults) = value; | |
| 902 for (b = all_buffers; b; b = b->next) | |
| 903 if (!(b->local_var_flags & mask)) | |
| 904 *(Lisp_Object *)(idx + (char *) b) = value; | |
| 905 } | |
| 906 return value; | |
| 907 } | |
| 908 | |
| 909 if (XTYPE (valcontents) != Lisp_Buffer_Local_Value && | |
| 910 XTYPE (valcontents) != Lisp_Some_Buffer_Local_Value) | |
| 911 return Fset (sym, value); | |
| 912 | |
| 913 /* Store new value into the DEFAULT-VALUE slot */ | |
| 914 XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->cdr = value; | |
| 915 | |
| 916 /* If that slot is current, we must set the REALVALUE slot too */ | |
| 917 current_alist_element = XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car; | |
| 918 alist_element_buffer = Fcar (current_alist_element); | |
| 919 if (EQ (alist_element_buffer, current_alist_element)) | |
| 920 store_symval_forwarding (sym, XCONS (valcontents)->car, value); | |
| 921 | |
| 922 return value; | |
| 923 } | |
| 924 | |
| 925 DEFUN ("setq-default", Fsetq_default, Ssetq_default, 2, UNEVALLED, 0, | |
| 926 "\ | |
| 927 (setq-default SYM VAL SYM VAL ...): set each SYM's default value to its VAL.\n\ | |
| 928 VAL is evaluated; SYM is not. The default value is seen in buffers that do\n\ | |
| 929 not have their own values for this variable.") | |
| 930 (args) | |
| 931 Lisp_Object args; | |
| 932 { | |
| 933 register Lisp_Object args_left; | |
| 934 register Lisp_Object val, sym; | |
| 935 struct gcpro gcpro1; | |
| 936 | |
| 490 | 937 if (NILP (args)) |
| 298 | 938 return Qnil; |
| 939 | |
| 940 args_left = args; | |
| 941 GCPRO1 (args); | |
| 942 | |
| 943 do | |
| 944 { | |
| 945 val = Feval (Fcar (Fcdr (args_left))); | |
| 946 sym = Fcar (args_left); | |
| 947 Fset_default (sym, val); | |
| 948 args_left = Fcdr (Fcdr (args_left)); | |
| 949 } | |
| 490 | 950 while (!NILP (args_left)); |
| 298 | 951 |
| 952 UNGCPRO; | |
| 953 return val; | |
| 954 } | |
| 955 | |
| 956 DEFUN ("make-variable-buffer-local", Fmake_variable_buffer_local, Smake_variable_buffer_local, | |
| 957 1, 1, "vMake Variable Buffer Local: ", | |
| 958 "Make VARIABLE have a separate value for each buffer.\n\ | |
| 959 At any time, the value for the current buffer is in effect.\n\ | |
| 960 There is also a default value which is seen in any buffer which has not yet\n\ | |
| 961 set its own value.\n\ | |
| 962 Using `set' or `setq' to set the variable causes it to have a separate value\n\ | |
| 963 for the current buffer if it was previously using the default value.\n\ | |
| 964 The function `default-value' gets the default value and `set-default' sets it.") | |
| 965 (sym) | |
| 966 register Lisp_Object sym; | |
| 967 { | |
| 968 register Lisp_Object tem, valcontents; | |
| 969 | |
| 970 CHECK_SYMBOL (sym, 0); | |
| 971 | |
| 972 if (EQ (sym, Qnil) || EQ (sym, Qt)) | |
| 973 error ("Symbol %s may not be buffer-local", XSYMBOL (sym)->name->data); | |
| 974 | |
| 975 valcontents = XSYMBOL (sym)->value; | |
| 976 if ((XTYPE (valcontents) == Lisp_Buffer_Local_Value) || | |
| 977 (XTYPE (valcontents) == Lisp_Buffer_Objfwd)) | |
| 978 return sym; | |
| 979 if (XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value) | |
| 980 { | |
| 981 XSETTYPE (XSYMBOL (sym)->value, Lisp_Buffer_Local_Value); | |
| 982 return sym; | |
| 983 } | |
| 984 if (EQ (valcontents, Qunbound)) | |
| 985 XSYMBOL (sym)->value = Qnil; | |
| 986 tem = Fcons (Qnil, Fsymbol_value (sym)); | |
| 987 XCONS (tem)->car = tem; | |
| 988 XSYMBOL (sym)->value = Fcons (XSYMBOL (sym)->value, Fcons (Fcurrent_buffer (), tem)); | |
| 989 XSETTYPE (XSYMBOL (sym)->value, Lisp_Buffer_Local_Value); | |
| 990 return sym; | |
| 991 } | |
| 992 | |
| 993 DEFUN ("make-local-variable", Fmake_local_variable, Smake_local_variable, | |
| 994 1, 1, "vMake Local Variable: ", | |
| 995 "Make VARIABLE have a separate value in the current buffer.\n\ | |
| 996 Other buffers will continue to share a common default value.\n\ | |
| 997 See also `make-variable-buffer-local'.\n\n\ | |
| 998 If the variable is already arranged to become local when set,\n\ | |
| 999 this function causes a local value to exist for this buffer,\n\ | |
| 1000 just as if the variable were set.") | |
| 1001 (sym) | |
| 1002 register Lisp_Object sym; | |
| 1003 { | |
| 1004 register Lisp_Object tem, valcontents; | |
| 1005 | |
| 1006 CHECK_SYMBOL (sym, 0); | |
| 1007 | |
| 1008 if (EQ (sym, Qnil) || EQ (sym, Qt)) | |
| 1009 error ("Symbol %s may not be buffer-local", XSYMBOL (sym)->name->data); | |
| 1010 | |
| 1011 valcontents = XSYMBOL (sym)->value; | |
| 1012 if (XTYPE (valcontents) == Lisp_Buffer_Local_Value | |
| 1013 || XTYPE (valcontents) == Lisp_Buffer_Objfwd) | |
| 1014 { | |
| 1015 tem = Fboundp (sym); | |
| 1016 | |
| 1017 /* Make sure the symbol has a local value in this particular buffer, | |
| 1018 by setting it to the same value it already has. */ | |
| 1019 Fset (sym, (EQ (tem, Qt) ? Fsymbol_value (sym) : Qunbound)); | |
| 1020 return sym; | |
| 1021 } | |
| 1022 /* Make sure sym is set up to hold per-buffer values */ | |
| 1023 if (XTYPE (valcontents) != Lisp_Some_Buffer_Local_Value) | |
| 1024 { | |
| 1025 if (EQ (valcontents, Qunbound)) | |
| 1026 XSYMBOL (sym)->value = Qnil; | |
| 1027 tem = Fcons (Qnil, do_symval_forwarding (valcontents)); | |
| 1028 XCONS (tem)->car = tem; | |
| 1029 XSYMBOL (sym)->value = Fcons (XSYMBOL (sym)->value, Fcons (Qnil, tem)); | |
| 1030 XSETTYPE (XSYMBOL (sym)->value, Lisp_Some_Buffer_Local_Value); | |
| 1031 } | |
| 1032 /* Make sure this buffer has its own value of sym */ | |
| 1033 tem = Fassq (sym, current_buffer->local_var_alist); | |
| 490 | 1034 if (NILP (tem)) |
| 298 | 1035 { |
| 1036 current_buffer->local_var_alist | |
| 1037 = Fcons (Fcons (sym, XCONS (XCONS (XCONS (XSYMBOL (sym)->value)->cdr)->cdr)->cdr), | |
| 1038 current_buffer->local_var_alist); | |
| 1039 | |
| 1040 /* Make sure symbol does not think it is set up for this buffer; | |
| 1041 force it to look once again for this buffer's value */ | |
| 1042 { | |
| 1043 /* This local variable avoids "expression too complex" on IBM RT. */ | |
| 1044 Lisp_Object xs; | |
| 1045 | |
| 1046 xs = XSYMBOL (sym)->value; | |
| 1047 if (current_buffer == XBUFFER (XCONS (XCONS (xs)->cdr)->car)) | |
| 1048 XCONS (XCONS (XSYMBOL (sym)->value)->cdr)->car = Qnil; | |
| 1049 } | |
| 1050 | |
| 1051 } | |
| 1052 return sym; | |
| 1053 } | |
| 1054 | |
| 1055 DEFUN ("kill-local-variable", Fkill_local_variable, Skill_local_variable, | |
| 1056 1, 1, "vKill Local Variable: ", | |
| 1057 "Make VARIABLE no longer have a separate value in the current buffer.\n\ | |
| 1058 From now on the default value will apply in this buffer.") | |
| 1059 (sym) | |
| 1060 register Lisp_Object sym; | |
| 1061 { | |
| 1062 register Lisp_Object tem, valcontents; | |
| 1063 | |
| 1064 CHECK_SYMBOL (sym, 0); | |
| 1065 | |
| 1066 valcontents = XSYMBOL (sym)->value; | |
| 1067 | |
| 1068 if (XTYPE (valcontents) == Lisp_Buffer_Objfwd) | |
| 1069 { | |
| 1070 register int idx = XUINT (valcontents); | |
| 1071 register int mask = *(int *) (idx + (char *) &buffer_local_flags); | |
| 1072 | |
| 1073 if (mask > 0) | |
| 1074 { | |
| 1075 *(Lisp_Object *)(idx + (char *) current_buffer) | |
| 1076 = *(Lisp_Object *)(idx + (char *) &buffer_defaults); | |
| 1077 current_buffer->local_var_flags &= ~mask; | |
| 1078 } | |
| 1079 return sym; | |
| 1080 } | |
| 1081 | |
| 1082 if (XTYPE (valcontents) != Lisp_Buffer_Local_Value && | |
| 1083 XTYPE (valcontents) != Lisp_Some_Buffer_Local_Value) | |
| 1084 return sym; | |
| 1085 | |
| 1086 /* Get rid of this buffer's alist element, if any */ | |
| 1087 | |
| 1088 tem = Fassq (sym, current_buffer->local_var_alist); | |
| 490 | 1089 if (!NILP (tem)) |
| 298 | 1090 current_buffer->local_var_alist = Fdelq (tem, current_buffer->local_var_alist); |
| 1091 | |
| 1092 /* Make sure symbol does not think it is set up for this buffer; | |
| 1093 force it to look once again for this buffer's value */ | |
| 1094 { | |
| 1095 Lisp_Object sv; | |
| 1096 sv = XSYMBOL (sym)->value; | |
| 1097 if (current_buffer == XBUFFER (XCONS (XCONS (sv)->cdr)->car)) | |
| 1098 XCONS (XCONS (sv)->cdr)->car = Qnil; | |
| 1099 } | |
| 1100 | |
| 1101 return sym; | |
| 1102 } | |
| 1103 | |
| 648 | 1104 /* Find the function at the end of a chain of symbol function indirections. */ |
| 1105 | |
| 1106 /* If OBJECT is a symbol, find the end of its function chain and | |
| 1107 return the value found there. If OBJECT is not a symbol, just | |
| 1108 return it. If there is a cycle in the function chain, signal a | |
| 1109 cyclic-function-indirection error. | |
| 1110 | |
| 1111 This is like Findirect_function, except that it doesn't signal an | |
| 1112 error if the chain ends up unbound. */ | |
| 1113 Lisp_Object | |
| 1114 indirect_function (object, error) | |
| 1115 register Lisp_Object object; | |
| 1116 { | |
| 1117 Lisp_Object tortise, hare; | |
| 1118 | |
| 1119 hare = tortise = object; | |
| 1120 | |
| 1121 for (;;) | |
| 1122 { | |
| 1123 if (XTYPE (hare) != Lisp_Symbol || EQ (hare, Qunbound)) | |
| 1124 break; | |
| 1125 hare = XSYMBOL (hare)->function; | |
| 1126 if (XTYPE (hare) != Lisp_Symbol || EQ (hare, Qunbound)) | |
| 1127 break; | |
| 1128 hare = XSYMBOL (hare)->function; | |
| 1129 | |
| 1130 tortise = XSYMBOL (tortise)->function; | |
| 1131 | |
| 1132 if (EQ (hare, tortise)) | |
| 1133 Fsignal (Qcyclic_function_indirection, Fcons (object, Qnil)); | |
| 1134 } | |
| 1135 | |
| 1136 return hare; | |
| 1137 } | |
| 1138 | |
| 1139 DEFUN ("indirect-function", Findirect_function, Sindirect_function, 1, 1, 0, | |
| 1140 "Return the function at the end of OBJECT's function chain.\n\ | |
| 1141 If OBJECT is a symbol, follow all function indirections and return the final\n\ | |
| 1142 function binding.\n\ | |
| 1143 If OBJECT is not a symbol, just return it.\n\ | |
| 1144 Signal a void-function error if the final symbol is unbound.\n\ | |
| 1145 Signal a cyclic-function-indirection error if there is a loop in the\n\ | |
| 1146 function chain of symbols.") | |
| 1147 (object) | |
| 1148 register Lisp_Object object; | |
| 1149 { | |
| 1150 Lisp_Object result; | |
| 1151 | |
| 1152 result = indirect_function (object); | |
| 1153 | |
| 1154 if (EQ (result, Qunbound)) | |
| 1155 return Fsignal (Qvoid_function, Fcons (object, Qnil)); | |
| 1156 return result; | |
| 1157 } | |
| 1158 | |
| 298 | 1159 /* Extract and set vector and string elements */ |
| 1160 | |
| 1161 DEFUN ("aref", Faref, Saref, 2, 2, 0, | |
| 1162 "Return the element of ARRAY at index INDEX.\n\ | |
| 1163 ARRAY may be a vector or a string, or a byte-code object. INDEX starts at 0.") | |
| 1164 (array, idx) | |
| 1165 register Lisp_Object array; | |
| 1166 Lisp_Object idx; | |
| 1167 { | |
| 1168 register int idxval; | |
| 1169 | |
| 1170 CHECK_NUMBER (idx, 1); | |
| 1171 idxval = XINT (idx); | |
| 1172 if (XTYPE (array) != Lisp_Vector && XTYPE (array) != Lisp_String | |
| 1173 && XTYPE (array) != Lisp_Compiled) | |
| 1174 array = wrong_type_argument (Qarrayp, array); | |
| 1175 if (idxval < 0 || idxval >= XVECTOR (array)->size) | |
| 1176 args_out_of_range (array, idx); | |
| 1177 if (XTYPE (array) == Lisp_String) | |
| 1178 { | |
| 1179 Lisp_Object val; | |
| 1180 XFASTINT (val) = (unsigned char) XSTRING (array)->data[idxval]; | |
| 1181 return val; | |
| 1182 } | |
| 1183 else | |
| 1184 return XVECTOR (array)->contents[idxval]; | |
| 1185 } | |
| 1186 | |
| 1187 DEFUN ("aset", Faset, Saset, 3, 3, 0, | |
| 1188 "Store into the element of ARRAY at index INDEX the value NEWVAL.\n\ | |
| 1189 ARRAY may be a vector or a string. INDEX starts at 0.") | |
| 1190 (array, idx, newelt) | |
| 1191 register Lisp_Object array; | |
| 1192 Lisp_Object idx, newelt; | |
| 1193 { | |
| 1194 register int idxval; | |
| 1195 | |
| 1196 CHECK_NUMBER (idx, 1); | |
| 1197 idxval = XINT (idx); | |
| 1198 if (XTYPE (array) != Lisp_Vector && XTYPE (array) != Lisp_String) | |
| 1199 array = wrong_type_argument (Qarrayp, array); | |
| 1200 if (idxval < 0 || idxval >= XVECTOR (array)->size) | |
| 1201 args_out_of_range (array, idx); | |
| 1202 CHECK_IMPURE (array); | |
| 1203 | |
| 1204 if (XTYPE (array) == Lisp_Vector) | |
| 1205 XVECTOR (array)->contents[idxval] = newelt; | |
| 1206 else | |
| 1207 { | |
| 1208 CHECK_NUMBER (newelt, 2); | |
| 1209 XSTRING (array)->data[idxval] = XINT (newelt); | |
| 1210 } | |
| 1211 | |
| 1212 return newelt; | |
| 1213 } | |
| 1214 | |
| 1215 Lisp_Object | |
| 1216 Farray_length (array) | |
| 1217 register Lisp_Object array; | |
| 1218 { | |
| 1219 register Lisp_Object size; | |
| 1220 if (XTYPE (array) != Lisp_Vector && XTYPE (array) != Lisp_String | |
| 1221 && XTYPE (array) != Lisp_Compiled) | |
| 1222 array = wrong_type_argument (Qarrayp, array); | |
| 1223 XFASTINT (size) = XVECTOR (array)->size; | |
| 1224 return size; | |
| 1225 } | |
| 1226 | |
| 1227 /* Arithmetic functions */ | |
| 1228 | |
| 1229 enum comparison { equal, notequal, less, grtr, less_or_equal, grtr_or_equal }; | |
| 1230 | |
| 1231 Lisp_Object | |
| 1232 arithcompare (num1, num2, comparison) | |
| 1233 Lisp_Object num1, num2; | |
| 1234 enum comparison comparison; | |
| 1235 { | |
| 1236 double f1, f2; | |
| 1237 int floatp = 0; | |
| 1238 | |
| 1239 #ifdef LISP_FLOAT_TYPE | |
| 1240 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0); | |
| 1241 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0); | |
| 1242 | |
| 1243 if (XTYPE (num1) == Lisp_Float || XTYPE (num2) == Lisp_Float) | |
| 1244 { | |
| 1245 floatp = 1; | |
| 1246 f1 = (XTYPE (num1) == Lisp_Float) ? XFLOAT (num1)->data : XINT (num1); | |
| 1247 f2 = (XTYPE (num2) == Lisp_Float) ? XFLOAT (num2)->data : XINT (num2); | |
| 1248 } | |
| 1249 #else | |
| 1250 CHECK_NUMBER_COERCE_MARKER (num1, 0); | |
| 1251 CHECK_NUMBER_COERCE_MARKER (num2, 0); | |
| 1252 #endif /* LISP_FLOAT_TYPE */ | |
| 1253 | |
| 1254 switch (comparison) | |
| 1255 { | |
| 1256 case equal: | |
| 1257 if (floatp ? f1 == f2 : XINT (num1) == XINT (num2)) | |
| 1258 return Qt; | |
| 1259 return Qnil; | |
| 1260 | |
| 1261 case notequal: | |
| 1262 if (floatp ? f1 != f2 : XINT (num1) != XINT (num2)) | |
| 1263 return Qt; | |
| 1264 return Qnil; | |
| 1265 | |
| 1266 case less: | |
| 1267 if (floatp ? f1 < f2 : XINT (num1) < XINT (num2)) | |
| 1268 return Qt; | |
| 1269 return Qnil; | |
| 1270 | |
| 1271 case less_or_equal: | |
| 1272 if (floatp ? f1 <= f2 : XINT (num1) <= XINT (num2)) | |
| 1273 return Qt; | |
| 1274 return Qnil; | |
| 1275 | |
| 1276 case grtr: | |
| 1277 if (floatp ? f1 > f2 : XINT (num1) > XINT (num2)) | |
| 1278 return Qt; | |
| 1279 return Qnil; | |
| 1280 | |
| 1281 case grtr_or_equal: | |
| 1282 if (floatp ? f1 >= f2 : XINT (num1) >= XINT (num2)) | |
| 1283 return Qt; | |
| 1284 return Qnil; | |
| 1285 } | |
| 1286 } | |
| 1287 | |
| 1288 DEFUN ("=", Feqlsign, Seqlsign, 2, 2, 0, | |
| 1289 "T if two args, both numbers or markers, are equal.") | |
| 1290 (num1, num2) | |
| 1291 register Lisp_Object num1, num2; | |
| 1292 { | |
| 1293 return arithcompare (num1, num2, equal); | |
| 1294 } | |
| 1295 | |
| 1296 DEFUN ("<", Flss, Slss, 2, 2, 0, | |
| 1297 "T if first arg is less than second arg. Both must be numbers or markers.") | |
| 1298 (num1, num2) | |
| 1299 register Lisp_Object num1, num2; | |
| 1300 { | |
| 1301 return arithcompare (num1, num2, less); | |
| 1302 } | |
| 1303 | |
| 1304 DEFUN (">", Fgtr, Sgtr, 2, 2, 0, | |
| 1305 "T if first arg is greater than second arg. Both must be numbers or markers.") | |
| 1306 (num1, num2) | |
| 1307 register Lisp_Object num1, num2; | |
| 1308 { | |
| 1309 return arithcompare (num1, num2, grtr); | |
| 1310 } | |
| 1311 | |
| 1312 DEFUN ("<=", Fleq, Sleq, 2, 2, 0, | |
| 1313 "T if first arg is less than or equal to second arg.\n\ | |
| 1314 Both must be numbers or markers.") | |
| 1315 (num1, num2) | |
| 1316 register Lisp_Object num1, num2; | |
| 1317 { | |
| 1318 return arithcompare (num1, num2, less_or_equal); | |
| 1319 } | |
| 1320 | |
| 1321 DEFUN (">=", Fgeq, Sgeq, 2, 2, 0, | |
| 1322 "T if first arg is greater than or equal to second arg.\n\ | |
| 1323 Both must be numbers or markers.") | |
| 1324 (num1, num2) | |
| 1325 register Lisp_Object num1, num2; | |
| 1326 { | |
| 1327 return arithcompare (num1, num2, grtr_or_equal); | |
| 1328 } | |
| 1329 | |
| 1330 DEFUN ("/=", Fneq, Sneq, 2, 2, 0, | |
| 1331 "T if first arg is not equal to second arg. Both must be numbers or markers.") | |
| 1332 (num1, num2) | |
| 1333 register Lisp_Object num1, num2; | |
| 1334 { | |
| 1335 return arithcompare (num1, num2, notequal); | |
| 1336 } | |
| 1337 | |
| 1338 DEFUN ("zerop", Fzerop, Szerop, 1, 1, 0, "T if NUMBER is zero.") | |
| 1339 (num) | |
| 1340 register Lisp_Object num; | |
| 1341 { | |
| 1342 #ifdef LISP_FLOAT_TYPE | |
| 1343 CHECK_NUMBER_OR_FLOAT (num, 0); | |
| 1344 | |
| 1345 if (XTYPE(num) == Lisp_Float) | |
| 1346 { | |
| 1347 if (XFLOAT(num)->data == 0.0) | |
| 1348 return Qt; | |
| 1349 return Qnil; | |
| 1350 } | |
| 1351 #else | |
| 1352 CHECK_NUMBER (num, 0); | |
| 1353 #endif /* LISP_FLOAT_TYPE */ | |
| 1354 | |
| 1355 if (!XINT (num)) | |
| 1356 return Qt; | |
| 1357 return Qnil; | |
| 1358 } | |
| 1359 | |
| 1360 DEFUN ("int-to-string", Fint_to_string, Sint_to_string, 1, 1, 0, | |
| 1361 "Convert INT to a string by printing it in decimal.\n\ | |
| 1362 Uses a minus sign if negative.") | |
| 1363 (num) | |
| 1364 Lisp_Object num; | |
| 1365 { | |
| 1366 char buffer[20]; | |
| 1367 | |
| 1368 #ifndef LISP_FLOAT_TYPE | |
| 1369 CHECK_NUMBER (num, 0); | |
| 1370 #else | |
| 1371 CHECK_NUMBER_OR_FLOAT (num, 0); | |
| 1372 | |
| 1373 if (XTYPE(num) == Lisp_Float) | |
| 1374 { | |
| 1375 char pigbuf[350]; /* see comments in float_to_string */ | |
| 1376 | |
| 1377 float_to_string (pigbuf, XFLOAT(num)->data); | |
| 1378 return build_string (pigbuf); | |
| 1379 } | |
| 1380 #endif /* LISP_FLOAT_TYPE */ | |
| 1381 | |
| 1382 sprintf (buffer, "%d", XINT (num)); | |
| 1383 return build_string (buffer); | |
| 1384 } | |
| 1385 | |
| 1386 DEFUN ("string-to-int", Fstring_to_int, Sstring_to_int, 1, 1, 0, | |
| 1387 "Convert STRING to an integer by parsing it as a decimal number.") | |
| 1388 (str) | |
| 1389 register Lisp_Object str; | |
| 1390 { | |
| 1391 CHECK_STRING (str, 0); | |
| 1392 | |
| 1393 #ifdef LISP_FLOAT_TYPE | |
| 1394 if (isfloat_string (XSTRING (str)->data)) | |
| 1395 return make_float (atof (XSTRING (str)->data)); | |
| 1396 #endif /* LISP_FLOAT_TYPE */ | |
| 1397 | |
| 1398 return make_number (atoi (XSTRING (str)->data)); | |
| 1399 } | |
| 1400 | |
| 1401 enum arithop | |
| 1402 { Aadd, Asub, Amult, Adiv, Alogand, Alogior, Alogxor, Amax, Amin }; | |
| 1403 | |
| 1404 Lisp_Object | |
| 1405 arith_driver | |
| 1406 (code, nargs, args) | |
| 1407 enum arithop code; | |
| 1408 int nargs; | |
| 1409 register Lisp_Object *args; | |
| 1410 { | |
| 1411 register Lisp_Object val; | |
| 1412 register int argnum; | |
| 1413 register int accum; | |
| 1414 register int next; | |
| 1415 | |
| 1416 #ifdef SWITCH_ENUM_BUG | |
| 1417 switch ((int) code) | |
| 1418 #else | |
| 1419 switch (code) | |
| 1420 #endif | |
| 1421 { | |
| 1422 case Alogior: | |
| 1423 case Alogxor: | |
| 1424 case Aadd: | |
| 1425 case Asub: | |
| 1426 accum = 0; break; | |
| 1427 case Amult: | |
| 1428 accum = 1; break; | |
| 1429 case Alogand: | |
| 1430 accum = -1; break; | |
| 1431 } | |
| 1432 | |
| 1433 for (argnum = 0; argnum < nargs; argnum++) | |
| 1434 { | |
| 1435 val = args[argnum]; /* using args[argnum] as argument to CHECK_NUMBER_... */ | |
| 1436 #ifdef LISP_FLOAT_TYPE | |
| 1437 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val, argnum); | |
| 1438 | |
| 1439 if (XTYPE (val) == Lisp_Float) /* time to do serious math */ | |
| 1440 return (float_arith_driver ((double) accum, argnum, code, | |
| 1441 nargs, args)); | |
| 1442 #else | |
| 1443 CHECK_NUMBER_COERCE_MARKER (val, argnum); | |
| 1444 #endif /* LISP_FLOAT_TYPE */ | |
| 1445 args[argnum] = val; /* runs into a compiler bug. */ | |
| 1446 next = XINT (args[argnum]); | |
| 1447 #ifdef SWITCH_ENUM_BUG | |
| 1448 switch ((int) code) | |
| 1449 #else | |
| 1450 switch (code) | |
| 1451 #endif | |
| 1452 { | |
| 1453 case Aadd: accum += next; break; | |
| 1454 case Asub: | |
| 1455 if (!argnum && nargs != 1) | |
| 1456 next = - next; | |
| 1457 accum -= next; | |
| 1458 break; | |
| 1459 case Amult: accum *= next; break; | |
| 1460 case Adiv: | |
| 1461 if (!argnum) accum = next; | |
| 1462 else accum /= next; | |
| 1463 break; | |
| 1464 case Alogand: accum &= next; break; | |
| 1465 case Alogior: accum |= next; break; | |
| 1466 case Alogxor: accum ^= next; break; | |
| 1467 case Amax: if (!argnum || next > accum) accum = next; break; | |
| 1468 case Amin: if (!argnum || next < accum) accum = next; break; | |
| 1469 } | |
| 1470 } | |
| 1471 | |
| 1472 XSET (val, Lisp_Int, accum); | |
| 1473 return val; | |
| 1474 } | |
| 1475 | |
| 1476 #ifdef LISP_FLOAT_TYPE | |
| 1477 Lisp_Object | |
| 1478 float_arith_driver (accum, argnum, code, nargs, args) | |
| 1479 double accum; | |
| 1480 register int argnum; | |
| 1481 enum arithop code; | |
| 1482 int nargs; | |
| 1483 register Lisp_Object *args; | |
| 1484 { | |
| 1485 register Lisp_Object val; | |
| 1486 double next; | |
| 1487 | |
| 1488 for (; argnum < nargs; argnum++) | |
| 1489 { | |
| 1490 val = args[argnum]; /* using args[argnum] as argument to CHECK_NUMBER_... */ | |
| 1491 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val, argnum); | |
| 1492 | |
| 1493 if (XTYPE (val) == Lisp_Float) | |
| 1494 { | |
| 1495 next = XFLOAT (val)->data; | |
| 1496 } | |
| 1497 else | |
| 1498 { | |
| 1499 args[argnum] = val; /* runs into a compiler bug. */ | |
| 1500 next = XINT (args[argnum]); | |
| 1501 } | |
| 1502 #ifdef SWITCH_ENUM_BUG | |
| 1503 switch ((int) code) | |
| 1504 #else | |
| 1505 switch (code) | |
| 1506 #endif | |
| 1507 { | |
| 1508 case Aadd: | |
| 1509 accum += next; | |
| 1510 break; | |
| 1511 case Asub: | |
| 1512 if (!argnum && nargs != 1) | |
| 1513 next = - next; | |
| 1514 accum -= next; | |
| 1515 break; | |
| 1516 case Amult: | |
| 1517 accum *= next; | |
| 1518 break; | |
| 1519 case Adiv: | |
| 1520 if (!argnum) | |
| 1521 accum = next; | |
| 1522 else | |
| 1523 accum /= next; | |
| 1524 break; | |
| 1525 case Alogand: | |
| 1526 case Alogior: | |
| 1527 case Alogxor: | |
| 1528 return wrong_type_argument (Qinteger_or_marker_p, val); | |
| 1529 case Amax: | |
| 1530 if (!argnum || next > accum) | |
| 1531 accum = next; | |
| 1532 break; | |
| 1533 case Amin: | |
| 1534 if (!argnum || next < accum) | |
| 1535 accum = next; | |
| 1536 break; | |
| 1537 } | |
| 1538 } | |
| 1539 | |
| 1540 return make_float (accum); | |
| 1541 } | |
| 1542 #endif /* LISP_FLOAT_TYPE */ | |
| 1543 | |
| 1544 DEFUN ("+", Fplus, Splus, 0, MANY, 0, | |
| 1545 "Return sum of any number of arguments, which are numbers or markers.") | |
| 1546 (nargs, args) | |
| 1547 int nargs; | |
| 1548 Lisp_Object *args; | |
| 1549 { | |
| 1550 return arith_driver (Aadd, nargs, args); | |
| 1551 } | |
| 1552 | |
| 1553 DEFUN ("-", Fminus, Sminus, 0, MANY, 0, | |
| 1554 "Negate number or subtract numbers or markers.\n\ | |
| 1555 With one arg, negates it. With more than one arg,\n\ | |
| 1556 subtracts all but the first from the first.") | |
| 1557 (nargs, args) | |
| 1558 int nargs; | |
| 1559 Lisp_Object *args; | |
| 1560 { | |
| 1561 return arith_driver (Asub, nargs, args); | |
| 1562 } | |
| 1563 | |
| 1564 DEFUN ("*", Ftimes, Stimes, 0, MANY, 0, | |
| 1565 "Returns product of any number of arguments, which are numbers or markers.") | |
| 1566 (nargs, args) | |
| 1567 int nargs; | |
| 1568 Lisp_Object *args; | |
| 1569 { | |
| 1570 return arith_driver (Amult, nargs, args); | |
| 1571 } | |
| 1572 | |
| 1573 DEFUN ("/", Fquo, Squo, 2, MANY, 0, | |
| 1574 "Returns first argument divided by all the remaining arguments.\n\ | |
| 1575 The arguments must be numbers or markers.") | |
| 1576 (nargs, args) | |
| 1577 int nargs; | |
| 1578 Lisp_Object *args; | |
| 1579 { | |
| 1580 return arith_driver (Adiv, nargs, args); | |
| 1581 } | |
| 1582 | |
| 1583 DEFUN ("%", Frem, Srem, 2, 2, 0, | |
| 1584 "Returns remainder of first arg divided by second.\n\ | |
| 1585 Both must be numbers or markers.") | |
| 1586 (num1, num2) | |
| 1587 register Lisp_Object num1, num2; | |
| 1588 { | |
| 1589 Lisp_Object val; | |
| 1590 | |
| 1591 #ifdef LISP_FLOAT_TYPE | |
| 1592 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0); | |
| 1593 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0); | |
| 1594 | |
| 1595 if (XTYPE (num1) == Lisp_Float || XTYPE (num2) == Lisp_Float) | |
| 1596 { | |
| 1597 double f1, f2; | |
| 1598 | |
| 1599 f1 = XTYPE (num1) == Lisp_Float ? XFLOAT (num1)->data : XINT (num1); | |
| 1600 f2 = XTYPE (num2) == Lisp_Float ? XFLOAT (num2)->data : XINT (num2); | |
| 1601 return (make_float (drem (f1,f2))); | |
| 1602 } | |
| 1603 #else /* not LISP_FLOAT_TYPE */ | |
| 1604 CHECK_NUMBER_COERCE_MARKER (num1, 0); | |
| 1605 CHECK_NUMBER_COERCE_MARKER (num2, 1); | |
| 1606 #endif /* not LISP_FLOAT_TYPE */ | |
| 1607 | |
| 1608 XSET (val, Lisp_Int, XINT (num1) % XINT (num2)); | |
| 1609 return val; | |
| 1610 } | |
| 1611 | |
| 1612 DEFUN ("max", Fmax, Smax, 1, MANY, 0, | |
| 1613 "Return largest of all the arguments (which must be numbers or markers).\n\ | |
| 1614 The value is always a number; markers are converted to numbers.") | |
| 1615 (nargs, args) | |
| 1616 int nargs; | |
| 1617 Lisp_Object *args; | |
| 1618 { | |
| 1619 return arith_driver (Amax, nargs, args); | |
| 1620 } | |
| 1621 | |
| 1622 DEFUN ("min", Fmin, Smin, 1, MANY, 0, | |
| 1623 "Return smallest of all the arguments (which must be numbers or markers).\n\ | |
| 1624 The value is always a number; markers are converted to numbers.") | |
| 1625 (nargs, args) | |
| 1626 int nargs; | |
| 1627 Lisp_Object *args; | |
| 1628 { | |
| 1629 return arith_driver (Amin, nargs, args); | |
| 1630 } | |
| 1631 | |
| 1632 DEFUN ("logand", Flogand, Slogand, 0, MANY, 0, | |
| 1633 "Return bitwise-and of all the arguments.\n\ | |
| 1634 Arguments may be integers, or markers converted to integers.") | |
| 1635 (nargs, args) | |
| 1636 int nargs; | |
| 1637 Lisp_Object *args; | |
| 1638 { | |
| 1639 return arith_driver (Alogand, nargs, args); | |
| 1640 } | |
| 1641 | |
| 1642 DEFUN ("logior", Flogior, Slogior, 0, MANY, 0, | |
| 1643 "Return bitwise-or of all the arguments.\n\ | |
| 1644 Arguments may be integers, or markers converted to integers.") | |
| 1645 (nargs, args) | |
| 1646 int nargs; | |
| 1647 Lisp_Object *args; | |
| 1648 { | |
| 1649 return arith_driver (Alogior, nargs, args); | |
| 1650 } | |
| 1651 | |
| 1652 DEFUN ("logxor", Flogxor, Slogxor, 0, MANY, 0, | |
| 1653 "Return bitwise-exclusive-or of all the arguments.\n\ | |
| 1654 Arguments may be integers, or markers converted to integers.") | |
| 1655 (nargs, args) | |
| 1656 int nargs; | |
| 1657 Lisp_Object *args; | |
| 1658 { | |
| 1659 return arith_driver (Alogxor, nargs, args); | |
| 1660 } | |
| 1661 | |
| 1662 DEFUN ("ash", Fash, Sash, 2, 2, 0, | |
| 1663 "Return VALUE with its bits shifted left by COUNT.\n\ | |
| 1664 If COUNT is negative, shifting is actually to the right.\n\ | |
| 1665 In this case, the sign bit is duplicated.") | |
| 1666 (num1, num2) | |
| 1667 register Lisp_Object num1, num2; | |
| 1668 { | |
| 1669 register Lisp_Object val; | |
| 1670 | |
| 1671 CHECK_NUMBER (num1, 0); | |
| 1672 CHECK_NUMBER (num2, 1); | |
| 1673 | |
| 1674 if (XINT (num2) > 0) | |
| 1675 XSET (val, Lisp_Int, XINT (num1) << XFASTINT (num2)); | |
| 1676 else | |
| 1677 XSET (val, Lisp_Int, XINT (num1) >> -XINT (num2)); | |
| 1678 return val; | |
| 1679 } | |
| 1680 | |
| 1681 DEFUN ("lsh", Flsh, Slsh, 2, 2, 0, | |
| 1682 "Return VALUE with its bits shifted left by COUNT.\n\ | |
| 1683 If COUNT is negative, shifting is actually to the right.\n\ | |
| 1684 In this case, zeros are shifted in on the left.") | |
| 1685 (num1, num2) | |
| 1686 register Lisp_Object num1, num2; | |
| 1687 { | |
| 1688 register Lisp_Object val; | |
| 1689 | |
| 1690 CHECK_NUMBER (num1, 0); | |
| 1691 CHECK_NUMBER (num2, 1); | |
| 1692 | |
| 1693 if (XINT (num2) > 0) | |
| 1694 XSET (val, Lisp_Int, (unsigned) XFASTINT (num1) << XFASTINT (num2)); | |
| 1695 else | |
| 1696 XSET (val, Lisp_Int, (unsigned) XFASTINT (num1) >> -XINT (num2)); | |
| 1697 return val; | |
| 1698 } | |
| 1699 | |
| 1700 DEFUN ("1+", Fadd1, Sadd1, 1, 1, 0, | |
| 1701 "Return NUMBER plus one. NUMBER may be a number or a marker.\n\ | |
| 1702 Markers are converted to integers.") | |
| 1703 (num) | |
| 1704 register Lisp_Object num; | |
| 1705 { | |
| 1706 #ifdef LISP_FLOAT_TYPE | |
| 1707 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num, 0); | |
| 1708 | |
| 1709 if (XTYPE (num) == Lisp_Float) | |
| 1710 return (make_float (1.0 + XFLOAT (num)->data)); | |
| 1711 #else | |
| 1712 CHECK_NUMBER_COERCE_MARKER (num, 0); | |
| 1713 #endif /* LISP_FLOAT_TYPE */ | |
| 1714 | |
| 1715 XSETINT (num, XFASTINT (num) + 1); | |
| 1716 return num; | |
| 1717 } | |
| 1718 | |
| 1719 DEFUN ("1-", Fsub1, Ssub1, 1, 1, 0, | |
| 1720 "Return NUMBER minus one. NUMBER may be a number or a marker.\n\ | |
| 1721 Markers are converted to integers.") | |
| 1722 (num) | |
| 1723 register Lisp_Object num; | |
| 1724 { | |
| 1725 #ifdef LISP_FLOAT_TYPE | |
| 1726 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num, 0); | |
| 1727 | |
| 1728 if (XTYPE (num) == Lisp_Float) | |
| 1729 return (make_float (-1.0 + XFLOAT (num)->data)); | |
| 1730 #else | |
| 1731 CHECK_NUMBER_COERCE_MARKER (num, 0); | |
| 1732 #endif /* LISP_FLOAT_TYPE */ | |
| 1733 | |
| 1734 XSETINT (num, XFASTINT (num) - 1); | |
| 1735 return num; | |
| 1736 } | |
| 1737 | |
| 1738 DEFUN ("lognot", Flognot, Slognot, 1, 1, 0, | |
| 1739 "Return the bitwise complement of ARG. ARG must be an integer.") | |
| 1740 (num) | |
| 1741 register Lisp_Object num; | |
| 1742 { | |
| 1743 CHECK_NUMBER (num, 0); | |
| 1744 XSETINT (num, ~XFASTINT (num)); | |
| 1745 return num; | |
| 1746 } | |
| 1747 | |
| 1748 void | |
| 1749 syms_of_data () | |
| 1750 { | |
| 1751 Qquote = intern ("quote"); | |
| 1752 Qlambda = intern ("lambda"); | |
| 1753 Qsubr = intern ("subr"); | |
| 1754 Qerror_conditions = intern ("error-conditions"); | |
| 1755 Qerror_message = intern ("error-message"); | |
| 1756 Qtop_level = intern ("top-level"); | |
| 1757 | |
| 1758 Qerror = intern ("error"); | |
| 1759 Qquit = intern ("quit"); | |
| 1760 Qwrong_type_argument = intern ("wrong-type-argument"); | |
| 1761 Qargs_out_of_range = intern ("args-out-of-range"); | |
| 1762 Qvoid_function = intern ("void-function"); | |
| 648 | 1763 Qcyclic_function_indirection = intern ("cyclic-function-indirection"); |
| 298 | 1764 Qvoid_variable = intern ("void-variable"); |
| 1765 Qsetting_constant = intern ("setting-constant"); | |
| 1766 Qinvalid_read_syntax = intern ("invalid-read-syntax"); | |
| 1767 | |
| 1768 Qinvalid_function = intern ("invalid-function"); | |
| 1769 Qwrong_number_of_arguments = intern ("wrong-number-of-arguments"); | |
| 1770 Qno_catch = intern ("no-catch"); | |
| 1771 Qend_of_file = intern ("end-of-file"); | |
| 1772 Qarith_error = intern ("arith-error"); | |
| 1773 Qbeginning_of_buffer = intern ("beginning-of-buffer"); | |
| 1774 Qend_of_buffer = intern ("end-of-buffer"); | |
| 1775 Qbuffer_read_only = intern ("buffer-read-only"); | |
| 1776 | |
| 1777 Qlistp = intern ("listp"); | |
| 1778 Qconsp = intern ("consp"); | |
| 1779 Qsymbolp = intern ("symbolp"); | |
| 1780 Qintegerp = intern ("integerp"); | |
| 1781 Qnatnump = intern ("natnump"); | |
| 1782 Qstringp = intern ("stringp"); | |
| 1783 Qarrayp = intern ("arrayp"); | |
| 1784 Qsequencep = intern ("sequencep"); | |
| 1785 Qbufferp = intern ("bufferp"); | |
| 1786 Qvectorp = intern ("vectorp"); | |
| 1787 Qchar_or_string_p = intern ("char-or-string-p"); | |
| 1788 Qmarkerp = intern ("markerp"); | |
| 1789 Qinteger_or_marker_p = intern ("integer-or-marker-p"); | |
| 1790 Qboundp = intern ("boundp"); | |
| 1791 Qfboundp = intern ("fboundp"); | |
| 1792 | |
| 1793 #ifdef LISP_FLOAT_TYPE | |
| 1794 Qfloatp = intern ("floatp"); | |
| 1795 Qnumberp = intern ("numberp"); | |
| 1796 Qnumber_or_marker_p = intern ("number-or-marker-p"); | |
| 1797 #endif /* LISP_FLOAT_TYPE */ | |
| 1798 | |
| 1799 Qcdr = intern ("cdr"); | |
| 1800 | |
| 1801 /* ERROR is used as a signaler for random errors for which nothing else is right */ | |
| 1802 | |
| 1803 Fput (Qerror, Qerror_conditions, | |
| 1804 Fcons (Qerror, Qnil)); | |
| 1805 Fput (Qerror, Qerror_message, | |
| 1806 build_string ("error")); | |
| 1807 | |
| 1808 Fput (Qquit, Qerror_conditions, | |
| 1809 Fcons (Qquit, Qnil)); | |
| 1810 Fput (Qquit, Qerror_message, | |
| 1811 build_string ("Quit")); | |
| 1812 | |
| 1813 Fput (Qwrong_type_argument, Qerror_conditions, | |
| 1814 Fcons (Qwrong_type_argument, Fcons (Qerror, Qnil))); | |
| 1815 Fput (Qwrong_type_argument, Qerror_message, | |
| 1816 build_string ("Wrong type argument")); | |
| 1817 | |
| 1818 Fput (Qargs_out_of_range, Qerror_conditions, | |
| 1819 Fcons (Qargs_out_of_range, Fcons (Qerror, Qnil))); | |
| 1820 Fput (Qargs_out_of_range, Qerror_message, | |
| 1821 build_string ("Args out of range")); | |
| 1822 | |
| 1823 Fput (Qvoid_function, Qerror_conditions, | |
| 1824 Fcons (Qvoid_function, Fcons (Qerror, Qnil))); | |
| 1825 Fput (Qvoid_function, Qerror_message, | |
| 1826 build_string ("Symbol's function definition is void")); | |
| 1827 | |
| 648 | 1828 Fput (Qcyclic_function_indirection, Qerror_conditions, |
| 1829 Fcons (Qcyclic_function_indirection, Fcons (Qerror, Qnil))); | |
| 1830 Fput (Qcyclic_function_indirection, Qerror_message, | |
| 1831 build_string ("Symbol's chain of function indirections contains a loop")); | |
| 1832 | |
| 298 | 1833 Fput (Qvoid_variable, Qerror_conditions, |
| 1834 Fcons (Qvoid_variable, Fcons (Qerror, Qnil))); | |
| 1835 Fput (Qvoid_variable, Qerror_message, | |
| 1836 build_string ("Symbol's value as variable is void")); | |
| 1837 | |
| 1838 Fput (Qsetting_constant, Qerror_conditions, | |
| 1839 Fcons (Qsetting_constant, Fcons (Qerror, Qnil))); | |
| 1840 Fput (Qsetting_constant, Qerror_message, | |
| 1841 build_string ("Attempt to set a constant symbol")); | |
| 1842 | |
| 1843 Fput (Qinvalid_read_syntax, Qerror_conditions, | |
| 1844 Fcons (Qinvalid_read_syntax, Fcons (Qerror, Qnil))); | |
| 1845 Fput (Qinvalid_read_syntax, Qerror_message, | |
| 1846 build_string ("Invalid read syntax")); | |
| 1847 | |
| 1848 Fput (Qinvalid_function, Qerror_conditions, | |
| 1849 Fcons (Qinvalid_function, Fcons (Qerror, Qnil))); | |
| 1850 Fput (Qinvalid_function, Qerror_message, | |
| 1851 build_string ("Invalid function")); | |
| 1852 | |
| 1853 Fput (Qwrong_number_of_arguments, Qerror_conditions, | |
| 1854 Fcons (Qwrong_number_of_arguments, Fcons (Qerror, Qnil))); | |
| 1855 Fput (Qwrong_number_of_arguments, Qerror_message, | |
| 1856 build_string ("Wrong number of arguments")); | |
| 1857 | |
| 1858 Fput (Qno_catch, Qerror_conditions, | |
| 1859 Fcons (Qno_catch, Fcons (Qerror, Qnil))); | |
| 1860 Fput (Qno_catch, Qerror_message, | |
| 1861 build_string ("No catch for tag")); | |
| 1862 | |
| 1863 Fput (Qend_of_file, Qerror_conditions, | |
| 1864 Fcons (Qend_of_file, Fcons (Qerror, Qnil))); | |
| 1865 Fput (Qend_of_file, Qerror_message, | |
| 1866 build_string ("End of file during parsing")); | |
| 1867 | |
| 1868 Fput (Qarith_error, Qerror_conditions, | |
| 1869 Fcons (Qarith_error, Fcons (Qerror, Qnil))); | |
| 1870 Fput (Qarith_error, Qerror_message, | |
| 1871 build_string ("Arithmetic error")); | |
| 1872 | |
| 1873 Fput (Qbeginning_of_buffer, Qerror_conditions, | |
| 1874 Fcons (Qbeginning_of_buffer, Fcons (Qerror, Qnil))); | |
| 1875 Fput (Qbeginning_of_buffer, Qerror_message, | |
| 1876 build_string ("Beginning of buffer")); | |
| 1877 | |
| 1878 Fput (Qend_of_buffer, Qerror_conditions, | |
| 1879 Fcons (Qend_of_buffer, Fcons (Qerror, Qnil))); | |
| 1880 Fput (Qend_of_buffer, Qerror_message, | |
| 1881 build_string ("End of buffer")); | |
| 1882 | |
| 1883 Fput (Qbuffer_read_only, Qerror_conditions, | |
| 1884 Fcons (Qbuffer_read_only, Fcons (Qerror, Qnil))); | |
| 1885 Fput (Qbuffer_read_only, Qerror_message, | |
| 1886 build_string ("Buffer is read-only")); | |
| 1887 | |
| 1888 staticpro (&Qnil); | |
| 1889 staticpro (&Qt); | |
| 1890 staticpro (&Qquote); | |
| 1891 staticpro (&Qlambda); | |
| 1892 staticpro (&Qsubr); | |
| 1893 staticpro (&Qunbound); | |
| 1894 staticpro (&Qerror_conditions); | |
| 1895 staticpro (&Qerror_message); | |
| 1896 staticpro (&Qtop_level); | |
| 1897 | |
| 1898 staticpro (&Qerror); | |
| 1899 staticpro (&Qquit); | |
| 1900 staticpro (&Qwrong_type_argument); | |
| 1901 staticpro (&Qargs_out_of_range); | |
| 1902 staticpro (&Qvoid_function); | |
| 648 | 1903 staticpro (&Qcyclic_function_indirection); |
| 298 | 1904 staticpro (&Qvoid_variable); |
| 1905 staticpro (&Qsetting_constant); | |
| 1906 staticpro (&Qinvalid_read_syntax); | |
| 1907 staticpro (&Qwrong_number_of_arguments); | |
| 1908 staticpro (&Qinvalid_function); | |
| 1909 staticpro (&Qno_catch); | |
| 1910 staticpro (&Qend_of_file); | |
| 1911 staticpro (&Qarith_error); | |
| 1912 staticpro (&Qbeginning_of_buffer); | |
| 1913 staticpro (&Qend_of_buffer); | |
| 1914 staticpro (&Qbuffer_read_only); | |
| 1915 | |
| 1916 staticpro (&Qlistp); | |
| 1917 staticpro (&Qconsp); | |
| 1918 staticpro (&Qsymbolp); | |
| 1919 staticpro (&Qintegerp); | |
| 1920 staticpro (&Qnatnump); | |
| 1921 staticpro (&Qstringp); | |
| 1922 staticpro (&Qarrayp); | |
| 1923 staticpro (&Qsequencep); | |
| 1924 staticpro (&Qbufferp); | |
| 1925 staticpro (&Qvectorp); | |
| 1926 staticpro (&Qchar_or_string_p); | |
| 1927 staticpro (&Qmarkerp); | |
| 1928 staticpro (&Qinteger_or_marker_p); | |
| 1929 #ifdef LISP_FLOAT_TYPE | |
| 1930 staticpro (&Qfloatp); | |
|
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
1931 staticpro (&Qnumberp); |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
1932 staticpro (&Qnumber_or_marker_p); |
| 298 | 1933 #endif /* LISP_FLOAT_TYPE */ |
| 1934 | |
| 1935 staticpro (&Qboundp); | |
| 1936 staticpro (&Qfboundp); | |
| 1937 staticpro (&Qcdr); | |
| 1938 | |
| 1939 defsubr (&Seq); | |
| 1940 defsubr (&Snull); | |
| 1941 defsubr (&Slistp); | |
| 1942 defsubr (&Snlistp); | |
| 1943 defsubr (&Sconsp); | |
| 1944 defsubr (&Satom); | |
| 1945 defsubr (&Sintegerp); | |
|
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
1946 defsubr (&Sinteger_or_marker_p); |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
1947 defsubr (&Snumberp); |
|
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
1948 defsubr (&Snumber_or_marker_p); |
| 298 | 1949 #ifdef LISP_FLOAT_TYPE |
| 1950 defsubr (&Sfloatp); | |
| 1951 #endif /* LISP_FLOAT_TYPE */ | |
| 1952 defsubr (&Snatnump); | |
| 1953 defsubr (&Ssymbolp); | |
| 1954 defsubr (&Sstringp); | |
| 1955 defsubr (&Svectorp); | |
| 1956 defsubr (&Sarrayp); | |
| 1957 defsubr (&Ssequencep); | |
| 1958 defsubr (&Sbufferp); | |
| 1959 defsubr (&Smarkerp); | |
| 1960 defsubr (&Ssubrp); | |
| 1961 defsubr (&Scompiled_function_p); | |
| 1962 defsubr (&Schar_or_string_p); | |
| 1963 defsubr (&Scar); | |
| 1964 defsubr (&Scdr); | |
| 1965 defsubr (&Scar_safe); | |
| 1966 defsubr (&Scdr_safe); | |
| 1967 defsubr (&Ssetcar); | |
| 1968 defsubr (&Ssetcdr); | |
| 1969 defsubr (&Ssymbol_function); | |
| 648 | 1970 defsubr (&Sindirect_function); |
| 298 | 1971 defsubr (&Ssymbol_plist); |
| 1972 defsubr (&Ssymbol_name); | |
| 1973 defsubr (&Smakunbound); | |
| 1974 defsubr (&Sfmakunbound); | |
| 1975 defsubr (&Sboundp); | |
| 1976 defsubr (&Sfboundp); | |
| 1977 defsubr (&Sfset); | |
| 1978 defsubr (&Ssetplist); | |
| 1979 defsubr (&Ssymbol_value); | |
| 1980 defsubr (&Sset); | |
| 1981 defsubr (&Sdefault_boundp); | |
| 1982 defsubr (&Sdefault_value); | |
| 1983 defsubr (&Sset_default); | |
| 1984 defsubr (&Ssetq_default); | |
| 1985 defsubr (&Smake_variable_buffer_local); | |
| 1986 defsubr (&Smake_local_variable); | |
| 1987 defsubr (&Skill_local_variable); | |
| 1988 defsubr (&Saref); | |
| 1989 defsubr (&Saset); | |
| 1990 defsubr (&Sint_to_string); | |
| 1991 defsubr (&Sstring_to_int); | |
| 1992 defsubr (&Seqlsign); | |
| 1993 defsubr (&Slss); | |
| 1994 defsubr (&Sgtr); | |
| 1995 defsubr (&Sleq); | |
| 1996 defsubr (&Sgeq); | |
| 1997 defsubr (&Sneq); | |
| 1998 defsubr (&Szerop); | |
| 1999 defsubr (&Splus); | |
| 2000 defsubr (&Sminus); | |
| 2001 defsubr (&Stimes); | |
| 2002 defsubr (&Squo); | |
| 2003 defsubr (&Srem); | |
| 2004 defsubr (&Smax); | |
| 2005 defsubr (&Smin); | |
| 2006 defsubr (&Slogand); | |
| 2007 defsubr (&Slogior); | |
| 2008 defsubr (&Slogxor); | |
| 2009 defsubr (&Slsh); | |
| 2010 defsubr (&Sash); | |
| 2011 defsubr (&Sadd1); | |
| 2012 defsubr (&Ssub1); | |
| 2013 defsubr (&Slognot); | |
| 2014 } | |
| 2015 | |
| 490 | 2016 SIGTYPE |
| 298 | 2017 arith_error (signo) |
| 2018 int signo; | |
| 2019 { | |
| 2020 #ifdef USG | |
| 2021 /* USG systems forget handlers when they are used; | |
| 2022 must reestablish each time */ | |
| 2023 signal (signo, arith_error); | |
| 2024 #endif /* USG */ | |
| 2025 #ifdef VMS | |
| 2026 /* VMS systems are like USG. */ | |
| 2027 signal (signo, arith_error); | |
| 2028 #endif /* VMS */ | |
| 2029 #ifdef BSD4_1 | |
| 2030 sigrelse (SIGFPE); | |
| 2031 #else /* not BSD4_1 */ | |
| 638 | 2032 sigsetmask (SIGEMPTYMASK); |
| 298 | 2033 #endif /* not BSD4_1 */ |
| 2034 | |
| 2035 Fsignal (Qarith_error, Qnil); | |
| 2036 } | |
| 2037 | |
| 2038 init_data () | |
| 2039 { | |
| 2040 /* Don't do this if just dumping out. | |
| 2041 We don't want to call `signal' in this case | |
| 2042 so that we don't have trouble with dumping | |
| 2043 signal-delivering routines in an inconsistent state. */ | |
| 2044 #ifndef CANNOT_DUMP | |
| 2045 if (!initialized) | |
| 2046 return; | |
| 2047 #endif /* CANNOT_DUMP */ | |
| 2048 signal (SIGFPE, arith_error); | |
| 591 | 2049 |
| 298 | 2050 #ifdef uts |
| 2051 signal (SIGEMT, arith_error); | |
| 2052 #endif /* uts */ | |
| 2053 } |
