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