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