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