0
|
1 /* Primitive operations on Lisp data types for XEmacs Lisp interpreter.
|
|
2 Copyright (C) 1985, 1986, 1988, 1992, 1993, 1994, 1995
|
|
3 Free Software Foundation, Inc.
|
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Mule 2.0, FSF 19.30. Some of FSF's data.c is in
|
|
23 XEmacs' symbols.c. */
|
|
24
|
|
25 /* This file has been Mule-ized. */
|
|
26
|
|
27 #include <config.h>
|
|
28 #include "lisp.h"
|
|
29
|
|
30 #include "buffer.h"
|
|
31 #include "bytecode.h"
|
|
32
|
|
33 #include "syssignal.h"
|
|
34 #ifdef LISP_FLOAT_TYPE
|
|
35 /* Need to define a differentiating symbol -- see sysfloat.h */
|
|
36 # define THIS_FILENAME data_c
|
|
37 # include "sysfloat.h"
|
|
38 #endif /* LISP_FLOAT_TYPE */
|
|
39
|
|
40 Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound;
|
|
41 Lisp_Object Qerror_conditions, Qerror_message, Qtop_level;
|
|
42 Lisp_Object Qsignal, Qerror, Qquit, Qwrong_type_argument, Qargs_out_of_range;
|
|
43 Lisp_Object Qvoid_variable, Qcyclic_variable_indirection;
|
|
44 Lisp_Object Qvoid_function, Qcyclic_function_indirection;
|
|
45 Lisp_Object Qsetting_constant, Qinvalid_read_syntax;
|
|
46 Lisp_Object Qmalformed_list, Qmalformed_property_list;
|
|
47 Lisp_Object Qcircular_list, Qcircular_property_list;
|
|
48 Lisp_Object Qinvalid_function, Qwrong_number_of_arguments, Qno_catch;
|
|
49 Lisp_Object Qio_error, Qend_of_file;
|
|
50 Lisp_Object Qarith_error, Qrange_error, Qdomain_error;
|
|
51 Lisp_Object Qsingularity_error, Qoverflow_error, Qunderflow_error;
|
|
52 Lisp_Object Qbeginning_of_buffer, Qend_of_buffer, Qbuffer_read_only;
|
|
53 Lisp_Object Qintegerp, Qnatnump, Qsymbolp, Qkeywordp, Qlistp, Qconsp, Qsubrp;
|
|
54 Lisp_Object Qcharacterp, Qstringp, Qarrayp, Qsequencep, Qbufferp;
|
|
55 Lisp_Object Qcompiled_functionp;
|
|
56 Lisp_Object Qchar_or_string_p, Qmarkerp, Qinteger_or_marker_p, Qvectorp;
|
|
57 Lisp_Object Qinteger_or_char_p, Qinteger_char_or_marker_p;
|
|
58 Lisp_Object Qbit_vectorp, Qbitp;
|
|
59
|
|
60 /* Qstring, Qinteger, Qsymbol, Qvector defined in general.c */
|
|
61 Lisp_Object Qcons, Qkeyword;
|
|
62
|
|
63 Lisp_Object Qcdr;
|
|
64
|
|
65 Lisp_Object Qignore;
|
|
66
|
|
67 #ifdef LISP_FLOAT_TYPE
|
|
68 Lisp_Object Qfloatp;
|
|
69 #endif
|
|
70 Lisp_Object Qnumberp, Qnumber_or_marker_p, Qnumber_char_or_marker_p;
|
|
71
|
|
72 Lisp_Object Qweak_listp;
|
70
|
73
|
|
74 #ifdef DEBUG_XEMACS
|
|
75
|
|
76 int debug_issue_ebola_notices;
|
|
77
|
|
78 int debug_ebola_backtrace_length;
|
|
79
|
|
80 int
|
|
81 eq_with_ebola_notice (Lisp_Object obj1, Lisp_Object obj2)
|
|
82 {
|
|
83 if (((CHARP (obj1) && INTP (obj2)) || (CHARP (obj2) && INTP (obj1)))
|
|
84 && (debug_issue_ebola_notices >= 2
|
|
85 || XREALINT (obj1) == XREALINT (obj2)))
|
|
86 {
|
108
|
87 /* Continuing the joke by printing `Ebola warning!!!' confuses */
|
|
88 /* too many people. The message must be printed because Emacs used */
|
|
89 /* to work differently for two decades. */
|
|
90 stderr_out("Comparison between integer and character is constant nil (");
|
70
|
91 Fprinc (obj1, Qexternal_debugging_output);
|
|
92 stderr_out (" and ");
|
|
93 Fprinc (obj2, Qexternal_debugging_output);
|
|
94 stderr_out (")\n");
|
|
95 debug_short_backtrace (debug_ebola_backtrace_length);
|
|
96 }
|
|
97
|
|
98 return EQ (obj1, obj2);
|
|
99 }
|
|
100
|
|
101 #endif /* DEBUG_XEMACS */
|
|
102
|
|
103
|
0
|
104
|
|
105 Lisp_Object
|
|
106 wrong_type_argument (Lisp_Object predicate, Lisp_Object value)
|
|
107 {
|
|
108 /* This function can GC */
|
|
109 REGISTER Lisp_Object tem;
|
|
110 do
|
|
111 {
|
|
112 #ifdef MOCKLISP_SUPPORT
|
|
113 if (!EQ (Vmocklisp_arguments, Qt))
|
|
114 {
|
|
115 if (STRINGP (value) &&
|
|
116 (EQ (predicate, Qintegerp) ||
|
|
117 EQ (predicate, Qinteger_or_marker_p) ||
|
|
118 EQ (predicate, Qinteger_char_or_marker_p)))
|
|
119 return Fstring_to_number (value);
|
|
120 if (INTP (value) && EQ (predicate, Qstringp))
|
|
121 return Fnumber_to_string (value);
|
|
122 if (CHARP (value) && EQ (predicate, Qstringp))
|
|
123 return Fchar_to_string (value);
|
|
124 }
|
16
|
125 #endif /* MOCKLISP_SUPPORT */
|
0
|
126 value = Fsignal (Qwrong_type_argument, list2 (predicate, value));
|
|
127 tem = call1 (predicate, value);
|
|
128 }
|
|
129 while (NILP (tem));
|
|
130 return value;
|
|
131 }
|
|
132
|
|
133 DOESNT_RETURN
|
|
134 dead_wrong_type_argument (Lisp_Object predicate, Lisp_Object value)
|
|
135 {
|
|
136 signal_error (Qwrong_type_argument, list2 (predicate, value));
|
|
137 }
|
|
138
|
20
|
139 DEFUN ("wrong-type-argument", Fwrong_type_argument, 2, 2, 0, /*
|
0
|
140 Signal an error until the correct type value is given by the user.
|
|
141 This function loops, signalling a continuable `wrong-type-argument' error
|
|
142 with PREDICATE and VALUE as the data associated with the error and then
|
|
143 calling PREDICATE on the returned value, until the value gotten satisfies
|
|
144 PREDICATE. At that point, the gotten value is returned.
|
20
|
145 */
|
|
146 (predicate, value))
|
0
|
147 {
|
|
148 return wrong_type_argument (predicate, value);
|
|
149 }
|
|
150
|
|
151 DOESNT_RETURN
|
|
152 pure_write_error (void)
|
|
153 {
|
|
154 error ("Attempt to modify read-only object");
|
|
155 }
|
|
156
|
|
157 DOESNT_RETURN
|
|
158 args_out_of_range (Lisp_Object a1, Lisp_Object a2)
|
|
159 {
|
|
160 signal_error (Qargs_out_of_range, list2 (a1, a2));
|
|
161 }
|
|
162
|
|
163 DOESNT_RETURN
|
|
164 args_out_of_range_3 (Lisp_Object a1, Lisp_Object a2, Lisp_Object a3)
|
|
165 {
|
|
166 signal_error (Qargs_out_of_range, list3 (a1, a2, a3));
|
|
167 }
|
|
168
|
|
169 void
|
|
170 check_int_range (int val, int min, int max)
|
|
171 {
|
|
172 if (val < min || val > max)
|
|
173 args_out_of_range_3 (make_int (val), make_int (min),
|
|
174 make_int (max));
|
|
175 }
|
|
176
|
|
177 #ifndef make_int
|
|
178 Lisp_Object
|
|
179 make_int (EMACS_INT num)
|
|
180 {
|
|
181 Lisp_Object val;
|
|
182 /* Don't use XSETINT here -- it's defined in terms of make_int (). */
|
|
183 XSETOBJ (val, Lisp_Int, num);
|
|
184 return val;
|
|
185 }
|
|
186 #endif /* ! defined (make_int) */
|
|
187
|
|
188 /* On some machines, XINT needs a temporary location.
|
|
189 Here it is, in case it is needed. */
|
|
190
|
|
191 EMACS_INT sign_extend_temp;
|
|
192
|
|
193 /* On a few machines, XINT can only be done by calling this. */
|
|
194 /* XEmacs: only used by m/convex.h */
|
|
195 int sign_extend_lisp_int (EMACS_INT num);
|
|
196 int
|
|
197 sign_extend_lisp_int (EMACS_INT num)
|
|
198 {
|
|
199 if (num & (1L << (VALBITS - 1)))
|
|
200 return num | ((-1L) << VALBITS);
|
|
201 else
|
|
202 return num & ((1L << VALBITS) - 1);
|
|
203 }
|
|
204
|
|
205 /* characters do not need to sign extend so there's no need for special
|
|
206 futzing like with ints. */
|
|
207 Lisp_Object
|
|
208 make_char (Emchar num)
|
|
209 {
|
16
|
210 Lisp_Object val;
|
70
|
211 /* Don't use XSETCHAR here -- it's defined in terms of make_char (). */
|
|
212 XSETOBJ (val, Lisp_Char, num);
|
16
|
213 return val;
|
0
|
214 }
|
|
215
|
|
216 /* Data type predicates */
|
|
217
|
20
|
218 DEFUN ("eq", Feq, 2, 2, 0, /*
|
0
|
219 T if the two args are the same Lisp object.
|
20
|
220 */
|
|
221 (obj1, obj2))
|
0
|
222 {
|
70
|
223 return EQ_WITH_EBOLA_NOTICE (obj1, obj2) ? Qt : Qnil;
|
|
224 }
|
|
225
|
|
226 DEFUN ("old-eq", Fold_eq, 2, 2, 0, /*
|
|
227 T if the two args are (in most cases) the same Lisp object.
|
|
228
|
|
229 Special kludge: A character is considered `old-eq' to its equivalent integer
|
|
230 even though they are not the same object and are in fact of different
|
|
231 types. This is ABSOLUTELY AND UTTERLY HORRENDOUS but is necessary to
|
|
232 preserve byte-code compatibility with v19. This kludge is known as the
|
104
|
233 \"char-to-int confoundance disease\" and appears in a number of other
|
70
|
234 functions with `old-foo' equivalents.
|
|
235
|
|
236 Do not use this function!
|
|
237 */
|
|
238 (obj1, obj2))
|
|
239 {
|
|
240 /* The miscreant responsible for this blasphemy is known as
|
|
241 Richard M. Stallman, and he will burn in hell for it. */
|
|
242 return HACKEQ_UNSAFE (obj1, obj2) ? Qt : Qnil;
|
0
|
243 }
|
|
244
|
20
|
245 DEFUN ("null", Fnull, 1, 1, 0, /*
|
0
|
246 T if OBJECT is nil.
|
20
|
247 */
|
|
248 (object))
|
0
|
249 {
|
16
|
250 return NILP (object) ? Qt : Qnil;
|
0
|
251 }
|
|
252
|
20
|
253 DEFUN ("consp", Fconsp, 1, 1, 0, /*
|
0
|
254 T if OBJECT is a cons cell.
|
20
|
255 */
|
|
256 (object))
|
0
|
257 {
|
16
|
258 return CONSP (object) ? Qt : Qnil;
|
0
|
259 }
|
|
260
|
20
|
261 DEFUN ("atom", Fatom, 1, 1, 0, /*
|
0
|
262 T if OBJECT is not a cons cell. This includes nil.
|
20
|
263 */
|
|
264 (object))
|
0
|
265 {
|
16
|
266 return CONSP (object) ? Qnil : Qt;
|
0
|
267 }
|
|
268
|
20
|
269 DEFUN ("listp", Flistp, 1, 1, 0, /*
|
0
|
270 T if OBJECT is a list. This includes nil.
|
20
|
271 */
|
|
272 (object))
|
0
|
273 {
|
16
|
274 return (CONSP (object) || NILP (object)) ? Qt : Qnil;
|
0
|
275 }
|
|
276
|
20
|
277 DEFUN ("nlistp", Fnlistp, 1, 1, 0, /*
|
0
|
278 T if OBJECT is not a list. Lists include nil.
|
20
|
279 */
|
|
280 (object))
|
0
|
281 {
|
16
|
282 return (CONSP (object) || NILP (object)) ? Qnil : Qt;
|
0
|
283 }
|
|
284
|
20
|
285 DEFUN ("symbolp", Fsymbolp, 1, 1, 0, /*
|
0
|
286 T if OBJECT is a symbol.
|
20
|
287 */
|
|
288 (object))
|
0
|
289 {
|
16
|
290 return SYMBOLP (object) ? Qt : Qnil;
|
0
|
291 }
|
|
292
|
20
|
293 DEFUN ("keywordp", Fkeywordp, 1, 1, 0, /*
|
0
|
294 T if OBJECT is a keyword.
|
20
|
295 */
|
|
296 (object))
|
0
|
297 {
|
16
|
298 return KEYWORDP (object) ? Qt : Qnil;
|
0
|
299 }
|
|
300
|
20
|
301 DEFUN ("vectorp", Fvectorp, 1, 1, 0, /*
|
0
|
302 T if OBJECT is a vector.
|
20
|
303 */
|
|
304 (object))
|
0
|
305 {
|
16
|
306 return VECTORP (object) ? Qt : Qnil;
|
0
|
307 }
|
|
308
|
20
|
309 DEFUN ("bit-vector-p", Fbit_vector_p, 1, 1, 0, /*
|
0
|
310 T if OBJECT is a bit vector.
|
20
|
311 */
|
|
312 (object))
|
0
|
313 {
|
16
|
314 return BIT_VECTORP (object) ? Qt : Qnil;
|
0
|
315 }
|
|
316
|
20
|
317 DEFUN ("stringp", Fstringp, 1, 1, 0, /*
|
0
|
318 T if OBJECT is a string.
|
20
|
319 */
|
|
320 (object))
|
0
|
321 {
|
16
|
322 return STRINGP (object) ? Qt : Qnil;
|
0
|
323 }
|
|
324
|
20
|
325 DEFUN ("arrayp", Farrayp, 1, 1, 0, /*
|
0
|
326 T if OBJECT is an array (string, vector, or bit vector).
|
20
|
327 */
|
|
328 (object))
|
0
|
329 {
|
16
|
330 return (VECTORP (object) ||
|
|
331 STRINGP (object) ||
|
|
332 BIT_VECTORP (object))
|
|
333 ? Qt : Qnil;
|
0
|
334 }
|
|
335
|
20
|
336 DEFUN ("sequencep", Fsequencep, 1, 1, 0, /*
|
0
|
337 T if OBJECT is a sequence (list or array).
|
20
|
338 */
|
|
339 (object))
|
0
|
340 {
|
16
|
341 return (CONSP (object) ||
|
|
342 NILP (object) ||
|
|
343 VECTORP (object) ||
|
|
344 STRINGP (object) ||
|
|
345 BIT_VECTORP (object))
|
|
346 ? Qt : Qnil;
|
0
|
347 }
|
|
348
|
20
|
349 DEFUN ("markerp", Fmarkerp, 1, 1, 0, /*
|
0
|
350 T if OBJECT is a marker (editor pointer).
|
20
|
351 */
|
|
352 (object))
|
0
|
353 {
|
16
|
354 return MARKERP (object) ? Qt : Qnil;
|
0
|
355 }
|
|
356
|
20
|
357 DEFUN ("subrp", Fsubrp, 1, 1, 0, /*
|
0
|
358 T if OBJECT is a built-in function.
|
20
|
359 */
|
|
360 (object))
|
0
|
361 {
|
16
|
362 return SUBRP (object) ? Qt : Qnil;
|
0
|
363 }
|
|
364
|
20
|
365 DEFUN ("subr-min-args", Fsubr_min_args, 1, 1, 0, /*
|
0
|
366 Return minimum number of args built-in function SUBR may be called with.
|
20
|
367 */
|
|
368 (subr))
|
0
|
369 {
|
|
370 CHECK_SUBR (subr);
|
|
371 return make_int (XSUBR (subr)->min_args);
|
|
372 }
|
|
373
|
20
|
374 DEFUN ("subr-max-args", Fsubr_max_args, 1, 1, 0, /*
|
0
|
375 Return maximum number of args built-in function SUBR may be called with,
|
16
|
376 or nil if it takes an arbitrary number of arguments or is a special form.
|
20
|
377 */
|
|
378 (subr))
|
0
|
379 {
|
|
380 int nargs;
|
|
381 CHECK_SUBR (subr);
|
|
382 nargs = XSUBR (subr)->max_args;
|
|
383 if (nargs == MANY || nargs == UNEVALLED)
|
|
384 return Qnil;
|
|
385 else
|
|
386 return make_int (nargs);
|
|
387 }
|
|
388
|
20
|
389 DEFUN ("compiled-function-p", Fcompiled_function_p, 1, 1, 0, /*
|
0
|
390 t if OBJECT is a byte-compiled function object.
|
20
|
391 */
|
|
392 (object))
|
0
|
393 {
|
16
|
394 return COMPILED_FUNCTIONP (object) ? Qt : Qnil;
|
0
|
395 }
|
|
396
|
|
397
|
20
|
398 DEFUN ("characterp", Fcharacterp, 1, 1, 0, /*
|
0
|
399 t if OBJECT is a character.
|
70
|
400 Unlike in FSF Emacs, a character is its own primitive type.
|
|
401 Any character can be converted into an equivalent integer using
|
104
|
402 `char-to-int'. To convert the other way, use `int-to-char'; however,
|
70
|
403 only some integers can be converted into characters. Such an integer
|
104
|
404 is called a `char-to-int'; see `char-int-p'.
|
70
|
405
|
|
406 Some functions that work on integers (e.g. the comparison functions
|
|
407 <, <=, =, /=, etc. and the arithmetic functions +, -, *, etc.)
|
|
408 accept characters and implicitly convert them into integers. In
|
|
409 general, functions that work on characters also accept char-ints and
|
|
410 implicitly convert them into characters. WARNING: Neither of these
|
|
411 behaviors is very desirable, and they are maintained for backward
|
|
412 compatibility with old E-Lisp programs that confounded characters and
|
|
413 integers willy-nilly. These behaviors may change in the future; therefore,
|
|
414 do not rely on them. Instead, use the character-specific functions such
|
|
415 as `char='.
|
20
|
416 */
|
|
417 (object))
|
0
|
418 {
|
16
|
419 return CHARP (object) ? Qt : Qnil;
|
0
|
420 }
|
|
421
|
104
|
422 DEFUN ("char-to-int", Fchar_to_int, 1, 1, 0, /*
|
70
|
423 Convert a character into an equivalent integer.
|
|
424 The resulting integer will always be non-negative. The integers in
|
|
425 the range 0 - 255 map to characters as follows:
|
|
426
|
|
427 0 - 31 Control set 0
|
|
428 32 - 127 ASCII
|
|
429 128 - 159 Control set 1
|
|
430 160 - 255 Right half of ISO-8859-1
|
|
431
|
|
432 If support for Mule does not exist, these are the only valid character
|
|
433 values. When Mule support exists, the values assigned to other characters
|
|
434 may vary depending on the particular version of XEmacs, the order in which
|
|
435 character sets were loaded, etc., and you should not depend on them.
|
|
436 */
|
|
437 (ch))
|
|
438 {
|
|
439 CHECK_CHAR (ch);
|
|
440 return make_int (XCHAR (ch));
|
|
441 }
|
|
442
|
104
|
443 DEFUN ("int-to-char", Fint_to_char, 1, 1, 0, /*
|
70
|
444 Convert an integer into the equivalent character.
|
|
445 Not all integers correspond to valid characters; use `char-int-p' to
|
|
446 determine whether this is the case. If the integer cannot be converted,
|
|
447 nil is returned.
|
|
448 */
|
|
449 (integer))
|
|
450 {
|
|
451 CHECK_INT (integer);
|
|
452 if (CHAR_INTP (integer))
|
|
453 return make_char (XINT (integer));
|
|
454 else
|
|
455 return Qnil;
|
|
456 }
|
|
457
|
|
458 DEFUN ("char-int-p", Fchar_int_p, 1, 1, 0, /*
|
|
459 t if OBJECT is an integer that can be converted into a character.
|
104
|
460 See `char-to-int'.
|
70
|
461 */
|
|
462 (object))
|
|
463 {
|
|
464 return CHAR_INTP (object) ? Qt : Qnil;
|
|
465 }
|
|
466
|
|
467 DEFUN ("char-or-char-int-p", Fchar_or_char_int_p, 1, 1, 0, /*
|
|
468 t if OBJECT is a character or an integer that can be converted into one.
|
|
469 */
|
|
470 (object))
|
|
471 {
|
|
472 return CHAR_OR_CHAR_INTP (object) ? Qt : Qnil;
|
|
473 }
|
|
474
|
20
|
475 DEFUN ("char-or-string-p", Fchar_or_string_p, 1, 1, 0, /*
|
70
|
476 t if OBJECT is a character (or a char-int) or a string.
|
|
477 It is semi-hateful that we allow a char-int here, as it goes against
|
|
478 the name of this function, but it makes the most sense considering the
|
|
479 other steps we take to maintain compatibility with the old character/integer
|
|
480 confoundedness in older versions of E-Lisp.
|
20
|
481 */
|
|
482 (object))
|
0
|
483 {
|
16
|
484 return CHAR_OR_CHAR_INTP (object) || STRINGP (object) ? Qt : Qnil;
|
0
|
485 }
|
|
486
|
20
|
487 DEFUN ("integerp", Fintegerp, 1, 1, 0, /*
|
0
|
488 t if OBJECT is an integer.
|
20
|
489 */
|
|
490 (object))
|
0
|
491 {
|
16
|
492 return INTP (object) ? Qt : Qnil;
|
0
|
493 }
|
|
494
|
20
|
495 DEFUN ("integer-or-marker-p", Finteger_or_marker_p, 1, 1, 0, /*
|
0
|
496 t if OBJECT is an integer or a marker (editor pointer).
|
20
|
497 */
|
|
498 (object))
|
0
|
499 {
|
16
|
500 return INTP (object) || MARKERP (object) ? Qt : Qnil;
|
0
|
501 }
|
|
502
|
70
|
503 DEFUN ("integer-or-char-p", Finteger_or_char_p, 1, 1, 0, /*
|
|
504 t if OBJECT is an integer or a character.
|
|
505 */
|
|
506 (object))
|
|
507 {
|
|
508 return INTP (object) || CHARP (object) ? Qt : Qnil;
|
|
509 }
|
|
510
|
|
511 DEFUN ("integer-char-or-marker-p", Finteger_char_or_marker_p, 1, 1, 0, /*
|
|
512 t if OBJECT is an integer, character or a marker (editor pointer).
|
|
513 */
|
|
514 (object))
|
|
515 {
|
|
516 return INTP (object) || CHARP (object) || MARKERP (object) ? Qt : Qnil;
|
|
517 }
|
|
518
|
20
|
519 DEFUN ("natnump", Fnatnump, 1, 1, 0, /*
|
0
|
520 t if OBJECT is a nonnegative integer.
|
20
|
521 */
|
|
522 (object))
|
0
|
523 {
|
16
|
524 return NATNUMP (object) ? Qt : Qnil;
|
0
|
525 }
|
|
526
|
20
|
527 DEFUN ("bitp", Fbitp, 1, 1, 0, /*
|
0
|
528 t if OBJECT is a bit (0 or 1).
|
20
|
529 */
|
|
530 (object))
|
0
|
531 {
|
16
|
532 return BITP (object) ? Qt : Qnil;
|
0
|
533 }
|
|
534
|
20
|
535 DEFUN ("numberp", Fnumberp, 1, 1, 0, /*
|
0
|
536 t if OBJECT is a number (floating point or integer).
|
20
|
537 */
|
|
538 (object))
|
0
|
539 {
|
16
|
540 return INT_OR_FLOATP (object) ? Qt : Qnil;
|
0
|
541 }
|
|
542
|
20
|
543 DEFUN ("number-or-marker-p", Fnumber_or_marker_p, 1, 1, 0, /*
|
0
|
544 t if OBJECT is a number or a marker.
|
20
|
545 */
|
|
546 (object))
|
0
|
547 {
|
16
|
548 return INT_OR_FLOATP (object) || MARKERP (object) ? Qt : Qnil;
|
0
|
549 }
|
|
550
|
70
|
551 DEFUN ("number-char-or-marker-p", Fnumber_char_or_marker_p, 1, 1, 0, /*
|
|
552 t if OBJECT is a number, character or a marker.
|
|
553 */
|
|
554 (object))
|
|
555 {
|
|
556 return (INT_OR_FLOATP (object) ||
|
|
557 CHARP (object) ||
|
|
558 MARKERP (object))
|
|
559 ? Qt : Qnil;
|
|
560 }
|
|
561
|
0
|
562 #ifdef LISP_FLOAT_TYPE
|
20
|
563 DEFUN ("floatp", Ffloatp, 1, 1, 0, /*
|
0
|
564 t if OBJECT is a floating point number.
|
20
|
565 */
|
|
566 (object))
|
0
|
567 {
|
16
|
568 return FLOATP (object) ? Qt : Qnil;
|
0
|
569 }
|
|
570 #endif /* LISP_FLOAT_TYPE */
|
|
571
|
20
|
572 DEFUN ("type-of", Ftype_of, 1, 1, 0, /*
|
0
|
573 Return a symbol representing the type of OBJECT.
|
20
|
574 */
|
|
575 (object))
|
0
|
576 {
|
16
|
577 if (CONSP (object)) return Qcons;
|
|
578 if (SYMBOLP (object)) return Qsymbol;
|
|
579 if (KEYWORDP (object)) return Qkeyword;
|
|
580 if (INTP (object)) return Qinteger;
|
70
|
581 if (CHARP (object)) return Qcharacter;
|
16
|
582 if (STRINGP (object)) return Qstring;
|
|
583 if (VECTORP (object)) return Qvector;
|
|
584
|
0
|
585 assert (LRECORDP (object));
|
|
586 return intern (XRECORD_LHEADER (object)->implementation->name);
|
|
587 }
|
|
588
|
|
589
|
|
590 /* Extract and set components of lists */
|
|
591
|
20
|
592 DEFUN ("car", Fcar, 1, 1, 0, /*
|
0
|
593 Return the car of LIST. If arg is nil, return nil.
|
|
594 Error if arg is not nil and not a cons cell. See also `car-safe'.
|
20
|
595 */
|
|
596 (list))
|
0
|
597 {
|
|
598 while (1)
|
|
599 {
|
|
600 if (CONSP (list))
|
|
601 return XCAR (list);
|
|
602 else if (NILP (list))
|
|
603 return Qnil;
|
|
604 else
|
|
605 list = wrong_type_argument (Qconsp, list);
|
|
606 }
|
|
607 }
|
|
608
|
20
|
609 DEFUN ("car-safe", Fcar_safe, 1, 1, 0, /*
|
0
|
610 Return the car of OBJECT if it is a cons cell, or else nil.
|
20
|
611 */
|
|
612 (object))
|
0
|
613 {
|
16
|
614 return CONSP (object) ? XCAR (object) : Qnil;
|
0
|
615 }
|
|
616
|
20
|
617 DEFUN ("cdr", Fcdr, 1, 1, 0, /*
|
0
|
618 Return the cdr of LIST. If arg is nil, return nil.
|
|
619 Error if arg is not nil and not a cons cell. See also `cdr-safe'.
|
20
|
620 */
|
|
621 (list))
|
0
|
622 {
|
|
623 while (1)
|
|
624 {
|
|
625 if (CONSP (list))
|
|
626 return XCDR (list);
|
|
627 else if (NILP (list))
|
|
628 return Qnil;
|
|
629 else
|
|
630 list = wrong_type_argument (Qconsp, list);
|
|
631 }
|
|
632 }
|
|
633
|
20
|
634 DEFUN ("cdr-safe", Fcdr_safe, 1, 1, 0, /*
|
0
|
635 Return the cdr of OBJECT if it is a cons cell, or else nil.
|
20
|
636 */
|
|
637 (object))
|
0
|
638 {
|
16
|
639 return CONSP (object) ? XCDR (object) : Qnil;
|
0
|
640 }
|
|
641
|
20
|
642 DEFUN ("setcar", Fsetcar, 2, 2, 0, /*
|
0
|
643 Set the car of CONSCELL to be NEWCAR. Returns NEWCAR.
|
20
|
644 */
|
|
645 (conscell, newcar))
|
0
|
646 {
|
|
647 if (!CONSP (conscell))
|
|
648 conscell = wrong_type_argument (Qconsp, conscell);
|
|
649
|
|
650 CHECK_IMPURE (conscell);
|
|
651 XCAR (conscell) = newcar;
|
|
652 return newcar;
|
|
653 }
|
|
654
|
20
|
655 DEFUN ("setcdr", Fsetcdr, 2, 2, 0, /*
|
0
|
656 Set the cdr of CONSCELL to be NEWCDR. Returns NEWCDR.
|
20
|
657 */
|
|
658 (conscell, newcdr))
|
0
|
659 {
|
|
660 if (!CONSP (conscell))
|
|
661 conscell = wrong_type_argument (Qconsp, conscell);
|
|
662
|
|
663 CHECK_IMPURE (conscell);
|
|
664 XCDR (conscell) = newcdr;
|
|
665 return newcdr;
|
|
666 }
|
|
667
|
|
668 /* Find the function at the end of a chain of symbol function indirections. */
|
|
669
|
|
670 /* If OBJECT is a symbol, find the end of its function chain and
|
|
671 return the value found there. If OBJECT is not a symbol, just
|
|
672 return it. If there is a cycle in the function chain, signal a
|
|
673 cyclic-function-indirection error.
|
|
674
|
|
675 This is like Findirect_function, except that it doesn't signal an
|
|
676 error if the chain ends up unbound. */
|
|
677 Lisp_Object
|
|
678 indirect_function (Lisp_Object object, int errorp)
|
|
679 {
|
|
680 Lisp_Object tortoise = object;
|
16
|
681 Lisp_Object hare = object;
|
0
|
682
|
|
683 for (;;)
|
|
684 {
|
|
685 if (!SYMBOLP (hare) || UNBOUNDP (hare))
|
|
686 break;
|
|
687 hare = XSYMBOL (hare)->function;
|
|
688 if (!SYMBOLP (hare) || UNBOUNDP (hare))
|
|
689 break;
|
|
690 hare = XSYMBOL (hare)->function;
|
|
691
|
|
692 tortoise = XSYMBOL (tortoise)->function;
|
|
693
|
|
694 if (EQ (hare, tortoise))
|
|
695 return (Fsignal (Qcyclic_function_indirection, list1 (object)));
|
|
696 }
|
|
697
|
|
698 if (UNBOUNDP (hare) && errorp)
|
|
699 return Fsignal (Qvoid_function, list1 (object));
|
|
700 return hare;
|
|
701 }
|
|
702
|
20
|
703 DEFUN ("indirect-function", Findirect_function, 1, 1, 0, /*
|
0
|
704 Return the function at the end of OBJECT's function chain.
|
|
705 If OBJECT is a symbol, follow all function indirections and return
|
|
706 the final function binding.
|
|
707 If OBJECT is not a symbol, just return it.
|
|
708 Signal a void-function error if the final symbol is unbound.
|
|
709 Signal a cyclic-function-indirection error if there is a loop in the
|
|
710 function chain of symbols.
|
20
|
711 */
|
|
712 (object))
|
0
|
713 {
|
|
714 return indirect_function (object, 1);
|
|
715 }
|
|
716
|
|
717 /* Extract and set vector and string elements */
|
|
718
|
20
|
719 DEFUN ("aref", Faref, 2, 2, 0, /*
|
0
|
720 Return the element of ARRAY at index INDEX.
|
|
721 ARRAY may be a vector, bit vector, string, or byte-code object.
|
|
722 IDX starts at 0.
|
20
|
723 */
|
|
724 (array, idx))
|
0
|
725 {
|
|
726 int idxval;
|
|
727
|
|
728 retry:
|
|
729 CHECK_INT_COERCE_CHAR (idx); /* yuck! */
|
|
730 idxval = XINT (idx);
|
|
731 if (idxval < 0)
|
|
732 {
|
|
733 lose:
|
|
734 args_out_of_range (array, idx);
|
|
735 }
|
|
736 if (VECTORP (array))
|
|
737 {
|
|
738 if (idxval >= vector_length (XVECTOR (array))) goto lose;
|
|
739 return vector_data (XVECTOR (array))[idxval];
|
|
740 }
|
|
741 else if (BIT_VECTORP (array))
|
|
742 {
|
|
743 if (idxval >= bit_vector_length (XBIT_VECTOR (array))) goto lose;
|
|
744 return make_int (bit_vector_bit (XBIT_VECTOR (array), idxval));
|
|
745 }
|
|
746 else if (STRINGP (array))
|
|
747 {
|
|
748 if (idxval >= string_char_length (XSTRING (array))) goto lose;
|
|
749 return (make_char (string_char (XSTRING (array), idxval)));
|
|
750 }
|
|
751 #ifdef LOSING_BYTECODE
|
|
752 else if (COMPILED_FUNCTIONP (array))
|
|
753 {
|
|
754 /* Weird, gross compatibility kludge */
|
|
755 return (Felt (array, idx));
|
|
756 }
|
|
757 #endif
|
|
758 else
|
|
759 {
|
|
760 check_losing_bytecode ("aref", array);
|
|
761 array = wrong_type_argument (Qarrayp, array);
|
|
762 goto retry;
|
|
763 }
|
|
764 }
|
|
765
|
20
|
766 DEFUN ("aset", Faset, 3, 3, 0, /*
|
0
|
767 Store into the element of ARRAY at index IDX the value NEWVAL.
|
|
768 ARRAY may be a vector, bit vector, or string. IDX starts at 0.
|
20
|
769 */
|
|
770 (array, idx, newval))
|
0
|
771 {
|
|
772 int idxval;
|
|
773
|
|
774 CHECK_INT_COERCE_CHAR (idx); /* yuck! */
|
|
775 if (!VECTORP (array) && !BIT_VECTORP (array) && !STRINGP (array))
|
|
776 array = wrong_type_argument (Qarrayp, array);
|
|
777
|
|
778 idxval = XINT (idx);
|
|
779 if (idxval < 0)
|
|
780 {
|
|
781 lose:
|
|
782 args_out_of_range (array, idx);
|
|
783 }
|
|
784 CHECK_IMPURE (array);
|
|
785
|
|
786 if (VECTORP (array))
|
|
787 {
|
|
788 if (idxval >= vector_length (XVECTOR (array))) goto lose;
|
|
789 vector_data (XVECTOR (array))[idxval] = newval;
|
|
790 }
|
|
791 else if (BIT_VECTORP (array))
|
|
792 {
|
|
793 if (idxval >= bit_vector_length (XBIT_VECTOR (array))) goto lose;
|
|
794 CHECK_BIT (newval);
|
|
795 set_bit_vector_bit (XBIT_VECTOR (array), idxval, !ZEROP (newval));
|
|
796 }
|
|
797 else /* string */
|
|
798 {
|
|
799 CHECK_CHAR_COERCE_INT (newval);
|
|
800 if (idxval >= string_char_length (XSTRING (array))) goto lose;
|
|
801 set_string_char (XSTRING (array), idxval, XCHAR (newval));
|
|
802 bump_string_modiff (array);
|
|
803 }
|
|
804
|
|
805 return newval;
|
|
806 }
|
|
807
|
|
808
|
|
809 /**********************************************************************/
|
|
810 /* Compiled-function objects */
|
|
811 /**********************************************************************/
|
|
812
|
|
813 /* The compiled_function->doc_and_interactive slot uses the minimal
|
|
814 number of conses, based on compiled_function->flags; it may take
|
|
815 any of the following forms:
|
|
816
|
|
817 doc
|
|
818 interactive
|
|
819 domain
|
|
820 (doc . interactive)
|
|
821 (doc . domain)
|
|
822 (interactive . domain)
|
|
823 (doc . (interactive . domain))
|
|
824 */
|
|
825
|
|
826 /* Caller must check flags.interactivep first */
|
|
827 Lisp_Object
|
|
828 compiled_function_interactive (struct Lisp_Compiled_Function *b)
|
|
829 {
|
|
830 assert (b->flags.interactivep);
|
|
831 if (b->flags.documentationp && b->flags.domainp)
|
|
832 return (XCAR (XCDR (b->doc_and_interactive)));
|
|
833 else if (b->flags.documentationp)
|
|
834 return (XCDR (b->doc_and_interactive));
|
|
835 else if (b->flags.domainp)
|
|
836 return (XCAR (b->doc_and_interactive));
|
|
837
|
|
838 /* if all else fails... */
|
|
839 return (b->doc_and_interactive);
|
|
840 }
|
|
841
|
|
842 /* Caller need not check flags.documentationp first */
|
|
843 Lisp_Object
|
|
844 compiled_function_documentation (struct Lisp_Compiled_Function *b)
|
|
845 {
|
|
846 if (! b->flags.documentationp)
|
|
847 return Qnil;
|
|
848 else if (b->flags.interactivep && b->flags.domainp)
|
|
849 return (XCAR (b->doc_and_interactive));
|
|
850 else if (b->flags.interactivep)
|
|
851 return (XCAR (b->doc_and_interactive));
|
|
852 else if (b->flags.domainp)
|
|
853 return (XCAR (b->doc_and_interactive));
|
|
854 else
|
|
855 return (b->doc_and_interactive);
|
|
856 }
|
|
857
|
|
858 /* Caller need not check flags.domainp first */
|
|
859 Lisp_Object
|
|
860 compiled_function_domain (struct Lisp_Compiled_Function *b)
|
|
861 {
|
|
862 if (! b->flags.domainp)
|
|
863 return Qnil;
|
|
864 else if (b->flags.documentationp && b->flags.interactivep)
|
|
865 return (XCDR (XCDR (b->doc_and_interactive)));
|
|
866 else if (b->flags.documentationp)
|
|
867 return (XCDR (b->doc_and_interactive));
|
|
868 else if (b->flags.interactivep)
|
|
869 return (XCDR (b->doc_and_interactive));
|
|
870 else
|
|
871 return (b->doc_and_interactive);
|
|
872 }
|
|
873
|
|
874 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
875
|
|
876 Lisp_Object
|
|
877 compiled_function_annotation (struct Lisp_Compiled_Function *b)
|
|
878 {
|
|
879 return b->annotated;
|
|
880 }
|
|
881
|
|
882 #endif
|
|
883
|
|
884 /* used only by Snarf-documentation; there must be doc already. */
|
|
885 void
|
|
886 set_compiled_function_documentation (struct Lisp_Compiled_Function *b,
|
|
887 Lisp_Object new)
|
|
888 {
|
|
889 assert (b->flags.documentationp);
|
|
890 assert (INTP (new) || STRINGP (new));
|
|
891
|
|
892 if (b->flags.interactivep && b->flags.domainp)
|
|
893 XCAR (b->doc_and_interactive) = new;
|
|
894 else if (b->flags.interactivep)
|
|
895 XCAR (b->doc_and_interactive) = new;
|
|
896 else if (b->flags.domainp)
|
|
897 XCAR (b->doc_and_interactive) = new;
|
|
898 else
|
|
899 b->doc_and_interactive = new;
|
|
900 }
|
|
901
|
20
|
902 DEFUN ("compiled-function-instructions", Fcompiled_function_instructions, 1, 1, 0, /*
|
0
|
903 Return the byte-opcode string of the compiled-function object.
|
20
|
904 */
|
|
905 (function))
|
0
|
906 {
|
|
907 CHECK_COMPILED_FUNCTION (function);
|
|
908 return (XCOMPILED_FUNCTION (function)->bytecodes);
|
|
909 }
|
|
910
|
20
|
911 DEFUN ("compiled-function-constants", Fcompiled_function_constants, 1, 1, 0, /*
|
0
|
912 Return the constants vector of the compiled-function object.
|
20
|
913 */
|
|
914 (function))
|
0
|
915 {
|
|
916 CHECK_COMPILED_FUNCTION (function);
|
|
917 return (XCOMPILED_FUNCTION (function)->constants);
|
|
918 }
|
|
919
|
20
|
920 DEFUN ("compiled-function-stack-depth", Fcompiled_function_stack_depth, 1, 1, 0, /*
|
0
|
921 Return the max stack depth of the compiled-function object.
|
20
|
922 */
|
|
923 (function))
|
0
|
924 {
|
|
925 CHECK_COMPILED_FUNCTION (function);
|
|
926 return (make_int (XCOMPILED_FUNCTION (function)->maxdepth));
|
|
927 }
|
|
928
|
20
|
929 DEFUN ("compiled-function-arglist", Fcompiled_function_arglist, 1, 1, 0, /*
|
0
|
930 Return the argument list of the compiled-function object.
|
20
|
931 */
|
|
932 (function))
|
0
|
933 {
|
|
934 CHECK_COMPILED_FUNCTION (function);
|
|
935 return (XCOMPILED_FUNCTION (function)->arglist);
|
|
936 }
|
|
937
|
20
|
938 DEFUN ("compiled-function-interactive", Fcompiled_function_interactive, 1, 1, 0, /*
|
0
|
939 Return the interactive spec of the compiled-function object, or nil.
|
|
940 If non-nil, the return value will be a list whose first element is
|
|
941 `interactive' and whose second element is the interactive spec.
|
20
|
942 */
|
|
943 (function))
|
0
|
944 {
|
|
945 CHECK_COMPILED_FUNCTION (function);
|
|
946 if (!XCOMPILED_FUNCTION (function)->flags.interactivep)
|
|
947 return Qnil;
|
|
948 return (list2 (Qinteractive,
|
|
949 compiled_function_interactive
|
|
950 (XCOMPILED_FUNCTION (function))));
|
|
951 }
|
|
952
|
20
|
953 DEFUN ("compiled-function-doc-string", Fcompiled_function_doc_string, 1, 1, 0, /*
|
0
|
954 Return the doc string of the compiled-function object, if available.
|
20
|
955 */
|
|
956 (function))
|
0
|
957 {
|
|
958 CHECK_COMPILED_FUNCTION (function);
|
|
959 if (!XCOMPILED_FUNCTION (function)->flags.interactivep)
|
|
960 return Qnil;
|
|
961 return (list2 (Qinteractive,
|
|
962 compiled_function_interactive
|
|
963 (XCOMPILED_FUNCTION (function))));
|
|
964 }
|
|
965
|
|
966 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
967
|
20
|
968 DEFUN ("compiled-function-annotation", Fcompiled_function_annotation, 1, 1, 0, /*
|
0
|
969 Return the annotation of the compiled-function object, or nil.
|
|
970 The annotation is a piece of information indicating where this
|
|
971 compiled-function object came from. Generally this will be
|
|
972 a symbol naming a function; or a string naming a file, if the
|
|
973 compiled-function object was not defined in a function; or nil,
|
|
974 if the compiled-function object was not created as a result of
|
|
975 a `load'.
|
20
|
976 */
|
|
977 (function))
|
0
|
978 {
|
|
979 CHECK_COMPILED_FUNCTION (function);
|
|
980 return (compiled_function_annotation (XCOMPILED_FUNCTION (function)));
|
|
981 }
|
|
982
|
|
983 #endif /* COMPILED_FUNCTION_ANNOTATION_HACK */
|
|
984
|
20
|
985 DEFUN ("compiled-function-domain", Fcompiled_function_domain, 1, 1, 0, /*
|
0
|
986 Return the domain of the compiled-function object, or nil.
|
|
987 This is only meaningful if I18N3 was enabled when emacs was compiled.
|
20
|
988 */
|
|
989 (function))
|
0
|
990 {
|
|
991 CHECK_COMPILED_FUNCTION (function);
|
|
992 if (!XCOMPILED_FUNCTION (function)->flags.domainp)
|
|
993 return Qnil;
|
|
994 return (compiled_function_domain (XCOMPILED_FUNCTION (function)));
|
|
995 }
|
|
996
|
|
997
|
|
998 /**********************************************************************/
|
|
999 /* Arithmetic functions */
|
|
1000 /**********************************************************************/
|
|
1001
|
|
1002 enum comparison { equal, notequal, less, grtr, less_or_equal, grtr_or_equal };
|
|
1003
|
|
1004 static Lisp_Object
|
16
|
1005 arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison)
|
0
|
1006 {
|
|
1007 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (num1);
|
|
1008 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (num2);
|
|
1009
|
|
1010 #ifdef LISP_FLOAT_TYPE
|
|
1011 if (FLOATP (num1) || FLOATP (num2))
|
|
1012 {
|
16
|
1013 double f1 = (FLOATP (num1)) ? float_data (XFLOAT (num1)) : XINT (num1);
|
|
1014 double f2 = (FLOATP (num2)) ? float_data (XFLOAT (num2)) : XINT (num2);
|
0
|
1015
|
|
1016 switch (comparison)
|
16
|
1017 {
|
|
1018 case equal: return f1 == f2 ? Qt : Qnil;
|
|
1019 case notequal: return f1 != f2 ? Qt : Qnil;
|
|
1020 case less: return f1 < f2 ? Qt : Qnil;
|
|
1021 case less_or_equal: return f1 <= f2 ? Qt : Qnil;
|
|
1022 case grtr: return f1 > f2 ? Qt : Qnil;
|
|
1023 case grtr_or_equal: return f1 >= f2 ? Qt : Qnil;
|
|
1024 }
|
0
|
1025 }
|
|
1026 #endif /* LISP_FLOAT_TYPE */
|
70
|
1027
|
16
|
1028 switch (comparison)
|
0
|
1029 {
|
16
|
1030 case equal: return XINT (num1) == XINT (num2) ? Qt : Qnil;
|
|
1031 case notequal: return XINT (num1) != XINT (num2) ? Qt : Qnil;
|
|
1032 case less: return XINT (num1) < XINT (num2) ? Qt : Qnil;
|
|
1033 case less_or_equal: return XINT (num1) <= XINT (num2) ? Qt : Qnil;
|
|
1034 case grtr: return XINT (num1) > XINT (num2) ? Qt : Qnil;
|
|
1035 case grtr_or_equal: return XINT (num1) >= XINT (num2) ? Qt : Qnil;
|
|
1036 }
|
0
|
1037
|
|
1038 abort ();
|
|
1039 return Qnil; /* suppress compiler warning */
|
|
1040 }
|
|
1041
|
20
|
1042 DEFUN ("=", Feqlsign, 2, 2, 0, /*
|
70
|
1043 T if two args, both numbers, characters or markers, are equal.
|
20
|
1044 */
|
|
1045 (num1, num2))
|
0
|
1046 {
|
|
1047 return arithcompare (num1, num2, equal);
|
|
1048 }
|
|
1049
|
20
|
1050 DEFUN ("<", Flss, 2, 2, 0, /*
|
16
|
1051 T if first arg is less than second arg.
|
70
|
1052 Both must be numbers, characters or markers.
|
20
|
1053 */
|
|
1054 (num1, num2))
|
0
|
1055 {
|
|
1056 return arithcompare (num1, num2, less);
|
|
1057 }
|
|
1058
|
20
|
1059 DEFUN (">", Fgtr, 2, 2, 0, /*
|
16
|
1060 T if first arg is greater than second arg.
|
70
|
1061 Both must be numbers, characters or markers.
|
20
|
1062 */
|
|
1063 (num1, num2))
|
0
|
1064 {
|
|
1065 return arithcompare (num1, num2, grtr);
|
|
1066 }
|
|
1067
|
20
|
1068 DEFUN ("<=", Fleq, 2, 2, 0, /*
|
0
|
1069 T if first arg is less than or equal to second arg.
|
70
|
1070 Both must be numbers, characters or markers.
|
20
|
1071 */
|
|
1072 (num1, num2))
|
0
|
1073 {
|
|
1074 return arithcompare (num1, num2, less_or_equal);
|
|
1075 }
|
|
1076
|
20
|
1077 DEFUN (">=", Fgeq, 2, 2, 0, /*
|
0
|
1078 T if first arg is greater than or equal to second arg.
|
70
|
1079 Both must be numbers, characters or markers.
|
20
|
1080 */
|
|
1081 (num1, num2))
|
0
|
1082 {
|
|
1083 return arithcompare (num1, num2, grtr_or_equal);
|
|
1084 }
|
|
1085
|
20
|
1086 DEFUN ("/=", Fneq, 2, 2, 0, /*
|
16
|
1087 T if first arg is not equal to second arg.
|
70
|
1088 Both must be numbers, characters or markers.
|
20
|
1089 */
|
|
1090 (num1, num2))
|
0
|
1091 {
|
|
1092 return arithcompare (num1, num2, notequal);
|
|
1093 }
|
|
1094
|
70
|
1095 #if 0
|
|
1096 /* I tried implementing Common Lisp multi-arg comparison functions,
|
|
1097 but failed because the byte-compiler needs to be hacked as well. */
|
|
1098
|
|
1099 static Lisp_Object
|
|
1100 arithcompare_many (enum comparison comparison, int nargs, Lisp_Object *args)
|
|
1101 {
|
|
1102 REGISTER int argnum;
|
|
1103 for (argnum = 1; argnum < nargs; argnum++)
|
|
1104 if (EQ (arithcompare ( args[argnum-1], args[argnum], comparison), Qnil))
|
|
1105 return Qnil;
|
|
1106
|
|
1107 return Qt;
|
|
1108 }
|
|
1109
|
|
1110 xxxDEFUN ("=", Feqlsign, 1, MANY, 0, /*
|
|
1111 T if all the arguments are equal.
|
|
1112 The arguments may be numbers, characters or markers.
|
|
1113 */
|
|
1114 (int nargs, Lisp_Object *args))
|
|
1115 {
|
|
1116 return arithcompare (equal, nargs, args);
|
|
1117 }
|
|
1118
|
|
1119 xxxDEFUN ("<", Flss, 1, MANY, 0, /*
|
|
1120 T if the sequence of arguments is monotonically increasing.
|
|
1121 The arguments may be numbers, characters or markers.
|
|
1122 */
|
|
1123 (int nargs, Lisp_Object *args))
|
|
1124 {
|
|
1125 return arithcompare (less, nargs, args);
|
|
1126 }
|
|
1127
|
|
1128 xxxDEFUN (">", Fgtr, 1, MANY, 0, /*
|
|
1129 T if the sequence of arguments is monotonically decreasing.
|
|
1130 The arguments may be numbers, characters or markers.
|
|
1131 */
|
|
1132 (int nargs, Lisp_Object *args))
|
|
1133 {
|
|
1134 return arithcompare (grtr, nargs, args);
|
|
1135 }
|
|
1136
|
|
1137 xxxDEFUN ("<=", Fleq, 1, MANY, 0, /*
|
|
1138 T if the sequence of arguments is monotonically nondecreasing.
|
|
1139 The arguments may be numbers, characters or markers.
|
|
1140 */
|
|
1141 (int nargs, Lisp_Object *args))
|
|
1142 {
|
|
1143 return arithcompare (less_or_equal, nargs, args);
|
|
1144 }
|
|
1145
|
|
1146 xxxDEFUN (">=", Fgeq, 1, MANY, 0, /*
|
|
1147 T if the sequence of arguments is monotonically nonincreasing.
|
|
1148 The arguments may be numbers, characters or markers.
|
|
1149 */
|
|
1150 (int nargs, Lisp_Object *args))
|
|
1151 {
|
|
1152 return arithcompare_many (grtr_or_equal, nargs, args);
|
|
1153 }
|
|
1154
|
|
1155 xxxDEFUN ("/=", Fneq, 1, MANY, 0, /*
|
|
1156 T if the sequence of arguments is monotonically increasing.
|
|
1157 The arguments may be numbers, characters or markers.
|
|
1158 */
|
|
1159 (int nargs, Lisp_Object *args))
|
|
1160 {
|
|
1161 return arithcompare_many (notequal, nargs, args);
|
|
1162 }
|
|
1163 #endif /* 0 - disabled for now */
|
|
1164
|
20
|
1165 DEFUN ("zerop", Fzerop, 1, 1, 0, /*
|
0
|
1166 T if NUMBER is zero.
|
20
|
1167 */
|
|
1168 (number))
|
0
|
1169 {
|
|
1170 CHECK_INT_OR_FLOAT (number);
|
|
1171
|
|
1172 #ifdef LISP_FLOAT_TYPE
|
|
1173 if (FLOATP (number))
|
16
|
1174 return (float_data (XFLOAT (number)) == 0.0) ? Qt : Qnil;
|
0
|
1175 #endif /* LISP_FLOAT_TYPE */
|
|
1176
|
16
|
1177 return (XINT (number) == 0) ? Qt : Qnil;
|
0
|
1178 }
|
|
1179
|
|
1180 /* Convert between a 32-bit value and a cons of two 16-bit values.
|
|
1181 This is used to pass 32-bit integers to and from the user.
|
|
1182 Use time_to_lisp() and lisp_to_time() for time values.
|
|
1183
|
|
1184 If you're thinking of using this to store a pointer into a Lisp Object
|
|
1185 for internal purposes (such as when calling record_unwind_protect()),
|
|
1186 try using make_opaque_ptr()/get_opaque_ptr() instead. */
|
|
1187 Lisp_Object
|
|
1188 word_to_lisp (unsigned int item)
|
|
1189 {
|
|
1190 return Fcons (make_int (item >> 16), make_int (item & 0xffff));
|
|
1191 }
|
|
1192
|
|
1193 unsigned int
|
|
1194 lisp_to_word (Lisp_Object item)
|
|
1195 {
|
|
1196 if (INTP (item))
|
|
1197 return XINT (item);
|
|
1198 else
|
|
1199 {
|
|
1200 Lisp_Object top = Fcar (item);
|
|
1201 Lisp_Object bot = Fcdr (item);
|
|
1202 CHECK_INT (top);
|
|
1203 CHECK_INT (bot);
|
|
1204 return (XINT (top) << 16) | (XINT (bot) & 0xffff);
|
|
1205 }
|
|
1206 }
|
|
1207
|
|
1208
|
20
|
1209 DEFUN ("number-to-string", Fnumber_to_string, 1, 1, 0, /*
|
0
|
1210 Convert NUM to a string by printing it in decimal.
|
|
1211 Uses a minus sign if negative.
|
|
1212 NUM may be an integer or a floating point number.
|
20
|
1213 */
|
|
1214 (num))
|
0
|
1215 {
|
|
1216 char buffer[VALBITS];
|
|
1217
|
|
1218 CHECK_INT_OR_FLOAT (num);
|
|
1219
|
|
1220 #ifdef LISP_FLOAT_TYPE
|
|
1221 if (FLOATP (num))
|
|
1222 {
|
|
1223 char pigbuf[350]; /* see comments in float_to_string */
|
|
1224
|
|
1225 float_to_string (pigbuf, float_data (XFLOAT (num)));
|
|
1226 return build_string (pigbuf);
|
|
1227 }
|
|
1228 #endif /* LISP_FLOAT_TYPE */
|
|
1229
|
|
1230 if (sizeof (int) == sizeof (EMACS_INT))
|
|
1231 sprintf (buffer, "%d", XINT (num));
|
|
1232 else if (sizeof (long) == sizeof (EMACS_INT))
|
|
1233 sprintf (buffer, "%ld", (long) XINT (num));
|
|
1234 else
|
|
1235 abort ();
|
|
1236 return build_string (buffer);
|
|
1237 }
|
|
1238
|
20
|
1239 DEFUN ("string-to-number", Fstring_to_number, 1, 1, 0, /*
|
0
|
1240 Convert STRING to a number by parsing it as a decimal number.
|
|
1241 This parses both integers and floating point numbers.
|
|
1242 It ignores leading spaces and tabs.
|
20
|
1243 */
|
|
1244 (string))
|
0
|
1245 {
|
|
1246 Lisp_Object value;
|
|
1247 char *p;
|
|
1248 CHECK_STRING (string);
|
|
1249
|
16
|
1250 p = (char *) XSTRING_DATA (string);
|
0
|
1251 /* Skip any whitespace at the front of the number. Some versions of
|
|
1252 atoi do this anyway, so we might as well make Emacs lisp consistent. */
|
|
1253 while (*p == ' ' || *p == '\t')
|
|
1254 p++;
|
|
1255
|
|
1256 #ifdef LISP_FLOAT_TYPE
|
|
1257 if (isfloat_string (p))
|
|
1258 return make_float (atof (p));
|
|
1259 #endif /* LISP_FLOAT_TYPE */
|
|
1260
|
|
1261 if (sizeof (int) == sizeof (EMACS_INT))
|
|
1262 XSETINT (value, atoi (p));
|
|
1263 else if (sizeof (long) == sizeof (EMACS_INT))
|
|
1264 XSETINT (value, atol (p));
|
|
1265 else
|
|
1266 abort ();
|
|
1267 return value;
|
|
1268 }
|
|
1269
|
|
1270 enum arithop
|
|
1271 { Aadd, Asub, Amult, Adiv, Alogand, Alogior, Alogxor, Amax, Amin };
|
|
1272
|
70
|
1273
|
0
|
1274 #ifdef LISP_FLOAT_TYPE
|
|
1275 static Lisp_Object
|
|
1276 float_arith_driver (double accum, int argnum, enum arithop code, int nargs,
|
|
1277 Lisp_Object *args)
|
|
1278 {
|
|
1279 REGISTER Lisp_Object val;
|
|
1280 double next;
|
|
1281
|
|
1282 for (; argnum < nargs; argnum++)
|
|
1283 {
|
16
|
1284 /* using args[argnum] as argument to CHECK_INT_OR_FLOAT_... */
|
|
1285 val = args[argnum];
|
0
|
1286 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (val);
|
|
1287
|
|
1288 if (FLOATP (val))
|
|
1289 {
|
|
1290 next = float_data (XFLOAT (val));
|
|
1291 }
|
|
1292 else
|
|
1293 {
|
|
1294 args[argnum] = val; /* runs into a compiler bug. */
|
|
1295 next = XINT (args[argnum]);
|
|
1296 }
|
|
1297 switch (code)
|
|
1298 {
|
|
1299 case Aadd:
|
|
1300 accum += next;
|
|
1301 break;
|
|
1302 case Asub:
|
|
1303 if (!argnum && nargs != 1)
|
|
1304 next = - next;
|
|
1305 accum -= next;
|
|
1306 break;
|
|
1307 case Amult:
|
|
1308 accum *= next;
|
|
1309 break;
|
|
1310 case Adiv:
|
|
1311 if (!argnum)
|
|
1312 accum = next;
|
|
1313 else
|
|
1314 {
|
|
1315 if (next == 0)
|
|
1316 Fsignal (Qarith_error, Qnil);
|
|
1317 accum /= next;
|
|
1318 }
|
|
1319 break;
|
|
1320 case Alogand:
|
|
1321 case Alogior:
|
|
1322 case Alogxor:
|
70
|
1323 return wrong_type_argument (Qinteger_char_or_marker_p, val);
|
0
|
1324 case Amax:
|
|
1325 if (!argnum || isnan (next) || next > accum)
|
|
1326 accum = next;
|
|
1327 break;
|
|
1328 case Amin:
|
|
1329 if (!argnum || isnan (next) || next < accum)
|
|
1330 accum = next;
|
|
1331 break;
|
|
1332 }
|
|
1333 }
|
|
1334
|
|
1335 return make_float (accum);
|
|
1336 }
|
|
1337 #endif /* LISP_FLOAT_TYPE */
|
|
1338
|
16
|
1339 static Lisp_Object
|
|
1340 arith_driver (enum arithop code, int nargs, Lisp_Object *args)
|
|
1341 {
|
|
1342 Lisp_Object val;
|
|
1343 REGISTER int argnum;
|
|
1344 REGISTER EMACS_INT accum = 0;
|
|
1345 REGISTER EMACS_INT next;
|
|
1346
|
|
1347 switch (code)
|
|
1348 {
|
|
1349 case Alogior:
|
|
1350 case Alogxor:
|
|
1351 case Aadd:
|
|
1352 case Asub:
|
|
1353 accum = 0; break;
|
|
1354 case Amult:
|
|
1355 accum = 1; break;
|
|
1356 case Alogand:
|
|
1357 accum = -1; break;
|
|
1358 case Adiv:
|
|
1359 case Amax:
|
|
1360 case Amin:
|
|
1361 accum = 0; break;
|
|
1362 default:
|
|
1363 abort ();
|
|
1364 }
|
|
1365
|
|
1366 for (argnum = 0; argnum < nargs; argnum++)
|
|
1367 {
|
|
1368 /* using args[argnum] as argument to CHECK_INT_OR_FLOAT_... */
|
|
1369 val = args[argnum];
|
|
1370 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (val);
|
|
1371
|
|
1372 #ifdef LISP_FLOAT_TYPE
|
|
1373 if (FLOATP (val)) /* time to do serious math */
|
|
1374 return (float_arith_driver ((double) accum, argnum, code,
|
|
1375 nargs, args));
|
|
1376 #endif /* LISP_FLOAT_TYPE */
|
|
1377 args[argnum] = val; /* runs into a compiler bug. */
|
|
1378 next = XINT (args[argnum]);
|
|
1379 switch (code)
|
|
1380 {
|
|
1381 case Aadd: accum += next; break;
|
|
1382 case Asub:
|
|
1383 if (!argnum && nargs != 1)
|
|
1384 next = - next;
|
|
1385 accum -= next;
|
|
1386 break;
|
|
1387 case Amult: accum *= next; break;
|
|
1388 case Adiv:
|
|
1389 if (!argnum) accum = next;
|
|
1390 else
|
|
1391 {
|
|
1392 if (next == 0)
|
|
1393 Fsignal (Qarith_error, Qnil);
|
|
1394 accum /= next;
|
|
1395 }
|
|
1396 break;
|
|
1397 case Alogand: accum &= next; break;
|
|
1398 case Alogior: accum |= next; break;
|
|
1399 case Alogxor: accum ^= next; break;
|
|
1400 case Amax: if (!argnum || next > accum) accum = next; break;
|
|
1401 case Amin: if (!argnum || next < accum) accum = next; break;
|
|
1402 }
|
|
1403 }
|
|
1404
|
|
1405 XSETINT (val, accum);
|
|
1406 return val;
|
|
1407 }
|
|
1408
|
20
|
1409 DEFUN ("+", Fplus, 0, MANY, 0, /*
|
16
|
1410 Return sum of any number of arguments.
|
70
|
1411 The arguments should all be numbers, characters or markers.
|
20
|
1412 */
|
|
1413 (int nargs, Lisp_Object *args))
|
0
|
1414 {
|
|
1415 return arith_driver (Aadd, nargs, args);
|
|
1416 }
|
|
1417
|
20
|
1418 DEFUN ("-", Fminus, 0, MANY, 0, /*
|
70
|
1419 Negate number or subtract numbers, characters or markers.
|
0
|
1420 With one arg, negates it. With more than one arg,
|
|
1421 subtracts all but the first from the first.
|
20
|
1422 */
|
|
1423 (int nargs, Lisp_Object *args))
|
0
|
1424 {
|
|
1425 return arith_driver (Asub, nargs, args);
|
|
1426 }
|
|
1427
|
20
|
1428 DEFUN ("*", Ftimes, 0, MANY, 0, /*
|
16
|
1429 Return product of any number of arguments.
|
70
|
1430 The arguments should all be numbers, characters or markers.
|
20
|
1431 */
|
|
1432 (int nargs, Lisp_Object *args))
|
0
|
1433 {
|
|
1434 return arith_driver (Amult, nargs, args);
|
|
1435 }
|
|
1436
|
20
|
1437 DEFUN ("/", Fquo, 2, MANY, 0, /*
|
0
|
1438 Return first argument divided by all the remaining arguments.
|
70
|
1439 The arguments must be numbers, characters or markers.
|
20
|
1440 */
|
|
1441 (int nargs, Lisp_Object *args))
|
0
|
1442 {
|
|
1443 return arith_driver (Adiv, nargs, args);
|
|
1444 }
|
|
1445
|
20
|
1446 DEFUN ("%", Frem, 2, 2, 0, /*
|
0
|
1447 Return remainder of first arg divided by second.
|
70
|
1448 Both must be integers, characters or markers.
|
20
|
1449 */
|
|
1450 (num1, num2))
|
0
|
1451 {
|
|
1452 CHECK_INT_COERCE_CHAR_OR_MARKER (num1);
|
|
1453 CHECK_INT_COERCE_CHAR_OR_MARKER (num2);
|
|
1454
|
|
1455 if (ZEROP (num2))
|
|
1456 Fsignal (Qarith_error, Qnil);
|
|
1457
|
|
1458 return (make_int (XINT (num1) % XINT (num2)));
|
|
1459 }
|
|
1460
|
|
1461 /* Note, ANSI *requires* the presence of the fmod() library routine.
|
|
1462 If your system doesn't have it, complain to your vendor, because
|
|
1463 that is a bug. */
|
|
1464
|
|
1465 #ifndef HAVE_FMOD
|
|
1466 double
|
|
1467 fmod (double f1, double f2)
|
|
1468 {
|
|
1469 if (f2 < 0.0)
|
|
1470 f2 = -f2;
|
|
1471 return (f1 - f2 * floor (f1/f2));
|
|
1472 }
|
|
1473 #endif /* ! HAVE_FMOD */
|
|
1474
|
|
1475
|
20
|
1476 DEFUN ("mod", Fmod, 2, 2, 0, /*
|
0
|
1477 Return X modulo Y.
|
|
1478 The result falls between zero (inclusive) and Y (exclusive).
|
70
|
1479 Both X and Y must be numbers, characters or markers.
|
0
|
1480 If either argument is a float, a float will be returned.
|
20
|
1481 */
|
|
1482 (x, y))
|
0
|
1483 {
|
|
1484 EMACS_INT i1, i2;
|
|
1485
|
|
1486 #ifdef LISP_FLOAT_TYPE
|
|
1487 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (x);
|
|
1488 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (y);
|
|
1489
|
|
1490 if (FLOATP (x) || FLOATP (y))
|
|
1491 {
|
|
1492 double f1, f2;
|
|
1493
|
|
1494 f1 = ((FLOATP (x)) ? float_data (XFLOAT (x)) : XINT (x));
|
|
1495 f2 = ((FLOATP (y)) ? float_data (XFLOAT (y)) : XINT (y));
|
|
1496 if (f2 == 0)
|
|
1497 Fsignal (Qarith_error, Qnil);
|
|
1498
|
|
1499 f1 = fmod (f1, f2);
|
|
1500
|
|
1501 /* If the "remainder" comes out with the wrong sign, fix it. */
|
|
1502 if (f2 < 0 ? f1 > 0 : f1 < 0)
|
|
1503 f1 += f2;
|
|
1504 return (make_float (f1));
|
|
1505 }
|
|
1506 #else /* not LISP_FLOAT_TYPE */
|
|
1507 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (x);
|
|
1508 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (y);
|
|
1509 #endif /* not LISP_FLOAT_TYPE */
|
|
1510
|
|
1511 i1 = XINT (x);
|
|
1512 i2 = XINT (y);
|
|
1513
|
|
1514 if (i2 == 0)
|
|
1515 Fsignal (Qarith_error, Qnil);
|
|
1516
|
|
1517 i1 %= i2;
|
|
1518
|
|
1519 /* If the "remainder" comes out with the wrong sign, fix it. */
|
|
1520 if (i2 < 0 ? i1 > 0 : i1 < 0)
|
|
1521 i1 += i2;
|
|
1522
|
|
1523 return (make_int (i1));
|
|
1524 }
|
|
1525
|
|
1526
|
20
|
1527 DEFUN ("max", Fmax, 1, MANY, 0, /*
|
16
|
1528 Return largest of all the arguments.
|
70
|
1529 All arguments must be numbers, characters or markers.
|
|
1530 The value is always a number; markers and characters are converted
|
|
1531 to numbers.
|
20
|
1532 */
|
|
1533 (int nargs, Lisp_Object *args))
|
0
|
1534 {
|
|
1535 return arith_driver (Amax, nargs, args);
|
|
1536 }
|
|
1537
|
20
|
1538 DEFUN ("min", Fmin, 1, MANY, 0, /*
|
16
|
1539 Return smallest of all the arguments.
|
70
|
1540 All arguments must be numbers, characters or markers.
|
|
1541 The value is always a number; markers and characters are converted
|
|
1542 to numbers.
|
20
|
1543 */
|
|
1544 (int nargs, Lisp_Object *args))
|
0
|
1545 {
|
|
1546 return arith_driver (Amin, nargs, args);
|
|
1547 }
|
|
1548
|
20
|
1549 DEFUN ("logand", Flogand, 0, MANY, 0, /*
|
0
|
1550 Return bitwise-and of all the arguments.
|
70
|
1551 Arguments may be integers, or markers or characters converted to integers.
|
20
|
1552 */
|
|
1553 (int nargs, Lisp_Object *args))
|
0
|
1554 {
|
|
1555 return arith_driver (Alogand, nargs, args);
|
|
1556 }
|
|
1557
|
20
|
1558 DEFUN ("logior", Flogior, 0, MANY, 0, /*
|
0
|
1559 Return bitwise-or of all the arguments.
|
70
|
1560 Arguments may be integers, or markers or characters converted to integers.
|
20
|
1561 */
|
|
1562 (int nargs, Lisp_Object *args))
|
0
|
1563 {
|
|
1564 return arith_driver (Alogior, nargs, args);
|
|
1565 }
|
|
1566
|
20
|
1567 DEFUN ("logxor", Flogxor, 0, MANY, 0, /*
|
0
|
1568 Return bitwise-exclusive-or of all the arguments.
|
70
|
1569 Arguments may be integers, or markers or characters converted to integers.
|
20
|
1570 */
|
|
1571 (int nargs, Lisp_Object *args))
|
0
|
1572 {
|
|
1573 return arith_driver (Alogxor, nargs, args);
|
|
1574 }
|
|
1575
|
20
|
1576 DEFUN ("ash", Fash, 2, 2, 0, /*
|
0
|
1577 Return VALUE with its bits shifted left by COUNT.
|
|
1578 If COUNT is negative, shifting is actually to the right.
|
|
1579 In this case, the sign bit is duplicated.
|
20
|
1580 */
|
|
1581 (value, count))
|
0
|
1582 {
|
|
1583 CHECK_INT_COERCE_CHAR (value);
|
|
1584 CHECK_INT (count);
|
|
1585
|
16
|
1586 return make_int (XINT (count) > 0 ?
|
70
|
1587 XINT (value) << XINT (count) :
|
|
1588 XINT (value) >> -XINT (count));
|
0
|
1589 }
|
|
1590
|
20
|
1591 DEFUN ("lsh", Flsh, 2, 2, 0, /*
|
0
|
1592 Return VALUE with its bits shifted left by COUNT.
|
|
1593 If COUNT is negative, shifting is actually to the right.
|
70
|
1594 In this case, zeros are shifted in on the left.
|
20
|
1595 */
|
|
1596 (value, count))
|
0
|
1597 {
|
|
1598 Lisp_Object val;
|
|
1599
|
|
1600 CHECK_INT_COERCE_CHAR (value);
|
|
1601 CHECK_INT (count);
|
|
1602
|
70
|
1603 {
|
|
1604 int C_count = XINT (count);
|
|
1605 EMACS_UINT C_value = (EMACS_UINT) XUINT (value);
|
|
1606 XSETINT (val, C_count > 0 ? C_value << C_count : C_value >> -C_count);
|
|
1607 }
|
0
|
1608 return val;
|
|
1609 }
|
|
1610
|
20
|
1611 DEFUN ("1+", Fadd1, 1, 1, 0, /*
|
0
|
1612 Return NUMBER plus one. NUMBER may be a number or a marker.
|
70
|
1613 Markers and characters are converted to integers.
|
20
|
1614 */
|
|
1615 (number))
|
0
|
1616 {
|
|
1617 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (number);
|
|
1618
|
|
1619 #ifdef LISP_FLOAT_TYPE
|
|
1620 if (FLOATP (number))
|
|
1621 return (make_float (1.0 + float_data (XFLOAT (number))));
|
|
1622 #endif /* LISP_FLOAT_TYPE */
|
|
1623
|
|
1624 return (make_int (XINT (number) + 1));
|
|
1625 }
|
|
1626
|
20
|
1627 DEFUN ("1-", Fsub1, 1, 1, 0, /*
|
0
|
1628 Return NUMBER minus one. NUMBER may be a number or a marker.
|
70
|
1629 Markers and characters are converted to integers.
|
20
|
1630 */
|
|
1631 (number))
|
0
|
1632 {
|
|
1633 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (number);
|
|
1634
|
|
1635 #ifdef LISP_FLOAT_TYPE
|
|
1636 if (FLOATP (number))
|
|
1637 return (make_float (-1.0 + (float_data (XFLOAT (number)))));
|
|
1638 #endif /* LISP_FLOAT_TYPE */
|
|
1639
|
|
1640 return (make_int (XINT (number) - 1));
|
|
1641 }
|
|
1642
|
20
|
1643 DEFUN ("lognot", Flognot, 1, 1, 0, /*
|
0
|
1644 Return the bitwise complement of NUMBER. NUMBER must be an integer.
|
20
|
1645 */
|
|
1646 (number))
|
0
|
1647 {
|
|
1648 CHECK_INT (number);
|
|
1649 return (make_int (~XINT (number)));
|
|
1650 }
|
|
1651
|
|
1652
|
|
1653 /************************************************************************/
|
|
1654 /* weak lists */
|
|
1655 /************************************************************************/
|
|
1656
|
|
1657 /* A weak list is like a normal list except that elements automatically
|
|
1658 disappear when no longer in use, i.e. when no longer GC-protected.
|
|
1659 The basic idea is that we don't mark the elements during GC, but
|
|
1660 wait for them to be marked elsewhere. If they're not marked, we
|
|
1661 remove them. This is analogous to weak hashtables; see the explanation
|
|
1662 there for more info. */
|
|
1663
|
|
1664 static Lisp_Object mark_weak_list (Lisp_Object, void (*) (Lisp_Object));
|
|
1665 static void print_weak_list (Lisp_Object, Lisp_Object, int);
|
|
1666 static int weak_list_equal (Lisp_Object, Lisp_Object, int depth);
|
|
1667 static unsigned long weak_list_hash (Lisp_Object obj, int depth);
|
|
1668 DEFINE_LRECORD_IMPLEMENTATION ("weak-list", weak_list,
|
|
1669 mark_weak_list, print_weak_list,
|
|
1670 0, weak_list_equal, weak_list_hash,
|
|
1671 struct weak_list);
|
|
1672
|
|
1673 static Lisp_Object Vall_weak_lists; /* Gemarke es nicht!!! */
|
|
1674
|
|
1675 static Lisp_Object encode_weak_list_type (enum weak_list_type type);
|
|
1676
|
|
1677 static Lisp_Object
|
|
1678 mark_weak_list (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
1679 {
|
|
1680 return Qnil; /* nichts ist gemarkt */
|
|
1681 }
|
|
1682
|
|
1683 static void
|
|
1684 print_weak_list (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1685 {
|
|
1686 if (print_readably)
|
|
1687 error ("printing unreadable object #<weak-list>");
|
|
1688
|
|
1689 write_c_string ("#<weak-list ", printcharfun);
|
|
1690 print_internal (encode_weak_list_type (XWEAK_LIST (obj)->type),
|
|
1691 printcharfun, 0);
|
|
1692 write_c_string (" ", printcharfun);
|
|
1693 print_internal (XWEAK_LIST (obj)->list, printcharfun, escapeflag);
|
|
1694 write_c_string (">", printcharfun);
|
|
1695 }
|
|
1696
|
|
1697 static int
|
|
1698 weak_list_equal (Lisp_Object o1, Lisp_Object o2, int depth)
|
|
1699 {
|
|
1700 struct weak_list *w1 = XWEAK_LIST (o1);
|
|
1701 struct weak_list *w2 = XWEAK_LIST (o2);
|
|
1702
|
70
|
1703 return (w1->type == w2->type) &&
|
|
1704 internal_equal (w1->list, w2->list, depth + 1);
|
0
|
1705 }
|
|
1706
|
|
1707 static unsigned long
|
|
1708 weak_list_hash (Lisp_Object obj, int depth)
|
|
1709 {
|
|
1710 struct weak_list *w = XWEAK_LIST (obj);
|
|
1711
|
|
1712 return HASH2 ((unsigned long) w->type,
|
|
1713 internal_hash (w->list, depth + 1));
|
|
1714 }
|
|
1715
|
|
1716 Lisp_Object
|
|
1717 make_weak_list (enum weak_list_type type)
|
|
1718 {
|
|
1719 Lisp_Object result = Qnil;
|
|
1720
|
|
1721 struct weak_list *wl =
|
|
1722 alloc_lcrecord (sizeof (struct weak_list), lrecord_weak_list);
|
|
1723 wl->list = Qnil;
|
|
1724 wl->type = type;
|
|
1725 XSETWEAK_LIST (result, wl);
|
|
1726 wl->next_weak = Vall_weak_lists;
|
|
1727 Vall_weak_lists = result;
|
|
1728 return result;
|
|
1729 }
|
|
1730
|
|
1731 /*
|
|
1732 -- we do not mark the list elements (either the elements themselves
|
|
1733 or the cons cells that hold them) in the normal marking phase.
|
|
1734 -- at the end of marking, we go through all weak lists that are
|
|
1735 marked, and mark the cons cells that hold all marked
|
|
1736 objects, and possibly parts of the objects themselves.
|
|
1737 (See alloc.c, "after-mark".)
|
|
1738 -- after that, we prune away all the cons cells that are not marked.
|
|
1739
|
|
1740 WARNING WARNING WARNING WARNING WARNING:
|
|
1741
|
|
1742 The code in the following two functions is *unbelievably* tricky.
|
|
1743 Don't mess with it. You'll be sorry.
|
|
1744
|
|
1745 Linked lists just majorly suck, d'ya know?
|
|
1746 */
|
|
1747
|
|
1748 int
|
|
1749 finish_marking_weak_lists (int (*obj_marked_p) (Lisp_Object),
|
|
1750 void (*markobj) (Lisp_Object))
|
|
1751 {
|
|
1752 Lisp_Object rest;
|
|
1753 int did_mark = 0;
|
|
1754
|
|
1755 for (rest = Vall_weak_lists;
|
|
1756 !GC_NILP (rest);
|
|
1757 rest = XWEAK_LIST (rest)->next_weak)
|
|
1758 {
|
|
1759 Lisp_Object rest2;
|
|
1760 enum weak_list_type type = XWEAK_LIST (rest)->type;
|
|
1761
|
|
1762 if (! ((*obj_marked_p) (rest)))
|
|
1763 /* The weak list is probably garbage. Ignore it. */
|
|
1764 continue;
|
|
1765
|
|
1766 for (rest2 = XWEAK_LIST (rest)->list;
|
|
1767 /* We need to be trickier since we're inside of GC;
|
|
1768 use CONSP instead of !NILP in case of user-visible
|
|
1769 imperfect lists */
|
|
1770 GC_CONSP (rest2);
|
|
1771 rest2 = XCDR (rest2))
|
|
1772 {
|
|
1773 Lisp_Object elem;
|
|
1774 /* If the element is "marked" (meaning depends on the type
|
|
1775 of weak list), we need to mark the cons containing the
|
|
1776 element, and maybe the element itself (if only some part
|
|
1777 was already marked). */
|
|
1778 int need_to_mark_cons = 0;
|
|
1779 int need_to_mark_elem = 0;
|
|
1780
|
|
1781 /* If a cons is already marked, then its car is already marked
|
|
1782 (either because of an external pointer or because of
|
|
1783 a previous call to this function), and likewise for all
|
|
1784 the rest of the elements in the list, so we can stop now. */
|
|
1785 if ((*obj_marked_p) (rest2))
|
|
1786 break;
|
|
1787
|
|
1788 elem = XCAR (rest2);
|
|
1789
|
|
1790 switch (type)
|
|
1791 {
|
|
1792 case WEAK_LIST_SIMPLE:
|
|
1793 if ((*obj_marked_p) (elem))
|
|
1794 need_to_mark_cons = 1;
|
|
1795 break;
|
|
1796
|
|
1797 case WEAK_LIST_ASSOC:
|
|
1798 if (!GC_CONSP (elem))
|
|
1799 {
|
|
1800 /* just leave bogus elements there */
|
|
1801 need_to_mark_cons = 1;
|
|
1802 need_to_mark_elem = 1;
|
|
1803 }
|
|
1804 else if ((*obj_marked_p) (XCAR (elem)) &&
|
|
1805 (*obj_marked_p) (XCDR (elem)))
|
|
1806 {
|
|
1807 need_to_mark_cons = 1;
|
|
1808 /* We still need to mark elem, because it's
|
|
1809 probably not marked. */
|
|
1810 need_to_mark_elem = 1;
|
|
1811 }
|
|
1812 break;
|
|
1813
|
|
1814 case WEAK_LIST_KEY_ASSOC:
|
|
1815 if (!GC_CONSP (elem))
|
|
1816 {
|
|
1817 /* just leave bogus elements there */
|
|
1818 need_to_mark_cons = 1;
|
|
1819 need_to_mark_elem = 1;
|
|
1820 }
|
|
1821 else if ((*obj_marked_p) (XCAR (elem)))
|
|
1822 {
|
|
1823 need_to_mark_cons = 1;
|
|
1824 /* We still need to mark elem and XCDR (elem);
|
|
1825 marking elem does both */
|
|
1826 need_to_mark_elem = 1;
|
|
1827 }
|
|
1828 break;
|
|
1829
|
|
1830 case WEAK_LIST_VALUE_ASSOC:
|
|
1831 if (!GC_CONSP (elem))
|
|
1832 {
|
|
1833 /* just leave bogus elements there */
|
|
1834 need_to_mark_cons = 1;
|
|
1835 need_to_mark_elem = 1;
|
|
1836 }
|
|
1837 else if ((*obj_marked_p) (XCDR (elem)))
|
|
1838 {
|
|
1839 need_to_mark_cons = 1;
|
|
1840 /* We still need to mark elem and XCAR (elem);
|
|
1841 marking elem does both */
|
|
1842 need_to_mark_elem = 1;
|
|
1843 }
|
|
1844 break;
|
|
1845
|
|
1846 default:
|
|
1847 abort ();
|
|
1848 }
|
|
1849
|
|
1850 if (need_to_mark_elem && ! (*obj_marked_p) (elem))
|
|
1851 {
|
|
1852 (*markobj) (elem);
|
|
1853 did_mark = 1;
|
|
1854 }
|
|
1855
|
|
1856 /* We also need to mark the cons that holds the elem or
|
|
1857 assoc-pair. We do *not* want to call (markobj) here
|
|
1858 because that will mark the entire list; we just want to
|
|
1859 mark the cons itself.
|
|
1860 */
|
|
1861 if (need_to_mark_cons)
|
|
1862 {
|
|
1863 struct Lisp_Cons *ptr = XCONS (rest2);
|
|
1864 if (!CONS_MARKED_P (ptr))
|
|
1865 {
|
|
1866 MARK_CONS (ptr);
|
|
1867 did_mark = 1;
|
|
1868 }
|
|
1869 }
|
|
1870 }
|
|
1871
|
|
1872 /* In case of imperfect list, need to mark the final cons
|
|
1873 because we're not removing it */
|
|
1874 if (!GC_NILP (rest2) && ! (obj_marked_p) (rest2))
|
|
1875 {
|
|
1876 (markobj) (rest2);
|
|
1877 did_mark = 1;
|
|
1878 }
|
|
1879 }
|
|
1880
|
|
1881 return did_mark;
|
|
1882 }
|
|
1883
|
|
1884 void
|
|
1885 prune_weak_lists (int (*obj_marked_p) (Lisp_Object))
|
|
1886 {
|
|
1887 Lisp_Object rest, prev = Qnil;
|
|
1888
|
|
1889 for (rest = Vall_weak_lists;
|
|
1890 !GC_NILP (rest);
|
|
1891 rest = XWEAK_LIST (rest)->next_weak)
|
|
1892 {
|
|
1893 if (! ((*obj_marked_p) (rest)))
|
|
1894 {
|
|
1895 /* This weak list itself is garbage. Remove it from the list. */
|
|
1896 if (GC_NILP (prev))
|
|
1897 Vall_weak_lists = XWEAK_LIST (rest)->next_weak;
|
|
1898 else
|
|
1899 XWEAK_LIST (prev)->next_weak =
|
|
1900 XWEAK_LIST (rest)->next_weak;
|
|
1901 }
|
|
1902 else
|
|
1903 {
|
|
1904 Lisp_Object rest2, prev2 = Qnil;
|
|
1905 Lisp_Object tortoise;
|
|
1906 int go_tortoise = 0;
|
|
1907
|
|
1908 for (rest2 = XWEAK_LIST (rest)->list, tortoise = rest2;
|
|
1909 /* We need to be trickier since we're inside of GC;
|
|
1910 use CONSP instead of !NILP in case of user-visible
|
|
1911 imperfect lists */
|
|
1912 GC_CONSP (rest2);)
|
|
1913 {
|
|
1914 /* It suffices to check the cons for marking,
|
|
1915 regardless of the type of weak list:
|
|
1916
|
|
1917 -- if the cons is pointed to somewhere else,
|
|
1918 then it should stay around and will be marked.
|
|
1919 -- otherwise, if it should stay around, it will
|
|
1920 have been marked in finish_marking_weak_lists().
|
|
1921 -- otherwise, it's not marked and should disappear.
|
|
1922 */
|
|
1923 if (!(*obj_marked_p) (rest2))
|
|
1924 {
|
|
1925 /* bye bye :-( */
|
|
1926 if (GC_NILP (prev2))
|
|
1927 XWEAK_LIST (rest)->list = XCDR (rest2);
|
|
1928 else
|
|
1929 XCDR (prev2) = XCDR (rest2);
|
|
1930 rest2 = XCDR (rest2);
|
|
1931 /* Ouch. Circularity checking is even trickier
|
|
1932 than I thought. When we cut out a link
|
|
1933 like this, we can't advance the turtle or
|
|
1934 it'll catch up to us. Imagine that we're
|
|
1935 standing on floor tiles and moving forward --
|
|
1936 what we just did here is as if the floor
|
|
1937 tile under us just disappeared and all the
|
|
1938 ones ahead of us slid one tile towards us.
|
|
1939 In other words, we didn't move at all;
|
|
1940 if the tortoise was one step behind us
|
|
1941 previously, it still is, and therefore
|
|
1942 it must not move. */
|
|
1943 }
|
|
1944 else
|
|
1945 {
|
|
1946 prev2 = rest2;
|
|
1947
|
|
1948 /* Implementing circularity checking is trickier here
|
|
1949 than in other places because we have to guarantee
|
|
1950 that we've processed all elements before exiting
|
|
1951 due to a circularity. (In most places, an error
|
|
1952 is issued upon encountering a circularity, so it
|
|
1953 doesn't really matter if all elements are processed.)
|
|
1954 The idea is that we process along with the hare
|
|
1955 rather than the tortoise. If at any point in
|
|
1956 our forward process we encounter the tortoise,
|
|
1957 we must have already visited the spot, so we exit.
|
|
1958 (If we process with the tortoise, we can fail to
|
|
1959 process cases where a cons points to itself, or
|
|
1960 where cons A points to cons B, which points to
|
|
1961 cons A.) */
|
|
1962
|
|
1963 rest2 = XCDR (rest2);
|
|
1964 if (go_tortoise)
|
|
1965 tortoise = XCDR (tortoise);
|
|
1966 go_tortoise = !go_tortoise;
|
|
1967 if (GC_EQ (rest2, tortoise))
|
|
1968 break;
|
|
1969 }
|
|
1970 }
|
|
1971
|
|
1972 prev = rest;
|
|
1973 }
|
|
1974 }
|
|
1975 }
|
|
1976
|
|
1977 static enum weak_list_type
|
|
1978 decode_weak_list_type (Lisp_Object symbol)
|
|
1979 {
|
|
1980 CHECK_SYMBOL (symbol);
|
16
|
1981 if (EQ (symbol, Qsimple)) return WEAK_LIST_SIMPLE;
|
|
1982 if (EQ (symbol, Qassoc)) return WEAK_LIST_ASSOC;
|
70
|
1983 if (EQ (symbol, Qold_assoc)) return WEAK_LIST_ASSOC; /* EBOLA ALERT! */
|
16
|
1984 if (EQ (symbol, Qkey_assoc)) return WEAK_LIST_KEY_ASSOC;
|
|
1985 if (EQ (symbol, Qvalue_assoc)) return WEAK_LIST_VALUE_ASSOC;
|
0
|
1986
|
|
1987 signal_simple_error ("Invalid weak list type", symbol);
|
|
1988 return WEAK_LIST_SIMPLE; /* not reached */
|
|
1989 }
|
|
1990
|
|
1991 static Lisp_Object
|
|
1992 encode_weak_list_type (enum weak_list_type type)
|
|
1993 {
|
|
1994 switch (type)
|
|
1995 {
|
16
|
1996 case WEAK_LIST_SIMPLE: return Qsimple;
|
|
1997 case WEAK_LIST_ASSOC: return Qassoc;
|
|
1998 case WEAK_LIST_KEY_ASSOC: return Qkey_assoc;
|
|
1999 case WEAK_LIST_VALUE_ASSOC: return Qvalue_assoc;
|
0
|
2000 default:
|
|
2001 abort ();
|
|
2002 }
|
|
2003
|
16
|
2004 return Qnil; /* not reached */
|
0
|
2005 }
|
|
2006
|
20
|
2007 DEFUN ("weak-list-p", Fweak_list_p, 1, 1, 0, /*
|
0
|
2008 Return non-nil if OBJECT is a weak list.
|
20
|
2009 */
|
|
2010 (object))
|
0
|
2011 {
|
|
2012 return WEAK_LISTP (object) ? Qt : Qnil;
|
|
2013 }
|
|
2014
|
20
|
2015 DEFUN ("make-weak-list", Fmake_weak_list, 0, 1, 0, /*
|
0
|
2016 Create a new weak list.
|
|
2017 A weak list object is an object that contains a list. This list behaves
|
|
2018 like any other list except that its elements do not count towards
|
|
2019 garbage collection -- if the only pointer to an object in inside a weak
|
|
2020 list (other than pointers in similar objects such as weak hash tables),
|
|
2021 the object is garbage collected and automatically removed from the list.
|
|
2022 This is used internally, for example, to manage the list holding the
|
|
2023 children of an extent -- an extent that is unused but has a parent will
|
|
2024 still be reclaimed, and will automatically be removed from its parent's
|
|
2025 list of children.
|
|
2026
|
|
2027 Optional argument TYPE specifies the type of the weak list, and defaults
|
|
2028 to `simple'. Recognized types are
|
|
2029
|
|
2030 `simple' Objects in the list disappear if not pointed to.
|
|
2031 `assoc' Objects in the list disappear if they are conses
|
|
2032 and either the car or the cdr of the cons is not
|
|
2033 pointed to.
|
|
2034 `key-assoc' Objects in the list disappear if they are conses
|
|
2035 and the car is not pointed to.
|
|
2036 `value-assoc' Objects in the list disappear if they are conses
|
|
2037 and the cdr is not pointed to.
|
20
|
2038 */
|
|
2039 (type))
|
0
|
2040 {
|
|
2041 if (NILP (type))
|
|
2042 type = Qsimple;
|
|
2043
|
|
2044 return make_weak_list (decode_weak_list_type (type));
|
|
2045 }
|
|
2046
|
20
|
2047 DEFUN ("weak-list-type", Fweak_list_type, 1, 1, 0, /*
|
0
|
2048 Return the type of the given weak-list object.
|
20
|
2049 */
|
|
2050 (weak))
|
0
|
2051 {
|
|
2052 CHECK_WEAK_LIST (weak);
|
|
2053 return encode_weak_list_type (XWEAK_LIST (weak)->type);
|
|
2054 }
|
|
2055
|
20
|
2056 DEFUN ("weak-list-list", Fweak_list_list, 1, 1, 0, /*
|
0
|
2057 Return the list contained in a weak-list object.
|
20
|
2058 */
|
|
2059 (weak))
|
0
|
2060 {
|
|
2061 CHECK_WEAK_LIST (weak);
|
|
2062 return XWEAK_LIST_LIST (weak);
|
|
2063 }
|
|
2064
|
20
|
2065 DEFUN ("set-weak-list-list", Fset_weak_list_list, 2, 2, 0, /*
|
0
|
2066 Change the list contained in a weak-list object.
|
20
|
2067 */
|
|
2068 (weak, new_list))
|
0
|
2069 {
|
|
2070 CHECK_WEAK_LIST (weak);
|
|
2071 XWEAK_LIST_LIST (weak) = new_list;
|
|
2072 return new_list;
|
|
2073 }
|
|
2074
|
|
2075
|
|
2076 /************************************************************************/
|
|
2077 /* initialization */
|
|
2078 /************************************************************************/
|
|
2079
|
|
2080 static SIGTYPE
|
|
2081 arith_error (int signo)
|
|
2082 {
|
|
2083 EMACS_REESTABLISH_SIGNAL (signo, arith_error);
|
|
2084 EMACS_UNBLOCK_SIGNAL (signo);
|
|
2085 signal_error (Qarith_error, Qnil);
|
|
2086 }
|
|
2087
|
|
2088 void
|
|
2089 init_data_very_early (void)
|
|
2090 {
|
|
2091 /* Don't do this if just dumping out.
|
|
2092 We don't want to call `signal' in this case
|
|
2093 so that we don't have trouble with dumping
|
|
2094 signal-delivering routines in an inconsistent state. */
|
|
2095 #ifndef CANNOT_DUMP
|
|
2096 if (!initialized)
|
|
2097 return;
|
|
2098 #endif /* CANNOT_DUMP */
|
|
2099 signal (SIGFPE, arith_error);
|
|
2100 #ifdef uts
|
|
2101 signal (SIGEMT, arith_error);
|
|
2102 #endif /* uts */
|
|
2103 }
|
|
2104
|
|
2105 void
|
|
2106 init_errors_once_early (void)
|
|
2107 {
|
|
2108 defsymbol (&Qerror_conditions, "error-conditions");
|
|
2109 defsymbol (&Qerror_message, "error-message");
|
|
2110
|
|
2111 /* We declare the errors here because some other deferrors depend
|
|
2112 on some of the errors below. */
|
|
2113
|
|
2114 /* ERROR is used as a signaler for random errors for which nothing
|
|
2115 else is right */
|
|
2116
|
|
2117 deferror (&Qerror, "error", "error", Qnil);
|
|
2118 deferror (&Qquit, "quit", "Quit", Qnil);
|
|
2119
|
|
2120 deferror (&Qwrong_type_argument, "wrong-type-argument",
|
|
2121 "Wrong type argument", Qerror);
|
|
2122 deferror (&Qargs_out_of_range, "args-out-of-range", "Args out of range",
|
|
2123 Qerror);
|
|
2124 deferror (&Qvoid_function, "void-function",
|
|
2125 "Symbol's function definition is void", Qerror);
|
|
2126 deferror (&Qcyclic_function_indirection, "cyclic-function-indirection",
|
|
2127 "Symbol's chain of function indirections contains a loop", Qerror);
|
|
2128 deferror (&Qvoid_variable, "void-variable",
|
|
2129 "Symbol's value as variable is void", Qerror);
|
|
2130 deferror (&Qcyclic_variable_indirection, "cyclic-variable-indirection",
|
|
2131 "Symbol's chain of variable indirections contains a loop", Qerror);
|
|
2132 deferror (&Qsetting_constant, "setting-constant",
|
|
2133 "Attempt to set a constant symbol", Qerror);
|
|
2134 deferror (&Qinvalid_read_syntax, "invalid-read-syntax",
|
|
2135 "Invalid read syntax", Qerror);
|
|
2136 deferror (&Qmalformed_list, "malformed-list",
|
|
2137 "Malformed list", Qerror);
|
|
2138 deferror (&Qmalformed_property_list, "malformed-property-list",
|
|
2139 "Malformed property list", Qerror);
|
|
2140 deferror (&Qcircular_list, "circular-list",
|
|
2141 "Circular list", Qerror);
|
|
2142 deferror (&Qcircular_property_list, "circular-property-list",
|
|
2143 "Circular property list", Qerror);
|
|
2144 deferror (&Qinvalid_function, "invalid-function", "Invalid function",
|
|
2145 Qerror);
|
|
2146 deferror (&Qwrong_number_of_arguments, "wrong-number-of-arguments",
|
|
2147 "Wrong number of arguments", Qerror);
|
|
2148 deferror (&Qno_catch, "no-catch", "No catch for tag",
|
|
2149 Qerror);
|
|
2150 deferror (&Qbeginning_of_buffer, "beginning-of-buffer",
|
|
2151 "Beginning of buffer", Qerror);
|
|
2152 deferror (&Qend_of_buffer, "end-of-buffer", "End of buffer", Qerror);
|
|
2153 deferror (&Qbuffer_read_only, "buffer-read-only", "Buffer is read-only",
|
|
2154 Qerror);
|
|
2155
|
|
2156 deferror (&Qio_error, "io-error", "IO Error", Qerror);
|
|
2157 deferror (&Qend_of_file, "end-of-file", "End of stream", Qio_error);
|
|
2158
|
|
2159 deferror (&Qarith_error, "arith-error", "Arithmetic error", Qerror);
|
|
2160 deferror (&Qrange_error, "range-error", "Arithmetic range error",
|
|
2161 Qarith_error);
|
|
2162 deferror (&Qdomain_error, "domain-error", "Arithmetic domain error",
|
|
2163 Qarith_error);
|
|
2164 deferror (&Qsingularity_error, "singularity-error",
|
|
2165 "Arithmetic singularity error", Qdomain_error);
|
|
2166 deferror (&Qoverflow_error, "overflow-error",
|
|
2167 "Arithmetic overflow error", Qdomain_error);
|
|
2168 deferror (&Qunderflow_error, "underflow-error",
|
|
2169 "Arithmetic underflow error", Qdomain_error);
|
|
2170 }
|
|
2171
|
|
2172 void
|
|
2173 syms_of_data (void)
|
|
2174 {
|
|
2175 defsymbol (&Qcons, "cons");
|
|
2176 defsymbol (&Qkeyword, "keyword");
|
|
2177 /* Qstring, Qinteger, Qsymbol, Qvector defined in general.c */
|
|
2178
|
|
2179 defsymbol (&Qquote, "quote");
|
|
2180 defsymbol (&Qlambda, "lambda");
|
|
2181 defsymbol (&Qsignal, "signal");
|
|
2182 defsymbol (&Qtop_level, "top-level");
|
|
2183 defsymbol (&Qignore, "ignore");
|
|
2184
|
|
2185 defsymbol (&Qlistp, "listp");
|
|
2186 defsymbol (&Qconsp, "consp");
|
|
2187 defsymbol (&Qsubrp, "subrp");
|
|
2188 defsymbol (&Qsymbolp, "symbolp");
|
|
2189 defsymbol (&Qkeywordp, "keywordp");
|
|
2190 defsymbol (&Qintegerp, "integerp");
|
|
2191 defsymbol (&Qcharacterp, "characterp");
|
|
2192 defsymbol (&Qnatnump, "natnump");
|
|
2193 defsymbol (&Qstringp, "stringp");
|
|
2194 defsymbol (&Qarrayp, "arrayp");
|
|
2195 defsymbol (&Qsequencep, "sequencep");
|
|
2196 defsymbol (&Qbufferp, "bufferp");
|
|
2197 defsymbol (&Qbitp, "bitp");
|
|
2198 defsymbol (&Qbit_vectorp, "bit-vector-p");
|
|
2199 defsymbol (&Qvectorp, "vectorp");
|
|
2200 defsymbol (&Qcompiled_functionp, "compiled-function-p");
|
|
2201 defsymbol (&Qchar_or_string_p, "char-or-string-p");
|
|
2202 defsymbol (&Qmarkerp, "markerp");
|
|
2203 defsymbol (&Qinteger_or_marker_p, "integer-or-marker-p");
|
70
|
2204 defsymbol (&Qinteger_or_char_p, "integer-or-char-p");
|
|
2205 defsymbol (&Qinteger_char_or_marker_p, "integer-char-or-marker-p");
|
0
|
2206
|
|
2207 #ifdef LISP_FLOAT_TYPE
|
|
2208 defsymbol (&Qfloatp, "floatp");
|
|
2209 #endif /* LISP_FLOAT_TYPE */
|
|
2210 defsymbol (&Qnumberp, "numberp");
|
|
2211 defsymbol (&Qnumber_or_marker_p, "number-or-marker-p");
|
70
|
2212 defsymbol (&Qnumber_char_or_marker_p, "number-char-or-marker-p");
|
0
|
2213
|
|
2214 defsymbol (&Qcdr, "cdr");
|
|
2215
|
|
2216 defsymbol (&Qweak_listp, "weak-list-p");
|
|
2217
|
20
|
2218 DEFSUBR (Fwrong_type_argument);
|
0
|
2219
|
20
|
2220 DEFSUBR (Feq);
|
70
|
2221 DEFSUBR (Fold_eq);
|
20
|
2222 DEFSUBR (Fnull);
|
|
2223 DEFSUBR (Flistp);
|
|
2224 DEFSUBR (Fnlistp);
|
|
2225 DEFSUBR (Fconsp);
|
|
2226 DEFSUBR (Fatom);
|
|
2227 DEFSUBR (Fchar_or_string_p);
|
|
2228 DEFSUBR (Fcharacterp);
|
70
|
2229 DEFSUBR (Fchar_int_p);
|
104
|
2230 DEFSUBR (Fchar_to_int);
|
|
2231 DEFSUBR (Fint_to_char);
|
70
|
2232 DEFSUBR (Fchar_or_char_int_p);
|
20
|
2233 DEFSUBR (Fintegerp);
|
|
2234 DEFSUBR (Finteger_or_marker_p);
|
70
|
2235 DEFSUBR (Finteger_or_char_p);
|
|
2236 DEFSUBR (Finteger_char_or_marker_p);
|
20
|
2237 DEFSUBR (Fnumberp);
|
|
2238 DEFSUBR (Fnumber_or_marker_p);
|
70
|
2239 DEFSUBR (Fnumber_char_or_marker_p);
|
0
|
2240 #ifdef LISP_FLOAT_TYPE
|
20
|
2241 DEFSUBR (Ffloatp);
|
0
|
2242 #endif /* LISP_FLOAT_TYPE */
|
20
|
2243 DEFSUBR (Fnatnump);
|
|
2244 DEFSUBR (Fsymbolp);
|
|
2245 DEFSUBR (Fkeywordp);
|
|
2246 DEFSUBR (Fstringp);
|
|
2247 DEFSUBR (Fvectorp);
|
|
2248 DEFSUBR (Fbitp);
|
|
2249 DEFSUBR (Fbit_vector_p);
|
|
2250 DEFSUBR (Farrayp);
|
|
2251 DEFSUBR (Fsequencep);
|
|
2252 DEFSUBR (Fmarkerp);
|
|
2253 DEFSUBR (Fsubrp);
|
|
2254 DEFSUBR (Fsubr_min_args);
|
|
2255 DEFSUBR (Fsubr_max_args);
|
|
2256 DEFSUBR (Fcompiled_function_p);
|
|
2257 DEFSUBR (Ftype_of);
|
|
2258 DEFSUBR (Fcar);
|
|
2259 DEFSUBR (Fcdr);
|
|
2260 DEFSUBR (Fcar_safe);
|
|
2261 DEFSUBR (Fcdr_safe);
|
|
2262 DEFSUBR (Fsetcar);
|
|
2263 DEFSUBR (Fsetcdr);
|
|
2264 DEFSUBR (Findirect_function);
|
|
2265 DEFSUBR (Faref);
|
|
2266 DEFSUBR (Faset);
|
0
|
2267
|
20
|
2268 DEFSUBR (Fcompiled_function_instructions);
|
|
2269 DEFSUBR (Fcompiled_function_constants);
|
|
2270 DEFSUBR (Fcompiled_function_stack_depth);
|
|
2271 DEFSUBR (Fcompiled_function_arglist);
|
|
2272 DEFSUBR (Fcompiled_function_interactive);
|
|
2273 DEFSUBR (Fcompiled_function_doc_string);
|
|
2274 DEFSUBR (Fcompiled_function_domain);
|
0
|
2275 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
20
|
2276 DEFSUBR (Fcompiled_function_annotation);
|
0
|
2277 #endif
|
|
2278
|
20
|
2279 DEFSUBR (Fnumber_to_string);
|
|
2280 DEFSUBR (Fstring_to_number);
|
|
2281 DEFSUBR (Feqlsign);
|
|
2282 DEFSUBR (Flss);
|
|
2283 DEFSUBR (Fgtr);
|
|
2284 DEFSUBR (Fleq);
|
|
2285 DEFSUBR (Fgeq);
|
|
2286 DEFSUBR (Fneq);
|
|
2287 DEFSUBR (Fzerop);
|
|
2288 DEFSUBR (Fplus);
|
|
2289 DEFSUBR (Fminus);
|
|
2290 DEFSUBR (Ftimes);
|
|
2291 DEFSUBR (Fquo);
|
|
2292 DEFSUBR (Frem);
|
|
2293 DEFSUBR (Fmod);
|
|
2294 DEFSUBR (Fmax);
|
|
2295 DEFSUBR (Fmin);
|
|
2296 DEFSUBR (Flogand);
|
|
2297 DEFSUBR (Flogior);
|
|
2298 DEFSUBR (Flogxor);
|
|
2299 DEFSUBR (Flsh);
|
|
2300 DEFSUBR (Fash);
|
|
2301 DEFSUBR (Fadd1);
|
|
2302 DEFSUBR (Fsub1);
|
|
2303 DEFSUBR (Flognot);
|
0
|
2304
|
20
|
2305 DEFSUBR (Fweak_list_p);
|
|
2306 DEFSUBR (Fmake_weak_list);
|
|
2307 DEFSUBR (Fweak_list_type);
|
|
2308 DEFSUBR (Fweak_list_list);
|
|
2309 DEFSUBR (Fset_weak_list_list);
|
0
|
2310 }
|
|
2311
|
|
2312 void
|
|
2313 vars_of_data (void)
|
|
2314 {
|
|
2315 /* This must not be staticpro'd */
|
|
2316 Vall_weak_lists = Qnil;
|
70
|
2317
|
|
2318 #ifdef DEBUG_XEMACS
|
|
2319 DEFVAR_INT ("debug-issue-ebola-notices", &debug_issue_ebola_notices /*
|
|
2320 If non-nil, note when your code may be suffering from char-int confoundance.
|
|
2321 That is to say, if XEmacs encounters a usage of `eq', `memq', `equal',
|
|
2322 etc. where a int and a char with the same value are being compared,
|
|
2323 it will issue a notice on stderr to this effect, along with a backtrace.
|
|
2324 In such situations, the result would be different in XEmacs 19 versus
|
|
2325 XEmacs 20, and you probably don't want this.
|
|
2326
|
|
2327 Note that in order to see these notices, you have to byte compile your
|
|
2328 code under XEmacs 20 -- any code byte-compiled under XEmacs 19 will
|
|
2329 have its chars and ints all confounded in the byte code, making it
|
|
2330 impossible to accurately determine Ebola infection.
|
|
2331 */ );
|
|
2332
|
|
2333 debug_issue_ebola_notices = 2; /* #### temporary hack */
|
|
2334
|
|
2335 DEFVAR_INT ("debug-ebola-backtrace-length",
|
|
2336 &debug_ebola_backtrace_length /*
|
|
2337 Length (in stack frames) of short backtrace printed out in Ebola notices.
|
|
2338 See `debug-issue-ebola-notices'.
|
|
2339 */ );
|
|
2340 debug_ebola_backtrace_length = 8;
|
|
2341
|
|
2342 #endif /* DEBUG_XEMACS */
|
0
|
2343 }
|