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