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