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