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