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