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