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