annotate src/data.c @ 329:58bac07dfa74 r21-0-62

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