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