annotate src/fns.c @ 274:ca9a9ec9c1c1 r21-0b35

Import from CVS: tag r21-0b35
author cvs
date Mon, 13 Aug 2007 10:29:42 +0200
parents c5d627a313b1
children 6330739388db
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 /* Random utility Lisp functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985, 86, 87, 93, 94, 95 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1995, 1996 Ben Wing.
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. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 /* This file has been Mule-ized. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 /* Note: FSF 19.30 has bool vectors. We have bit vectors. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 /* Hacked on for Mule by Ben Wing, December 1994, January 1995. */
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 <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 /* Note on some machines this defines `vector' as a typedef,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 so make sure we don't use that name in this file. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #undef vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #define vector *****
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
39 #ifdef HAVE_UNISTD_H
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
40 #include <unistd.h>
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
41 #endif
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
42
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 #include "bytecode.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 #include "commands.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 #include "device.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 #include "events.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 #include "extents.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 #include "frame.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 #include "systime.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 120
diff changeset
52 /* NOTE: This symbol is also used in lread.c */
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 120
diff changeset
53 #define FEATUREP_SYNTAX
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 120
diff changeset
54
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 Lisp_Object Qstring_lessp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 Lisp_Object Qidentity;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
58 static int internal_old_equal (Lisp_Object, Lisp_Object, int);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 mark_bit_vector (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 {
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
63 return Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 print_bit_vector (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 struct Lisp_Bit_Vector *v = XBIT_VECTOR (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 int len = bit_vector_length (v);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 int last = len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 if (INTP (Vprint_length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 last = min (len, XINT (Vprint_length));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 write_c_string ("#*", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 for (i = 0; i < last; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 if (bit_vector_bit (v, i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 write_c_string ("1", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 write_c_string ("0", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 if (last != len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 write_c_string ("...", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 bit_vector_equal (Lisp_Object o1, Lisp_Object o2, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 struct Lisp_Bit_Vector *v1 = XBIT_VECTOR (o1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 struct Lisp_Bit_Vector *v2 = XBIT_VECTOR (o2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
95 return ((bit_vector_length (v1) == bit_vector_length (v2)) &&
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
96 !memcmp (v1->bits, v2->bits,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
97 BIT_VECTOR_LONG_STORAGE (bit_vector_length (v1)) *
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
98 sizeof (long)));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 static unsigned long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 bit_vector_hash (Lisp_Object obj, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 struct Lisp_Bit_Vector *v = XBIT_VECTOR (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 return HASH2 (bit_vector_length (v),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 memory_hash (v->bits,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 BIT_VECTOR_LONG_STORAGE (bit_vector_length (v)) *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 sizeof (long)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
111 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("bit-vector", bit_vector,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
112 mark_bit_vector, print_bit_vector, 0,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
113 bit_vector_equal, bit_vector_hash,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
114 struct Lisp_Bit_Vector);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
115
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
116 DEFUN ("identity", Fidentity, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 Return the argument unchanged.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
118 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
119 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 return arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 extern long get_random (void);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 extern void seed_random (long arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
127 DEFUN ("random", Frandom, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 Return a pseudo-random number.
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 76
diff changeset
129 All integers representable in Lisp are equally likely.
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 76
diff changeset
130 On most systems, this is 28 bits' worth.
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 76
diff changeset
131 With positive integer argument N, return random number in interval [0,N).
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 With argument t, set the random number seed from the current time and pid.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
133 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
134 (limit))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 EMACS_INT val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 unsigned long denominator;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 if (EQ (limit, Qt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 seed_random (getpid () + time (NULL));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 if (NATNUMP (limit) && !ZEROP (limit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 /* Try to take our random number from the higher bits of VAL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 not the lower, since (says Gentzel) the low bits of `random'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 are less random than the higher ones. We do this by using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 quotient rather than the remainder. At the high end of the RNG
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 it's possible to get a quotient larger than limit; discarding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 these values eliminates the bias that would otherwise appear
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 when using a large limit. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 denominator = ((unsigned long)1 << VALBITS) / XINT (limit);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 val = get_random () / denominator;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 while (val >= XINT (limit));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 val = get_random ();
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
157
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
158 return make_int (val);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 /* Random data-structure functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 #ifdef LOSING_BYTECODE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 /* #### Delete this shit */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 /* Charcount is a misnomer here as we might be dealing with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 length of a vector or list, but emphasizes that we're not dealing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 with Bytecounts in strings */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 static Charcount
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 length_with_bytecode_hack (Lisp_Object seq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 if (!COMPILED_FUNCTIONP (seq))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
174 return XINT (Flength (seq));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 struct Lisp_Compiled_Function *b = XCOMPILED_FUNCTION (seq);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
178
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
179 return (b->flags.interactivep ? COMPILED_INTERACTIVE :
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
180 b->flags.domainp ? COMPILED_DOMAIN :
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
181 COMPILED_DOC_STRING)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
182 + 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 #endif /* LOSING_BYTECODE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 check_losing_bytecode (CONST char *function, Lisp_Object seq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 if (COMPILED_FUNCTIONP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 error_with_frob
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (seq,
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
194 "As of 20.3, `%s' no longer works with compiled-function objects",
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 function);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
198 DEFUN ("length", Flength, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 Return the length of vector, bit vector, list or string SEQUENCE.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
200 */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
201 (sequence))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 retry:
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
204 if (STRINGP (sequence))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
205 return make_int (XSTRING_CHAR_LENGTH (sequence));
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
206 else if (CONSP (sequence))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
208 Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
209 int i = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
210
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
211 EXTERNAL_LIST_LOOP (tail, sequence)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 QUIT;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
214 i++;
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
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
217 return make_int (i);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
219 else if (VECTORP (sequence))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
220 return make_int (XVECTOR_LENGTH (sequence));
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
221 else if (NILP (sequence))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
222 return Qzero;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
223 else if (BIT_VECTORP (sequence))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
224 return make_int (bit_vector_length (XBIT_VECTOR (sequence)));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
227 check_losing_bytecode ("length", sequence);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
228 sequence = wrong_type_argument (Qsequencep, sequence);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 goto retry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 /* This does not check for quits. That is safe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 since it must terminate. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
236 DEFUN ("safe-length", Fsafe_length, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 Return the length of a list, but avoid error or infinite loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 This function never gets an error. If LIST is not really a list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 it returns 0. If LIST is circular, it returns a finite value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 which is at least the number of distinct elements.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
241 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
242 (list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
244 Lisp_Object halftail = list; /* Used to detect circular lists. */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
245 Lisp_Object tail;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 int len = 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 for (tail = list; CONSP (tail); tail = XCDR (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 if (EQ (tail, halftail) && len != 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 len++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 if ((len & 1) == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 halftail = XCDR (halftail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
257 return make_int (len);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 /*** string functions. ***/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
262 DEFUN ("string-equal", Fstring_equal, 2, 2, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
263 Return t if two strings have identical contents.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 Case is significant. Text properties are ignored.
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 223
diff changeset
265 \(Under XEmacs, `equal' also ignores text properties and extents in
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 223
diff changeset
266 strings, but this is not the case under FSF Emacs 19. In FSF Emacs 20
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 223
diff changeset
267 `equal' is the same as in XEmacs, in that respect.)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 Symbols are also allowed; their print names are used instead.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
269 */
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 223
diff changeset
270 (s1, s2))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
272 Bytecount len;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
273 struct Lisp_String *p1, *p2;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 if (SYMBOLP (s1))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
276 p1 = XSYMBOL (s1)->name;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
277 else
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
278 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
279 CHECK_STRING (s1);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
280 p1 = XSTRING (s1);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
281 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
282
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 if (SYMBOLP (s2))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
284 p2 = XSYMBOL (s2)->name;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
285 else
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
286 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
287 CHECK_STRING (s2);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
288 p2 = XSTRING (s2);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
289 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
290
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
291 return (((len = string_length (p1)) == string_length (p2)) &&
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
292 !memcmp (string_data (p1), string_data (p2), len)) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
296 DEFUN ("string-lessp", Fstring_lessp, 2, 2, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
297 Return t if first arg string is less than second in lexicographic order.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
298 If I18N2 support (but not Mule support) was compiled in, ordering is
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
299 determined by the locale. (Case is significant for the default C locale.)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
300 In all other cases, comparison is simply done on a character-by-
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
301 character basis using the numeric value of a character. (Note that
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
302 this may not produce particularly meaningful results under Mule if
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
303 characters from different charsets are being compared.)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
304
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 Symbols are also allowed; their print names are used instead.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
306
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
307 The reason that the I18N2 locale-specific collation is not used under
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
308 Mule is that the locale model of internationalization does not handle
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
309 multiple charsets and thus has no hope of working properly under Mule.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
310 What we really should do is create a collation table over all built-in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
311 charsets. This is extremely difficult to do from scratch, however.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
312
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
313 Unicode is a good first step towards solving this problem. In fact,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
314 it is quite likely that a collation table exists (or will exist) for
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
315 Unicode. When Unicode support is added to XEmacs/Mule, this problem
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
316 may be solved.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
317 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
318 (s1, s2))
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 struct Lisp_String *p1, *p2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 Charcount end, len2;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
322 int i;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 if (SYMBOLP (s1))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
325 p1 = XSYMBOL (s1)->name;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
326 else
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
327 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
328 CHECK_STRING (s1);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
329 p1 = XSTRING (s1);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
330 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
331
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 if (SYMBOLP (s2))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
333 p2 = XSYMBOL (s2)->name;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
334 else
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
335 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
336 CHECK_STRING (s2);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
337 p2 = XSTRING (s2);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
338 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
339
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
340 end = string_char_length (p1);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
341 len2 = string_char_length (p2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 if (end > len2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 end = len2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
345 #if defined (I18N2) && !defined (MULE)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
346 /* There is no hope of this working under Mule. Even if we converted
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
347 the data into an external format so that strcoll() processed it
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
348 properly, it would still not work because strcoll() does not
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
349 handle multiple locales. This is the fundamental flaw in the
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
350 locale model. */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
351 Bytecount bcend = charcount_to_bytecount (string_data (p1), end);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
352 /* Compare strings using collation order of locale. */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
353 /* Need to be tricky to handle embedded nulls. */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
354
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
355 for (i = 0; i < bcend; i += strlen((char *) string_data (p1) + i) + 1)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
356 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
357 int val = strcoll ((char *) string_data (p1) + i,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
358 (char *) string_data (p2) + i);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
359 if (val < 0)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
360 return Qt;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
361 if (val > 0)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
362 return Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
363 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
364 #else /* not I18N2, or MULE */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
365 /* #### It is not really necessary to do this: We could compare
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
366 byte-by-byte and still get a reasonable comparison, since this
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
367 would compare characters with a charset in the same way.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
368 With a little rearrangement of the leading bytes, we could
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
369 make most inter-charset comparisons work out the same, too;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
370 even if some don't, this is not a big deal because inter-charset
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
371 comparisons aren't really well-defined anyway. */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
372 for (i = 0; i < end; i++)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
373 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
374 if (string_char (p1, i) != string_char (p2, i))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
375 return string_char (p1, i) < string_char (p2, i) ? Qt : Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
376 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
377 #endif /* not I18N2, or MULE */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
378 /* Can't do i < len2 because then comparison between "foo" and "foo^@"
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
379 won't work right in I18N2 case */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
380 return end < len2 ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
383 DEFUN ("string-modified-tick", Fstring_modified_tick, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 Return STRING's tick counter, incremented for each change to the string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 Each string has a tick counter which is incremented each time the contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 of the string are changed (e.g. with `aset'). It wraps around occasionally.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
387 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
388 (string))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 struct Lisp_String *s;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 CHECK_STRING (string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 s = XSTRING (string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 if (CONSP (s->plist) && INTP (XCAR (s->plist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 return XCAR (s->plist);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 return Qzero;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 bump_string_modiff (Lisp_Object str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 struct Lisp_String *s = XSTRING (str);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 Lisp_Object *ptr = &s->plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 /* #### remove the `string-translatable' property from the string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 if there is one. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 /* skip over extent info if it's there */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 if (CONSP (*ptr) && EXTENT_INFOP (XCAR (*ptr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ptr = &XCDR (*ptr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 if (CONSP (*ptr) && INTP (XCAR (*ptr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 XSETINT (XCAR (*ptr), 1+XINT (XCAR (*ptr)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 *ptr = Fcons (make_int (1), *ptr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 enum concat_target_type { c_cons, c_string, c_vector, c_bit_vector };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 static Lisp_Object concat (int nargs, Lisp_Object *args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 enum concat_target_type target_type,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 int last_special);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 concat2 (Lisp_Object s1, Lisp_Object s2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 Lisp_Object args[2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 args[0] = s1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 args[1] = s2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 return concat (2, args, c_string, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 concat3 (Lisp_Object s1, Lisp_Object s2, Lisp_Object s3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 Lisp_Object args[3];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 args[0] = s1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 args[1] = s2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 args[2] = s3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 return concat (3, args, c_string, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 vconcat2 (Lisp_Object s1, Lisp_Object s2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 Lisp_Object args[2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 args[0] = s1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 args[1] = s2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 return concat (2, args, c_vector, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 vconcat3 (Lisp_Object s1, Lisp_Object s2, Lisp_Object s3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 Lisp_Object args[3];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 args[0] = s1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 args[1] = s2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 args[2] = s3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 return concat (3, args, c_vector, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
463 DEFUN ("append", Fappend, 0, MANY, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 Concatenate all the arguments and make the result a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 The result is a list whose elements are the elements of all the arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 Each argument may be a list, vector, bit vector, or string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 The last argument is not copied, just used as the tail of the new list.
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 195
diff changeset
468 Also see: `nconc'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
469 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
470 (int nargs, Lisp_Object *args))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 return concat (nargs, args, c_cons, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
475 DEFUN ("concat", Fconcat, 0, MANY, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 Concatenate all the arguments and make the result a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 The result is a string whose elements are the elements of all the arguments.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
478 Each argument may be a string or a list or vector of characters.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 Do not use individual integers as arguments!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 The behavior of `concat' in that case will be changed later!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 If your program passes an integer as an argument to `concat',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 you should change it right away not to do so.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
484 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
485 (int nargs, Lisp_Object *args))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 return concat (nargs, args, c_string, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
490 DEFUN ("vconcat", Fvconcat, 0, MANY, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 Concatenate all the arguments and make the result a vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 The result is a vector whose elements are the elements of all the arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 Each argument may be a list, vector, bit vector, or string.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
494 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
495 (int nargs, Lisp_Object *args))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 return concat (nargs, args, c_vector, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
500 DEFUN ("bvconcat", Fbvconcat, 0, MANY, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 Concatenate all the arguments and make the result a bit vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 The result is a bit vector whose elements are the elements of all the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 arguments. Each argument may be a list, vector, bit vector, or string.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
504 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
505 (int nargs, Lisp_Object *args))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 return concat (nargs, args, c_bit_vector, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
510 DEFUN ("copy-sequence", Fcopy_sequence, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 Return a copy of a list, vector, bit vector or string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 The elements of a list or vector are not copied; they are shared
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 with the original.
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 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 again:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 if (NILP (arg)) return arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 /* We handle conses separately because concat() is big and hairy and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 doesn't handle (copy-sequence '(a b . c)) and it's easier to redo this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 than to fix concat() without worrying about breaking other things.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 if (CONSP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 {
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
525 Lisp_Object head = Fcons (XCAR (arg), XCDR (arg));
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
526 Lisp_Object tail = head;
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
527
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
528 for (arg = XCDR (arg); CONSP (arg); arg = XCDR (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 {
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
530 XCDR (tail) = Fcons (XCAR (arg), XCDR (arg));
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
531 tail = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 return head;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 }
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
536 if (STRINGP (arg)) return concat (1, &arg, c_string, 0);
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
537 if (VECTORP (arg)) return concat (1, &arg, c_vector, 0);
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
538 if (BIT_VECTORP (arg)) return concat (1, &arg, c_bit_vector, 0);
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
539
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
540 check_losing_bytecode ("copy-sequence", arg);
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
541 arg = wrong_type_argument (Qsequencep, arg);
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
542 goto again;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 struct merge_string_extents_struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 Lisp_Object string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 Bytecount entry_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 Bytecount entry_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 concat (int nargs, Lisp_Object *args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 enum concat_target_type target_type,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 int last_special)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 Lisp_Object tail = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 int toindex;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 int argnum;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 Lisp_Object last_tail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 Lisp_Object prev;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 struct merge_string_extents_struct *args_mse = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 Bufbyte *string_result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 Bufbyte *string_result_ptr = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 /* The modus operandi in Emacs is "caller gc-protects args".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 However, concat is called many times in Emacs on freshly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 created stuff. So we help those callers out by protecting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 the args ourselves to save them a lot of temporary-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 grief. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 GCPRO1 (args[0]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 gcpro1.nvars = nargs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 /* #### if the result is a string and any of the strings have a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 for the `string-translatable' property, then concat should also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 concat the args but use the `string-translatable' strings, and store
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 the result in the returned string's `string-translatable' property. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 if (target_type == c_string)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
584 args_mse = alloca_array (struct merge_string_extents_struct, nargs);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 /* In append, the last arg isn't treated like the others */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 if (last_special && nargs > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 nargs--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 last_tail = args[nargs];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 last_tail = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 /* Check and coerce the arguments. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 for (argnum = 0; argnum < nargs; argnum++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 Lisp_Object seq = args[argnum];
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
599 if (LISTP (seq))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 else if (VECTORP (seq) || STRINGP (seq) || BIT_VECTORP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 #ifdef LOSING_BYTECODE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 else if (COMPILED_FUNCTIONP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 /* Urk! We allow this, for "compatibility"... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 else if (INTP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 /* This is too revolting to think about but maintains
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 compatibility with FSF (and lots and lots of old code). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 args[argnum] = Fnumber_to_string (seq);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 check_losing_bytecode ("concat", seq);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 args[argnum] = wrong_type_argument (Qsequencep, seq);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 }
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
617
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 if (args_mse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 if (STRINGP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 args_mse[argnum].string = seq;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 args_mse[argnum].string = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 /* Charcount is a misnomer here as we might be dealing with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 length of a vector or list, but emphasizes that we're not dealing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 with Bytecounts in strings */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 Charcount total_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 for (argnum = 0, total_length = 0; argnum < nargs; argnum++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 #ifdef LOSING_BYTECODE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 Charcount thislen = length_with_bytecode_hack (args[argnum]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 Charcount thislen = XINT (Flength (args[argnum]));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 total_length += thislen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 switch (target_type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 case c_cons:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 if (total_length == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 /* In append, if all but last arg are nil, return last arg */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 RETURN_UNGCPRO (last_tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 val = Fmake_list (make_int (total_length), Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 case c_vector:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 val = make_vector (total_length, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 case c_bit_vector:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 val = make_bit_vector (total_length, Qzero);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 case c_string:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 /* We don't make the string yet because we don't know the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 actual number of bytes. This loop was formerly written
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 to call Fmake_string() here and then call set_string_char()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 for each char. This seems logical enough but is waaaaaaaay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 slow -- set_string_char() has to scan the whole string up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 to the place where the substitution is called for in order
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 to find the place to change, and may have to do some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 realloc()ing in order to make the char fit properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 O(N^2) yuckage. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 val = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 string_result = (Bufbyte *) alloca (total_length * MAX_EMCHAR_LEN);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 string_result_ptr = string_result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 abort ();
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 if (CONSP (val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 tail = val, toindex = -1; /* -1 in toindex is flag we are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 making a list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 toindex = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 prev = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 for (argnum = 0; argnum < nargs; argnum++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 Charcount thisleni = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 Charcount thisindex = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 Lisp_Object seq = args[argnum];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 Bufbyte *string_source_ptr = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 Bufbyte *string_prev_result_ptr = string_result_ptr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 if (!CONSP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 #ifdef LOSING_BYTECODE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 thisleni = length_with_bytecode_hack (seq);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 thisleni = XINT (Flength (seq));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 if (STRINGP (seq))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 10
diff changeset
702 string_source_ptr = XSTRING_DATA (seq);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 Lisp_Object elt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 /* We've come to the end of this arg, so exit. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 if (NILP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 /* Fetch next element of `seq' arg into `elt' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 if (CONSP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
715 elt = XCAR (seq);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
716 seq = XCDR (seq);
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
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 (thisindex >= thisleni)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 if (STRINGP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 elt = make_char (charptr_emchar (string_source_ptr));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 INC_CHARPTR (string_source_ptr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 else if (VECTORP (seq))
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
729 elt = XVECTOR_DATA (seq)[thisindex];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 else if (BIT_VECTORP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 elt = make_int (bit_vector_bit (XBIT_VECTOR (seq),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 thisindex));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 elt = Felt (seq, make_int (thisindex));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 thisindex++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 /* Store into result */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 if (toindex < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 /* toindex negative means we are making a list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 XCAR (tail) = elt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 prev = tail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 tail = XCDR (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 else if (VECTORP (val))
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
747 XVECTOR_DATA (val)[toindex++] = elt;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 else if (BIT_VECTORP (val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 CHECK_BIT (elt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 set_bit_vector_bit (XBIT_VECTOR (val), toindex++, XINT (elt));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 CHECK_CHAR_COERCE_INT (elt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 string_result_ptr += set_charptr_emchar (string_result_ptr,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 XCHAR (elt));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 if (args_mse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 args_mse[argnum].entry_offset =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 string_prev_result_ptr - string_result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 args_mse[argnum].entry_length =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 string_result_ptr - string_prev_result_ptr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 /* Now we finally make the string. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 if (target_type == c_string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 val = make_string (string_result, string_result_ptr - string_result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 for (argnum = 0; argnum < nargs; argnum++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 if (STRINGP (args_mse[argnum].string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 copy_string_extents (val, args_mse[argnum].string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 args_mse[argnum].entry_offset, 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 args_mse[argnum].entry_length);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 }
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 if (!NILP (prev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 XCDR (prev) = last_tail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
785 RETURN_UNGCPRO (val);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
788 DEFUN ("copy-alist", Fcopy_alist, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 Return a copy of ALIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 This is an alist which represents the same mapping from objects to objects,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 but does not share the alist structure with ALIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 The objects mapped (cars and cdrs of elements of the alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 are shared, however.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 Elements of ALIST that are not conses are also shared.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
795 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
796 (alist))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
798 Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
799
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 if (NILP (alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 return alist;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
802 CHECK_CONS (alist);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
803
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 alist = concat (1, &alist, c_cons, 0);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
805 for (tail = alist; CONSP (tail); tail = XCDR (tail))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
807 Lisp_Object car = XCAR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 if (CONSP (car))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
810 XCAR (tail) = Fcons (XCAR (car), XCDR (car));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 return alist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
815 DEFUN ("copy-tree", Fcopy_tree, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 Return a copy of a list and substructures.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 The argument is copied, and any lists contained within it are copied
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 recursively. Circularities and shared substructures are not preserved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 Second arg VECP causes vectors to be copied, too. Strings and bit vectors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 are not copied.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
821 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
822 (arg, vecp))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 if (CONSP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 Lisp_Object rest;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 rest = arg = Fcopy_sequence (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 while (CONSP (rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 Lisp_Object elt = XCAR (rest);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 if (CONSP (elt) || VECTORP (elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 XCAR (rest) = Fcopy_tree (elt, vecp);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 if (VECTORP (XCDR (rest))) /* hack for (a b . [c d]) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 XCDR (rest) = Fcopy_tree (XCDR (rest), vecp);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 rest = XCDR (rest);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 else if (VECTORP (arg) && ! NILP (vecp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
841 int i = XVECTOR_LENGTH (arg);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 int j;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 arg = Fcopy_sequence (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 for (j = 0; j < i; j++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
846 Lisp_Object elt = XVECTOR_DATA (arg) [j];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 if (CONSP (elt) || VECTORP (elt))
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
849 XVECTOR_DATA (arg) [j] = Fcopy_tree (elt, vecp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 return arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
855 DEFUN ("substring", Fsubstring, 2, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 Return a substring of STRING, starting at index FROM and ending before TO.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 TO may be nil or omitted; then the substring runs to the end of STRING.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 If FROM or TO is negative, it counts from the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 Relevant parts of the string-extent-data are copied in the new string.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
860 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
861 (string, from, to))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 Charcount ccfr, ccto;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 Bytecount bfr, bto;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 CHECK_STRING (string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 /* Historically, FROM could not be omitted. Whatever ... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 CHECK_INT (from);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 get_string_range_char (string, from, to, &ccfr, &ccto,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 GB_HISTORICAL_STRING_BEHAVIOR);
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 10
diff changeset
872 bfr = charcount_to_bytecount (XSTRING_DATA (string), ccfr);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 10
diff changeset
873 bto = charcount_to_bytecount (XSTRING_DATA (string), ccto);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 10
diff changeset
874 val = make_string (XSTRING_DATA (string) + bfr, bto - bfr);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 /* Copy any applicable extent information into the new string: */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 copy_string_extents (val, string, 0, bfr, bto - bfr);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
877 return val;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
880 DEFUN ("subseq", Fsubseq, 2, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 Return a subsequence of SEQ, starting at index FROM and ending before TO.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 TO may be nil or omitted; then the subsequence runs to the end of SEQ.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 If FROM or TO is negative, it counts from the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 The resulting subsequence is always the same type as the original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 If SEQ is a string, relevant parts of the string-extent-data are copied
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 in the new string.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
888 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
889 (seq, from, to))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 int len, f, t;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 if (STRINGP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 return Fsubstring (seq, from, to);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
896 if (!LISTP (seq) && !VECTORP (seq) && !BIT_VECTORP (seq))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 check_losing_bytecode ("subseq", seq);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 seq = wrong_type_argument (Qsequencep, seq);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 }
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
901
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 len = XINT (Flength (seq));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 CHECK_INT (from);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 f = XINT (from);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 if (f < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 f = len + f;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 if (NILP (to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 t = len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 else
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_INT (to);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 t = XINT (to);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 if (t < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 t = len + t;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 }
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
916
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 if (!(0 <= f && f <= t && t <= len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 args_out_of_range_3 (seq, make_int (f), make_int (t));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 if (VECTORP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 Lisp_Object result = make_vector (t - f, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 int i;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
924 Lisp_Object *in_elts = XVECTOR_DATA (seq);
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
925 Lisp_Object *out_elts = XVECTOR_DATA (result);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 for (i = f; i < t; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 out_elts[i - f] = in_elts[i];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 if (CONSP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 Lisp_Object result = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 seq = Fnthcdr (make_int (f), seq);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 for (i = f; i < t; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 result = Fcons (Fcar (seq), result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 seq = Fcdr (seq);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 return Fnreverse (result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 /* bit vector */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 Lisp_Object result = make_bit_vector (t - f, Qzero);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 for (i = f; i < t; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 set_bit_vector_bit (XBIT_VECTOR (result), i - f,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 bit_vector_bit (XBIT_VECTOR (seq), i));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
961 DEFUN ("nthcdr", Fnthcdr, 2, 2, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
962 Take cdr N times on LIST, and return the result.
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 (n, list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
966 REGISTER int i;
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
967 REGISTER Lisp_Object tail = list;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
968 CHECK_NATNUM (n);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
969 for (i = XINT (n); i; i--)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 {
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
971 if (CONSP (tail))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
972 tail = XCDR (tail);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
973 else if (NILP (tail))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
974 return Qnil;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
975 else
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
976 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
977 tail = wrong_type_argument (Qlistp, tail);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
978 i++;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
979 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 }
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
981 return tail;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
984 DEFUN ("nth", Fnth, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 Return the Nth element of LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 N counts from zero. If LIST is not that long, nil is returned.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
987 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
988 (n, list))
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 return Fcar (Fnthcdr (n, list));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
993 DEFUN ("elt", Felt, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 Return element of SEQUENCE at index N.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
995 */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
996 (sequence, n))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 retry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 CHECK_INT_COERCE_CHAR (n); /* yuck! */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1000 if (LISTP (sequence))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1002 Lisp_Object tem = Fnthcdr (n, sequence);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 /* #### Utterly, completely, fucking disgusting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 * #### The whole point of "elt" is that it operates on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 * #### sequences, and does error- (bounds-) checking.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 if (CONSP (tem))
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1008 return XCAR (tem);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 #if 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 /* This is The Way It Has Always Been. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 #else
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 272
diff changeset
1014 /* This is The Way Mly and Cltl2 say It Should Be. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1015 args_out_of_range (sequence, n);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1018 else if (STRINGP (sequence)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1019 || VECTORP (sequence)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1020 || BIT_VECTORP (sequence))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1021 return Faref (sequence, n);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 #ifdef LOSING_BYTECODE
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1023 else if (COMPILED_FUNCTIONP (sequence))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 int idx = XINT (n);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 if (idx < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 lose:
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1029 args_out_of_range (sequence, n);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 /* Utter perversity */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1033 struct Lisp_Compiled_Function *b = XCOMPILED_FUNCTION (sequence);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 switch (idx)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 case COMPILED_ARGLIST:
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1037 return b->arglist;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 case COMPILED_BYTECODE:
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1039 return b->bytecodes;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 case COMPILED_CONSTANTS:
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1041 return b->constants;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 case COMPILED_STACK_DEPTH:
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1043 return make_int (b->maxdepth);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 case COMPILED_DOC_STRING:
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1045 return compiled_function_documentation (b);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 case COMPILED_DOMAIN:
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1047 return compiled_function_domain (b);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 case COMPILED_INTERACTIVE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 if (b->flags.interactivep)
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1050 return compiled_function_interactive (b);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 /* if we return nil, can't tell interactive with no args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 from noninteractive. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 goto lose;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 goto lose;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 #endif /* LOSING_BYTECODE */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1062 check_losing_bytecode ("elt", sequence);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1063 sequence = wrong_type_argument (Qsequencep, sequence);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 goto retry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1068 DEFUN ("member", Fmember, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 Return non-nil if ELT is an element of LIST. Comparison done with `equal'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 The value is actually the tail of LIST whose car is ELT.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1071 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1072 (elt, list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1074 REGISTER Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1075 LIST_LOOP (tail, list)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1077 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1078 if (internal_equal (elt, XCAR (tail), 0))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1079 return tail;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1085 DEFUN ("old-member", Fold_member, 2, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1086 Return non-nil if ELT is an element of LIST. Comparison done with `old-equal'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1087 The value is actually the tail of LIST whose car is ELT.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1088 This function is provided only for byte-code compatibility with v19.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1089 Do not use it.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1090 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1091 (elt, list))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1092 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1093 REGISTER Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1094 LIST_LOOP (tail, list)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1095 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1096 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1097 if (internal_old_equal (elt, XCAR (tail), 0))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1098 return tail;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1099 QUIT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1100 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1101 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1102 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1103
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1104 DEFUN ("memq", Fmemq, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 Return non-nil if ELT is an element of LIST. Comparison done with `eq'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 The value is actually the tail of LIST whose car is ELT.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1107 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1108 (elt, list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1110 REGISTER Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1111 LIST_LOOP (tail, list)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1113 REGISTER Lisp_Object tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1114 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1115 if (tem = XCAR (tail), EQ_WITH_EBOLA_NOTICE (elt, tem))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1116 return tail;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1117 QUIT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1118 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1119 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1120 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1121
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1122 DEFUN ("old-memq", Fold_memq, 2, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1123 Return non-nil if ELT is an element of LIST. Comparison done with `old-eq'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1124 The value is actually the tail of LIST whose car is ELT.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1125 This function is provided only for byte-code compatibility with v19.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1126 Do not use it.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1127 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1128 (elt, list))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1129 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1130 REGISTER Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1131 LIST_LOOP (tail, list)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1132 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1133 REGISTER Lisp_Object tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1134 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1135 if (tem = XCAR (tail), HACKEQ_UNSAFE (elt, tem))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1136 return tail;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 memq_no_quit (Lisp_Object elt, Lisp_Object list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1145 REGISTER Lisp_Object tail;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 for (tail = list; CONSP (tail); tail = XCDR (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1148 REGISTER Lisp_Object tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1149 if (tem = XCAR (tail), EQ_WITH_EBOLA_NOTICE (elt, tem))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1150 return tail;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1155 DEFUN ("assoc", Fassoc, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 Return non-nil if KEY is `equal' to the car of an element of LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 The value is actually the element of LIST whose car equals KEY.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1158 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1159 (key, list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 /* This function can GC. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1162 REGISTER Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1163 LIST_LOOP (tail, list)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1165 REGISTER Lisp_Object elt;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1166 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1167 elt = XCAR (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1168 if (CONSP (elt) && internal_equal (XCAR (elt), key, 0))
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 187
diff changeset
1169 return elt;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1175 DEFUN ("old-assoc", Fold_assoc, 2, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1176 Return non-nil if KEY is `old-equal' to the car of an element of LIST.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1177 The value is actually the element of LIST whose car equals KEY.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1178 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1179 (key, list))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1180 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1181 /* This function can GC. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1182 REGISTER Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1183 LIST_LOOP (tail, list)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1184 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1185 REGISTER Lisp_Object elt;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1186 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1187 elt = XCAR (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1188 if (CONSP (elt) && internal_old_equal (XCAR (elt), key, 0))
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 187
diff changeset
1189 return elt;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1190 QUIT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1191 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1192 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1193 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1194
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 assoc_no_quit (Lisp_Object key, Lisp_Object list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 specbind (Qinhibit_quit, Qt);
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
1200 return unbind_to (speccount, Fassoc (key, list));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1203 DEFUN ("assq", Fassq, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 Return non-nil if KEY is `eq' to the car of an element of LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 The value is actually the element of LIST whose car is KEY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 Elements of LIST that are not conses are ignored.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1207 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1208 (key, list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1210 REGISTER Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1211 LIST_LOOP (tail, list)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1213 REGISTER Lisp_Object elt, tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1214 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1215 elt = XCAR (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1216 if (CONSP (elt) && (tem = XCAR (elt), EQ_WITH_EBOLA_NOTICE (key, tem)))
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 187
diff changeset
1217 return elt;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1218 QUIT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1219 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1220 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1221 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1222
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1223 DEFUN ("old-assq", Fold_assq, 2, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1224 Return non-nil if KEY is `old-eq' to the car of an element of LIST.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1225 The value is actually the element of LIST whose car is KEY.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1226 Elements of LIST that are not conses are ignored.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1227 This function is provided only for byte-code compatibility with v19.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1228 Do not use it.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1229 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1230 (key, list))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1231 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1232 REGISTER Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1233 LIST_LOOP (tail, list)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1234 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1235 REGISTER Lisp_Object elt, tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1236 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1237 elt = XCAR (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1238 if (CONSP (elt) && (tem = XCAR (elt), HACKEQ_UNSAFE (key, tem)))
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 187
diff changeset
1239 return elt;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 /* Like Fassq but never report an error and do not allow quits.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 Use only on lists known never to be circular. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 assq_no_quit (Lisp_Object key, Lisp_Object list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 /* This cannot GC. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1252 REGISTER Lisp_Object tail;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 for (tail = list; CONSP (tail); tail = XCDR (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1255 REGISTER Lisp_Object tem, elt;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 elt = XCAR (tail);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1257 if (CONSP (elt) && (tem = XCAR (elt), EQ_WITH_EBOLA_NOTICE (key, tem)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1258 return elt;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1263 DEFUN ("rassoc", Frassoc, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 Return non-nil if KEY is `equal' to the cdr of an element of LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 The value is actually the element of LIST whose cdr equals KEY.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1266 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1267 (key, list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 REGISTER Lisp_Object tail;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1270 LIST_LOOP (tail, list)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 {
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 187
diff changeset
1272 REGISTER Lisp_Object elt;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1273 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1274 elt = XCAR (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1275 if (CONSP (elt) && internal_equal (XCDR (elt), key, 0))
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 187
diff changeset
1276 return elt;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1282 DEFUN ("old-rassoc", Fold_rassoc, 2, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1283 Return non-nil if KEY is `old-equal' to the cdr of an element of LIST.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1284 The value is actually the element of LIST whose cdr equals KEY.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1285 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1286 (key, list))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1287 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1288 REGISTER Lisp_Object tail;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1289 LIST_LOOP (tail, list)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1290 {
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 187
diff changeset
1291 REGISTER Lisp_Object elt;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1292 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1293 elt = XCAR (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1294 if (CONSP (elt) && internal_old_equal (XCDR (elt), key, 0))
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 187
diff changeset
1295 return elt;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1296 QUIT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1297 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1298 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1299 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1300
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1301 DEFUN ("rassq", Frassq, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 Return non-nil if KEY is `eq' to the cdr of an element of LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 The value is actually the element of LIST whose cdr is KEY.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1304 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1305 (key, list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1307 REGISTER Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1308 LIST_LOOP (tail, list)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1310 REGISTER Lisp_Object elt, tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1311 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1312 elt = XCAR (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1313 if (CONSP (elt) && (tem = XCDR (elt), EQ_WITH_EBOLA_NOTICE (key, tem)))
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 187
diff changeset
1314 return elt;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1315 QUIT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1316 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1317 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1318 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1319
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1320 DEFUN ("old-rassq", Fold_rassq, 2, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1321 Return non-nil if KEY is `old-eq' to the cdr of an element of LIST.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1322 The value is actually the element of LIST whose cdr is KEY.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1323 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1324 (key, list))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1325 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1326 REGISTER Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1327 LIST_LOOP (tail, list)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1328 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1329 REGISTER Lisp_Object elt, tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1330 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1331 elt = XCAR (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1332 if (CONSP (elt) && (tem = XCDR (elt), HACKEQ_UNSAFE (key, tem)))
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 187
diff changeset
1333 return elt;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 rassq_no_quit (Lisp_Object key, Lisp_Object list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1342 REGISTER Lisp_Object tail;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 for (tail = list; CONSP (tail); tail = XCDR (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1345 REGISTER Lisp_Object elt, tem;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 elt = XCAR (tail);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1347 if (CONSP (elt) && (tem = XCDR (elt), EQ_WITH_EBOLA_NOTICE (key, tem)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1348 return elt;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1354 DEFUN ("delete", Fdelete, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 Delete by side effect any occurrences of ELT as a member of LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 The modified LIST is returned. Comparison is done with `equal'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 If the first member of LIST is ELT, there is no way to remove it by side
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 effect; therefore, write `(setq foo (delete element foo))' to be sure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 of changing the value of `foo'.
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 195
diff changeset
1360 Also see: `remove'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1361 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1362 (elt, list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1364 REGISTER Lisp_Object tail = list;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1365 REGISTER Lisp_Object prev = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1366
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 while (!NILP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1369 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1370 if (internal_equal (elt, XCAR (tail), 0))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 if (NILP (prev))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1373 list = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 else
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1375 XCDR (prev) = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 prev = tail;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1379 tail = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 return list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1385 DEFUN ("old-delete", Fold_delete, 2, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1386 Delete by side effect any occurrences of ELT as a member of LIST.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1387 The modified LIST is returned. Comparison is done with `old-equal'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1388 If the first member of LIST is ELT, there is no way to remove it by side
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1389 effect; therefore, write `(setq foo (old-delete element foo))' to be sure
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1390 of changing the value of `foo'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1391 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1392 (elt, list))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1393 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1394 REGISTER Lisp_Object tail = list;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1395 REGISTER Lisp_Object prev = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1396
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1397 while (!NILP (tail))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1398 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1399 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1400 if (internal_old_equal (elt, XCAR (tail), 0))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1401 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1402 if (NILP (prev))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1403 list = XCDR (tail);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1404 else
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1405 XCDR (prev) = XCDR (tail);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1406 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1407 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1408 prev = tail;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1409 tail = XCDR (tail);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1410 QUIT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1411 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1412 return list;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1413 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1414
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1415 DEFUN ("delq", Fdelq, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 Delete by side effect any occurrences of ELT as a member of LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 The modified LIST is returned. Comparison is done with `eq'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 If the first member of LIST is ELT, there is no way to remove it by side
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 effect; therefore, write `(setq foo (delq element foo))' to be sure of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 changing the value of `foo'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1421 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1422 (elt, list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1424 REGISTER Lisp_Object tail = list;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1425 REGISTER Lisp_Object prev = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1426
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 while (!NILP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1429 REGISTER Lisp_Object tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1430 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1431 if (tem = XCAR (tail), EQ_WITH_EBOLA_NOTICE (elt, tem))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1432 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1433 if (NILP (prev))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1434 list = XCDR (tail);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1435 else
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1436 XCDR (prev) = XCDR (tail);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1437 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1438 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1439 prev = tail;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1440 tail = XCDR (tail);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1441 QUIT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1442 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1443 return list;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1444 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1445
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1446 DEFUN ("old-delq", Fold_delq, 2, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1447 Delete by side effect any occurrences of ELT as a member of LIST.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1448 The modified LIST is returned. Comparison is done with `old-eq'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1449 If the first member of LIST is ELT, there is no way to remove it by side
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1450 effect; therefore, write `(setq foo (old-delq element foo))' to be sure of
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1451 changing the value of `foo'.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1452 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1453 (elt, list))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1454 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1455 REGISTER Lisp_Object tail = list;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1456 REGISTER Lisp_Object prev = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1457
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1458 while (!NILP (tail))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1459 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1460 REGISTER Lisp_Object tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1461 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1462 if (tem = XCAR (tail), HACKEQ_UNSAFE (elt, tem))
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 (NILP (prev))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1465 list = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 else
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1467 XCDR (prev) = XCDR (tail);
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 prev = tail;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1471 tail = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 return list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 /* no quit, no errors; be careful */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 delq_no_quit (Lisp_Object elt, Lisp_Object list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1482 REGISTER Lisp_Object tail = list;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1483 REGISTER Lisp_Object prev = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1484
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 while (CONSP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1487 REGISTER Lisp_Object tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1488 if (tem = XCAR (tail), EQ_WITH_EBOLA_NOTICE (elt, tem))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 if (NILP (prev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 list = XCDR (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 XCDR (prev) = XCDR (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 prev = tail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 tail = XCDR (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 return list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 /* Be VERY careful with this. This is like delq_no_quit() but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 also calls free_cons() on the removed conses. You must be SURE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 that no pointers to the freed conses remain around (e.g.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 someone else is pointing to part of the list). This function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 is useful on internal lists that are used frequently and where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 the actual list doesn't escape beyond known code bounds. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 delq_no_quit_and_free_cons (Lisp_Object elt, Lisp_Object list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1512 REGISTER Lisp_Object tail = list;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1513 REGISTER Lisp_Object prev = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1514 struct Lisp_Cons *cons_to_free = NULL;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1515
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 while (CONSP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1518 REGISTER Lisp_Object tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1519 if (tem = XCAR (tail), EQ_WITH_EBOLA_NOTICE (elt, tem))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 if (NILP (prev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 list = XCDR (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 XCDR (prev) = XCDR (tail);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1525 cons_to_free = XCONS (tail);
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 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 prev = tail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 tail = XCDR (tail);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1530 if (cons_to_free)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1531 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1532 free_cons (cons_to_free);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1533 cons_to_free = NULL;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1534 }
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 list;
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 ("remassoc", Fremassoc, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 Delete by side effect any elements of LIST whose car is `equal' to KEY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 The modified LIST is returned. If the first member of LIST has a car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 that is `equal' to KEY, there is no way to remove it by side effect;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 therefore, write `(setq foo (remassoc key foo))' to be sure of changing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 the value of `foo'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1545 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1546 (key, list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1548 REGISTER Lisp_Object tail = list;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1549 REGISTER Lisp_Object prev = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1550
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 while (!NILP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1553 REGISTER Lisp_Object elt;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1554 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1555 elt = XCAR (tail);
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 187
diff changeset
1556 if (CONSP (elt) && internal_equal (key, XCAR (elt), 0))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 if (NILP (prev))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1559 list = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 else
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1561 XCDR (prev) = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 prev = tail;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1565 tail = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 return list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 remassoc_no_quit (Lisp_Object key, Lisp_Object list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 specbind (Qinhibit_quit, Qt);
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
1576 return unbind_to (speccount, Fremassoc (key, list));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1579 DEFUN ("remassq", Fremassq, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 Delete by side effect any elements of LIST whose car is `eq' to KEY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 The modified LIST is returned. If the first member of LIST has a car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 that is `eq' to KEY, there is no way to remove it by side effect;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 therefore, write `(setq foo (remassq key foo))' to be sure of changing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 the value of `foo'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1585 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1586 (key, list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1588 REGISTER Lisp_Object tail = list;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1589 REGISTER Lisp_Object prev = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1590
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 while (!NILP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1593 REGISTER Lisp_Object elt, tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1594 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1595 elt = XCAR (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1596 if (CONSP (elt) && (tem = XCAR (elt), EQ_WITH_EBOLA_NOTICE (key, tem)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 if (NILP (prev))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1599 list = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 else
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1601 XCDR (prev) = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 prev = tail;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1605 tail = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 return list;
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 /* no quit, no errors; be careful */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 remassq_no_quit (Lisp_Object key, Lisp_Object list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1616 REGISTER Lisp_Object tail = list;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1617 REGISTER Lisp_Object prev = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1618
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 while (CONSP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1621 REGISTER Lisp_Object elt, tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1622 elt = XCAR (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1623 if (CONSP (elt) && (tem = XCAR (elt), EQ_WITH_EBOLA_NOTICE (key, tem)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 if (NILP (prev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 list = XCDR (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 XCDR (prev) = XCDR (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 prev = tail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 tail = XCDR (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 return list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1637 DEFUN ("remrassoc", Fremrassoc, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 Delete by side effect any elements of LIST whose cdr is `equal' to VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 The modified LIST is returned. If the first member of LIST has a car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 that is `equal' to VALUE, there is no way to remove it by side effect;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 therefore, write `(setq foo (remrassoc value foo))' to be sure of changing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 the value of `foo'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1643 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1644 (value, list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1646 REGISTER Lisp_Object tail = list;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1647 REGISTER Lisp_Object prev = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1648
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 while (!NILP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1651 REGISTER Lisp_Object elt;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1652 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1653 elt = XCAR (tail);
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 187
diff changeset
1654 if (CONSP (elt) && internal_equal (value, XCDR (elt), 0))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 if (NILP (prev))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1657 list = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 else
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1659 XCDR (prev) = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 prev = tail;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1663 tail = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 return list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1669 DEFUN ("remrassq", Fremrassq, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 Delete by side effect any elements of LIST whose cdr is `eq' to VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 The modified LIST is returned. If the first member of LIST has a car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 that is `eq' to VALUE, there is no way to remove it by side effect;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 therefore, write `(setq foo (remrassq value foo))' to be sure of changing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 the value of `foo'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1675 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1676 (value, list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1678 REGISTER Lisp_Object tail = list;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1679 REGISTER Lisp_Object prev = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1680
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 while (!NILP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1683 REGISTER Lisp_Object elt, tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1684 CONCHECK_CONS (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1685 elt = XCAR (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1686 if (CONSP (elt) && (tem = XCAR (elt), EQ_WITH_EBOLA_NOTICE (value, tem)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 if (NILP (prev))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1689 list = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 else
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1691 XCDR (prev) = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 prev = tail;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1695 tail = XCDR (tail);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 return list;
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 /* no quit, no errors; be careful */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 remrassq_no_quit (Lisp_Object value, Lisp_Object list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1706 REGISTER Lisp_Object tail = list;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1707 REGISTER Lisp_Object prev = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1708
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 while (CONSP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1711 REGISTER Lisp_Object elt, tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1712 elt = XCAR (tail);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1713 if (CONSP (elt) && (tem = XCAR (elt), EQ_WITH_EBOLA_NOTICE (value, tem)))
0
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 (NILP (prev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 list = XCDR (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 XCDR (prev) = XCDR (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 prev = tail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 tail = XCDR (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 return list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1727 DEFUN ("nreverse", Fnreverse, 1, 1, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1728 Reverse LIST by destructively modifying cdr pointers.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1729 Return the beginning of the reversed list.
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 195
diff changeset
1730 Also see: `reverse'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1731 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1732 (list))
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 struct gcpro gcpro1, gcpro2;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1735 REGISTER Lisp_Object prev = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1736 REGISTER Lisp_Object tail = list;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 /* We gcpro our args; see `nconc' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 GCPRO2 (prev, tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 while (!NILP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1742 REGISTER Lisp_Object next;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 QUIT;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1744 CONCHECK_CONS (tail);
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
1745 next = XCDR (tail);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
1746 XCDR (tail) = prev;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 prev = tail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 tail = next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 return prev;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1754 DEFUN ("reverse", Freverse, 1, 1, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1755 Reverse LIST, copying. Return the beginning of the reversed list.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 See also the function `nreverse', which is used more often.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1757 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1758 (list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1760 REGISTER Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1761 Lisp_Object new = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1762
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1763 for (tail = list; CONSP (tail); tail = XCDR (tail))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1764 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1765 new = Fcons (XCAR (tail), new);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1766 QUIT;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1767 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1768 if (!NILP (tail))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1769 dead_wrong_type_argument (Qlistp, tail);
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
1770 return new;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1773 static Lisp_Object list_merge (Lisp_Object org_l1, Lisp_Object org_l2,
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1774 Lisp_Object lisp_arg,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 int (*pred_fn) (Lisp_Object, Lisp_Object,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 Lisp_Object lisp_arg));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 list_sort (Lisp_Object list,
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1780 Lisp_Object lisp_arg,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 int (*pred_fn) (Lisp_Object, Lisp_Object,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 Lisp_Object lisp_arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 struct gcpro gcpro1, gcpro2, gcpro3;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1785 Lisp_Object back, tem;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1786 Lisp_Object front = list;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1787 Lisp_Object len = Flength (list);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1788 int length = XINT (len);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
1789
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 if (length < 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 return list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 XSETINT (len, (length / 2) - 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 tem = Fnthcdr (len, list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 back = Fcdr (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 Fsetcdr (tem, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 GCPRO3 (front, back, lisp_arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 front = list_sort (front, lisp_arg, pred_fn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 back = list_sort (back, lisp_arg, pred_fn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 return list_merge (front, back, lisp_arg, pred_fn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 static int
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1807 merge_pred_function (Lisp_Object obj1, Lisp_Object obj2,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 Lisp_Object pred)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 Lisp_Object tmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 /* prevents the GC from happening in call2 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 /* Emacs' GC doesn't actually relocate pointers, so this probably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 isn't strictly necessary */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 record_unwind_protect (restore_gc_inhibit,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 make_int (gc_currently_forbidden));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 gc_currently_forbidden = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 tmp = call2 (pred, obj1, obj2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 unbind_to (speccount, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1822 if (NILP (tmp))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 return -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1828 DEFUN ("sort", Fsort, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 Sort LIST, stably, comparing elements using PREDICATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 Returns the sorted list. LIST is modified by side effects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 PREDICATE is called with two elements of LIST, and should return T
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1832 if the first element is "less" than the second.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1833 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1834 (list, pred))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 return list_sort (list, pred, merge_pred_function);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 Lisp_Object
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1840 merge (Lisp_Object org_l1, Lisp_Object org_l2,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 Lisp_Object pred)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 return list_merge (org_l1, org_l2, pred, merge_pred_function);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 static Lisp_Object
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1848 list_merge (Lisp_Object org_l1, Lisp_Object org_l2,
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1849 Lisp_Object lisp_arg,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 int (*pred_fn) (Lisp_Object, Lisp_Object, Lisp_Object lisp_arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 Lisp_Object value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 Lisp_Object tail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 Lisp_Object tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 Lisp_Object l1, l2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 l1 = org_l1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 l2 = org_l2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 tail = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 value = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 /* It is sufficient to protect org_l1 and org_l2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 When l1 and l2 are updated, we copy the new values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 back into the org_ vars. */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1866
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 GCPRO4 (org_l1, org_l2, lisp_arg, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 if (NILP (l1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 if (NILP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 return l2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 Fsetcdr (tail, l2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 return value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 if (NILP (l2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 if (NILP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 return l1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 Fsetcdr (tail, l1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 return value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 if (((*pred_fn) (Fcar (l2), Fcar (l1), lisp_arg)) < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 tem = l1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 l1 = Fcdr (l1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 org_l1 = l1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 tem = l2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 l2 = Fcdr (l2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 org_l2 = l2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 if (NILP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 value = tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 Fsetcdr (tail, tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 tail = tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 /* property-list functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 /* For properties of text, we need to do order-insensitive comparison of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 plists. That is, we need to compare two plists such that they are the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 same if they have the same set of keys, and equivalent values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 So (a 1 b 2) would be equal to (b 2 a 1).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 NIL_MEANS_NOT_PRESENT is as in `plists-eq' etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 LAXP means use `equal' for comparisons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
1921 int
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 plists_differ (Lisp_Object a, Lisp_Object b, int nil_means_not_present,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 int laxp, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 int eqp = (depth == -1); /* -1 as depth means us eq, not equal. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 int la, lb, m, i, fill;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 Lisp_Object *keys, *vals;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 char *flags;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 Lisp_Object rest;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 if (NILP (a) && NILP (b))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 Fcheck_valid_plist (a);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 Fcheck_valid_plist (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 la = XINT (Flength (a));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 lb = XINT (Flength (b));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 m = (la > lb ? la : lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 fill = 0;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1941 keys = alloca_array (Lisp_Object, m);
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1942 vals = alloca_array (Lisp_Object, m);
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1943 flags = alloca_array (char, m);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 /* First extract the pairs from A. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 for (rest = a; !NILP (rest); rest = XCDR (XCDR (rest)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 Lisp_Object k = XCAR (rest);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 Lisp_Object v = XCAR (XCDR (rest));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 /* Maybe be Ebolified. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 if (nil_means_not_present && NILP (v)) continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 keys [fill] = k;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 vals [fill] = v;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 flags[fill] = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 fill++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 /* Now iterate over B, and stop if we find something that's not in A,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 or that doesn't match. As we match, mark them. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 for (rest = b; !NILP (rest); rest = XCDR (XCDR (rest)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 Lisp_Object k = XCAR (rest);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 Lisp_Object v = XCAR (XCDR (rest));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 /* Maybe be Ebolified. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 if (nil_means_not_present && NILP (v)) continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 for (i = 0; i < fill; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 if (!laxp ? EQ (k, keys [i]) : internal_equal (k, keys [i], depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 if ((eqp
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1970 /* We narrowly escaped being Ebolified here. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
1971 ? !EQ_WITH_EBOLA_NOTICE (v, vals [i])
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 : !internal_equal (v, vals [i], depth)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 /* a property in B has a different value than in A */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 goto MISMATCH;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 flags [i] = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 if (i == fill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 /* there are some properties in B that are not in A */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 goto MISMATCH;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 /* Now check to see that all the properties in A were also in B */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 for (i = 0; i < fill; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 if (flags [i] == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 goto MISMATCH;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 /* Ok. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 MISMATCH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
1995 DEFUN ("plists-eq", Fplists_eq, 2, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 Return non-nil if property lists A and B are `eq'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 A property list is an alternating list of keywords and values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 This function does order-insensitive comparisons of the property lists:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 For example, the property lists '(a 1 b 2) and '(b 2 a 1) are equal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 Comparison between values is done using `eq'. See also `plists-equal'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 a nil value is ignored. This feature is a virus that has infected
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2003 old Lisp implementations, but should not be used except for backward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2004 compatibility.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2005 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2006 (a, b, nil_means_not_present))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 return (plists_differ (a, b, !NILP (nil_means_not_present), 0, -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 ? Qnil : Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2012 DEFUN ("plists-equal", Fplists_equal, 2, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 Return non-nil if property lists A and B are `equal'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 A property list is an alternating list of keywords and values. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 function does order-insensitive comparisons of the property lists: For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 example, the property lists '(a 1 b 2) and '(b 2 a 1) are equal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 Comparison between values is done using `equal'. See also `plists-eq'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 a nil value is ignored. This feature is a virus that has infected
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2020 old Lisp implementations, but should not be used except for backward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2021 compatibility.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2022 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2023 (a, b, nil_means_not_present))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 return (plists_differ (a, b, !NILP (nil_means_not_present), 0, 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 ? Qnil : Qt);
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
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2030 DEFUN ("lax-plists-eq", Flax_plists_eq, 2, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 Return non-nil if lax property lists A and B are `eq'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 A property list is an alternating list of keywords and values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 This function does order-insensitive comparisons of the property lists:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 For example, the property lists '(a 1 b 2) and '(b 2 a 1) are equal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 Comparison between values is done using `eq'. See also `plists-equal'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 A lax property list is like a regular one except that comparisons between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 keywords is done using `equal' instead of `eq'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 a nil value is ignored. This feature is a virus that has infected
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2040 old Lisp implementations, but should not be used except for backward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2041 compatibility.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2042 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2043 (a, b, nil_means_not_present))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 return (plists_differ (a, b, !NILP (nil_means_not_present), 1, -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 ? Qnil : Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2049 DEFUN ("lax-plists-equal", Flax_plists_equal, 2, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 Return non-nil if lax property lists A and B are `equal'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 A property list is an alternating list of keywords and values. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 function does order-insensitive comparisons of the property lists: For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 example, the property lists '(a 1 b 2) and '(b 2 a 1) are equal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 Comparison between values is done using `equal'. See also `plists-eq'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 A lax property list is like a regular one except that comparisons between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 keywords is done using `equal' instead of `eq'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 a nil value is ignored. This feature is a virus that has infected
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2059 old Lisp implementations, but should not be used except for backward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2060 compatibility.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2061 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2062 (a, b, nil_means_not_present))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 return (plists_differ (a, b, !NILP (nil_means_not_present), 1, 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 ? Qnil : Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 /* Return the value associated with key PROPERTY in property list PLIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 Return nil if key not found. This function is used for internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 property lists that cannot be directly manipulated by the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 internal_plist_get (Lisp_Object plist, Lisp_Object property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 Lisp_Object tail = plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 for (; !NILP (tail); tail = XCDR (XCDR (tail)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 struct Lisp_Cons *c = XCONS (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 if (EQ (c->car, property))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 return XCAR (c->cdr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 return Qunbound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 /* Set PLIST's value for PROPERTY to VALUE. Analogous to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 internal_plist_get(). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 internal_plist_put (Lisp_Object *plist, Lisp_Object property,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 Lisp_Object value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2095 Lisp_Object tail;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2096
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2097 for (tail = *plist; !NILP (tail); tail = XCDR (XCDR (tail)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2099 if (EQ (XCAR (tail), property))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2101 XCAR (XCDR (tail)) = value;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 *plist = Fcons (property, Fcons (value, *plist));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 internal_remprop (Lisp_Object *plist, Lisp_Object property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 Lisp_Object tail = *plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 if (NILP (tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 if (EQ (XCAR (tail), property))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 *plist = XCDR (XCDR (tail));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 for (tail = XCDR (tail); !NILP (XCDR (tail));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 tail = XCDR (XCDR (tail)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 struct Lisp_Cons *c = XCONS (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 if (EQ (XCAR (c->cdr), property))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 c->cdr = XCDR (XCDR (c->cdr));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 /* Called on a malformed property list. BADPLACE should be some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 place where truncating will form a good list -- i.e. we shouldn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 result in a list with an odd length. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 bad_bad_bunny (Lisp_Object *plist, Lisp_Object *badplace, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 if (ERRB_EQ (errb, ERROR_ME))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 return Fsignal (Qmalformed_property_list, list2 (*plist, *badplace));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 if (ERRB_EQ (errb, ERROR_ME_WARN))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 warn_when_safe_lispobj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 (Qlist, Qwarning,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 list2 (build_string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 ("Malformed property list -- list has been truncated"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 *plist));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 *badplace = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 return Qunbound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 /* Called on a circular property list. BADPLACE should be some place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 where truncating will result in an even-length list, as above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 If doesn't particularly matter where we truncate -- anywhere we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 truncate along the entire list will break the circularity, because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 it will create a terminus and the list currently doesn't have one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 bad_bad_turtle (Lisp_Object *plist, Lisp_Object *badplace, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 if (ERRB_EQ (errb, ERROR_ME))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 /* #### Eek, this will probably result in another error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 when PLIST is printed out */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 return Fsignal (Qcircular_property_list, list1 (*plist));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 if (ERRB_EQ (errb, ERROR_ME_WARN))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 warn_when_safe_lispobj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 (Qlist, Qwarning,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 list2 (build_string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 ("Circular property list -- list has been truncated"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 *plist));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 *badplace = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 return Qunbound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 /* Advance the tortoise pointer by two (one iteration of a property-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 loop) and the hare pointer by four and verify that no malformations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 or circularities exist. If so, return zero and store a value into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 RETVAL that should be returned by the calling function. Otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 return 1. See external_plist_get().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 advance_plist_pointers (Lisp_Object *plist,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 Lisp_Object **tortoise, Lisp_Object **hare,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 Error_behavior errb, Lisp_Object *retval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 Lisp_Object *tortsave = *tortoise;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 /* Note that our "fixing" may be more brutal than necessary,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 but it's the user's own problem, not ours. if they went in and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 manually fucked up a plist. */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2208
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 for (i = 0; i < 2; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 /* This is a standard iteration of a defensive-loop-checking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 loop. We just do it twice because we want to advance past
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 both the property and its value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 If the pointer indirection is confusing you, remember that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 one level of indirection on the hare and tortoise pointers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 is only due to pass-by-reference for this function. The other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 level is so that the plist can be fixed in place. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 /* When we reach the end of a well-formed plist, **HARE is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 nil. In that case, we don't do anything at all except
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 advance TORTOISE by one. Otherwise, we advance HARE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 by two (making sure it's OK to do so), then advance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 TORTOISE by one (it will always be OK to do so because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 the HARE is always ahead of the TORTOISE and will have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 already verified the path), then make sure TORTOISE and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 HARE don't contain the same non-nil object -- if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 TORTOISE and the HARE ever meet, then obviously we're
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 in a circularity, and if we're in a circularity, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 the TORTOISE and the HARE can't cross paths without
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 meeting, since the HARE only gains one step over the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 TORTOISE per iteration. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 if (!NILP (**hare))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 Lisp_Object *haresave = *hare;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 if (!CONSP (**hare))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 *retval = bad_bad_bunny (plist, haresave, errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 *hare = &XCDR (**hare);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 /* In a non-plist, we'd check here for a nil value for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 **HARE, which is OK (it just means the list has an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 odd number of elements). In a plist, it's not OK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 for the list to have an odd number of elements. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 if (!CONSP (**hare))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 *retval = bad_bad_bunny (plist, haresave, errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 *hare = &XCDR (**hare);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 *tortoise = &XCDR (**tortoise);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 if (!NILP (**hare) && EQ (**tortoise, **hare))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 *retval = bad_bad_turtle (plist, tortsave, errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 /* Return the value of PROPERTY from PLIST, or Qunbound if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 property is not on the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 PLIST is a Lisp-accessible property list, meaning that it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 has to be checked for malformations and circularities.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 If ERRB is ERROR_ME, an error will be signalled. Otherwise, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 function will never signal an error; and if ERRB is ERROR_ME_WARN,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 on finding a malformation or a circularity, it issues a warning and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 attempts to silently fix the problem.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 A pointer to PLIST is passed in so that PLIST can be successfully
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 "fixed" even if the error is at the beginning of the plist. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 external_plist_get (Lisp_Object *plist, Lisp_Object property,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 int laxp, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 Lisp_Object *tortoise = plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 Lisp_Object *hare = plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 while (!NILP (*tortoise))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 Lisp_Object *tortsave = tortoise;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 Lisp_Object retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 /* We do the standard tortoise/hare march. We isolate the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 grungy stuff to do this in advance_plist_pointers(), though.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 To us, all this function does is advance the tortoise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 pointer by two and the hare pointer by four and make sure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 everything's OK. We first advance the pointers and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 check if a property matched; this ensures that our
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 check for a matching property is safe. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 if (!advance_plist_pointers (plist, &tortoise, &hare, errb, &retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 return retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 if (!laxp ? EQ (XCAR (*tortsave), property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 : internal_equal (XCAR (*tortsave), property, 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 return XCAR (XCDR (*tortsave));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 return Qunbound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 /* Set PLIST's value for PROPERTY to VALUE, given a possibly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 malformed or circular plist. Analogous to external_plist_get(). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 external_plist_put (Lisp_Object *plist, Lisp_Object property,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 Lisp_Object value, int laxp, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 Lisp_Object *tortoise = plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 Lisp_Object *hare = plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 while (!NILP (*tortoise))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 Lisp_Object *tortsave = tortoise;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 Lisp_Object retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 /* See above */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 if (!advance_plist_pointers (plist, &tortoise, &hare, errb, &retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 if (!laxp ? EQ (XCAR (*tortsave), property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 : internal_equal (XCAR (*tortsave), property, 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 XCAR (XCDR (*tortsave)) = value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 *plist = Fcons (property, Fcons (value, *plist));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 external_remprop (Lisp_Object *plist, Lisp_Object property,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 int laxp, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 Lisp_Object *tortoise = plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 Lisp_Object *hare = plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 while (!NILP (*tortoise))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 Lisp_Object *tortsave = tortoise;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 Lisp_Object retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 /* See above */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 if (!advance_plist_pointers (plist, &tortoise, &hare, errb, &retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 if (!laxp ? EQ (XCAR (*tortsave), property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 : internal_equal (XCAR (*tortsave), property, 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 /* Now you see why it's so convenient to have that level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 of indirection. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 *tortsave = XCDR (XCDR (*tortsave));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2370 DEFUN ("plist-get", Fplist_get, 2, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 Extract a value from a property list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 PLIST is a property list, which is a list of the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 \(PROP1 VALUE1 PROP2 VALUE2...). This function returns the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 corresponding to the given PROP, or DEFAULT if PROP is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 one of the properties on the list.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2376 */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2377 (plist, prop, default_))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 Lisp_Object val = external_plist_get (&plist, prop, 0, ERROR_ME);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 if (UNBOUNDP (val))
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2381 return default_;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 return val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2385 DEFUN ("plist-put", Fplist_put, 3, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 Change value in PLIST of PROP to VAL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 PLIST is a property list, which is a list of the form \(PROP1 VALUE1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 PROP2 VALUE2 ...). PROP is usually a symbol and VAL is any object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 If PROP is already a property on the list, its value is set to VAL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 otherwise the new PROP VAL pair is added. The new plist is returned;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 use `(setq x (plist-put x prop val))' to be sure to use the new value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 The PLIST is modified by side effects.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2393 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2394 (plist, prop, val))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 external_plist_put (&plist, prop, val, 0, ERROR_ME);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 return plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2400 DEFUN ("plist-remprop", Fplist_remprop, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 Remove from PLIST the property PROP and its value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 PLIST is a property list, which is a list of the form \(PROP1 VALUE1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 PROP2 VALUE2 ...). PROP is usually a symbol. The new plist is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 returned; use `(setq x (plist-remprop x prop val))' to be sure to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 the new value. The PLIST is modified by side effects.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2406 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2407 (plist, prop))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 external_remprop (&plist, prop, 0, ERROR_ME);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 return plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2413 DEFUN ("plist-member", Fplist_member, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 Return t if PROP has a value specified in PLIST.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2415 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2416 (plist, prop))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 return UNBOUNDP (Fplist_get (plist, prop, Qunbound)) ? Qnil : Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2421 DEFUN ("check-valid-plist", Fcheck_valid_plist, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 Given a plist, signal an error if there is anything wrong with it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 This means that it's a malformed or circular plist.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2424 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2425 (plist))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 Lisp_Object *tortoise;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 Lisp_Object *hare;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 start_over:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 tortoise = &plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 hare = &plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 while (!NILP (*tortoise))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 Lisp_Object retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 /* See above */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 if (!advance_plist_pointers (&plist, &tortoise, &hare, ERROR_ME,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 &retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 goto start_over;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 }
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2445
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2446 DEFUN ("valid-plist-p", Fvalid_plist_p, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 Given a plist, return non-nil if its format is correct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 If it returns nil, `check-valid-plist' will signal an error when given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 the plist; that means it's a malformed or circular plist or has non-symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 as keywords.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2451 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2452 (plist))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 Lisp_Object *tortoise;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 Lisp_Object *hare;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 tortoise = &plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 hare = &plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 while (!NILP (*tortoise))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 Lisp_Object retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 /* See above */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 if (!advance_plist_pointers (&plist, &tortoise, &hare, ERROR_ME_NOT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 &retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 return Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2472 DEFUN ("canonicalize-plist", Fcanonicalize_plist, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 Destructively remove any duplicate entries from a plist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 In such cases, the first entry applies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 a nil value is removed. This feature is a virus that has infected
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2478 old Lisp implementations, but should not be used except for backward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2479 compatibility.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 The new plist is returned. If NIL-MEANS-NOT-PRESENT is given, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 return value may not be EQ to the passed-in value, so make sure to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 `setq' the value back into where it came from.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2484 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2485 (plist, nil_means_not_present))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 Lisp_Object head = plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 Fcheck_valid_plist (plist);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 while (!NILP (plist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 Lisp_Object prop = Fcar (plist);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 Lisp_Object next = Fcdr (plist);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 CHECK_CONS (next); /* just make doubly sure we catch any errors */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 if (!NILP (nil_means_not_present) && NILP (Fcar (next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 if (EQ (head, plist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 head = Fcdr (next);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 plist = Fcdr (next);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 /* external_remprop returns 1 if it removed any property.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 We have to loop till it didn't remove anything, in case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 the property occurs many times. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 while (external_remprop (&XCDR (next), prop, 0, ERROR_ME));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 plist = Fcdr (next);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 return head;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2514 DEFUN ("lax-plist-get", Flax_plist_get, 2, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 Extract a value from a lax property list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 LAX-PLIST is a lax property list, which is a list of the form \(PROP1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 VALUE1 PROP2 VALUE2...), where comparions between properties is done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 using `equal' instead of `eq'. This function returns the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 corresponding to the given PROP, or DEFAULT if PROP is not one of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 properties on the list.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2522 */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2523 (lax_plist, prop, default_))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 Lisp_Object val = external_plist_get (&lax_plist, prop, 1, ERROR_ME);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 if (UNBOUNDP (val))
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2527 return default_;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 return val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2531 DEFUN ("lax-plist-put", Flax_plist_put, 3, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 Change value in LAX-PLIST of PROP to VAL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 LAX-PLIST is a lax property list, which is a list of the form \(PROP1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 VALUE1 PROP2 VALUE2...), where comparions between properties is done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 using `equal' instead of `eq'. PROP is usually a symbol and VAL is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 any object. If PROP is already a property on the list, its value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 set to VAL, otherwise the new PROP VAL pair is added. The new plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 is returned; use `(setq x (lax-plist-put x prop val))' to be sure to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 use the new value. The LAX-PLIST is modified by side effects.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2540 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2541 (lax_plist, prop, val))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 external_plist_put (&lax_plist, prop, val, 1, ERROR_ME);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 return lax_plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2547 DEFUN ("lax-plist-remprop", Flax_plist_remprop, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 Remove from LAX-PLIST the property PROP and its value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 LAX-PLIST is a lax property list, which is a list of the form \(PROP1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 VALUE1 PROP2 VALUE2...), where comparions between properties is done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 using `equal' instead of `eq'. PROP is usually a symbol. The new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 plist is returned; use `(setq x (lax-plist-remprop x prop val))' to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 sure to use the new value. The LAX-PLIST is modified by side effects.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2554 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2555 (lax_plist, prop))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 external_remprop (&lax_plist, prop, 1, ERROR_ME);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 return lax_plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2561 DEFUN ("lax-plist-member", Flax_plist_member, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 Return t if PROP has a value specified in LAX-PLIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 LAX-PLIST is a lax property list, which is a list of the form \(PROP1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 VALUE1 PROP2 VALUE2...), where comparions between properties is done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 using `equal' instead of `eq'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2566 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2567 (lax_plist, prop))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 return UNBOUNDP (Flax_plist_get (lax_plist, prop, Qunbound)) ? Qnil : Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2572 DEFUN ("canonicalize-lax-plist", Fcanonicalize_lax_plist, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 Destructively remove any duplicate entries from a lax plist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 In such cases, the first entry applies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 a nil value is removed. This feature is a virus that has infected
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2578 old Lisp implementations, but should not be used except for backward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
2579 compatibility.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 The new plist is returned. If NIL-MEANS-NOT-PRESENT is given, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 return value may not be EQ to the passed-in value, so make sure to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 `setq' the value back into where it came from.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2584 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2585 (lax_plist, nil_means_not_present))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 Lisp_Object head = lax_plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 Fcheck_valid_plist (lax_plist);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 while (!NILP (lax_plist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 Lisp_Object prop = Fcar (lax_plist);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 Lisp_Object next = Fcdr (lax_plist);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 CHECK_CONS (next); /* just make doubly sure we catch any errors */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 if (!NILP (nil_means_not_present) && NILP (Fcar (next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 if (EQ (head, lax_plist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 head = Fcdr (next);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 lax_plist = Fcdr (next);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 /* external_remprop returns 1 if it removed any property.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 We have to loop till it didn't remove anything, in case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 the property occurs many times. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 while (external_remprop (&XCDR (next), prop, 1, ERROR_ME));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 lax_plist = Fcdr (next);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 return head;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 /* In C because the frame props stuff uses it */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2616 DEFUN ("destructive-alist-to-plist", Fdestructive_alist_to_plist, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 Convert association list ALIST into the equivalent property-list form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 The plist is returned. This converts from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 \((a . 1) (b . 2) (c . 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 \(a 1 b 2 c 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 The original alist is destroyed in the process of constructing the plist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 See also `alist-to-plist'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2628 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2629 (alist))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 Lisp_Object head = alist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 while (!NILP (alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 /* remember the alist element. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 Lisp_Object el = Fcar (alist);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 Fsetcar (alist, Fcar (el));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 Fsetcar (el, Fcdr (el));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 Fsetcdr (el, Fcdr (alist));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 Fsetcdr (alist, el);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 alist = Fcdr (Fcdr (alist));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 return head;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 /* Symbol plists are directly accessible, so we need to protect against
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 invalid property list structure */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 static Lisp_Object
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2651 symbol_getprop (Lisp_Object sym, Lisp_Object propname, Lisp_Object default_)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 Lisp_Object val = external_plist_get (&XSYMBOL (sym)->plist, propname,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 0, ERROR_ME);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2655 return UNBOUNDP (val) ? default_ : val;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 symbol_putprop (Lisp_Object sym, Lisp_Object propname, Lisp_Object value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 external_plist_put (&XSYMBOL (sym)->plist, propname, value, 0, ERROR_ME);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 symbol_remprop (Lisp_Object symbol, Lisp_Object propname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 return external_remprop (&XSYMBOL (symbol)->plist, propname, 0, ERROR_ME);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 /* We store the string's extent info as the first element of the string's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 property list; and the string's MODIFF as the first or second element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 of the string's property list (depending on whether the extent info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 is present), but only if the string has been modified. This is ugly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 but it reduces the memory allocated for the string in the vast
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 majority of cases, where the string is never modified and has no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 extent info. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 static Lisp_Object *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 string_plist_ptr (struct Lisp_String *s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 Lisp_Object *ptr = &s->plist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 if (CONSP (*ptr) && EXTENT_INFOP (XCAR (*ptr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 ptr = &XCDR (*ptr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 if (CONSP (*ptr) && INTP (XCAR (*ptr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 ptr = &XCDR (*ptr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 return ptr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2691 static Lisp_Object
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 string_getprop (struct Lisp_String *s, Lisp_Object property,
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2693 Lisp_Object default_)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 Lisp_Object val = external_plist_get (string_plist_ptr (s), property, 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 ERROR_ME);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2697 return UNBOUNDP (val) ? default_ : val;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2700 static void
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 string_putprop (struct Lisp_String *s, Lisp_Object property,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 Lisp_Object value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 external_plist_put (string_plist_ptr (s), property, value, 0, ERROR_ME);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 string_remprop (struct Lisp_String *s, Lisp_Object property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 return external_remprop (string_plist_ptr (s), property, 0, ERROR_ME);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 string_plist (struct Lisp_String *s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 return *string_plist_ptr (s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2719 DEFUN ("get", Fget, 2, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 Return the value of OBJECT's PROPNAME property.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 This is the last VALUE stored with `(put OBJECT PROPNAME VALUE)'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 If there is no such property, return optional third arg DEFAULT
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2723 \(which defaults to `nil'). OBJECT can be a symbol, face, extent,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 or string. See also `put', `remprop', and `object-plist'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2725 */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2726 (object, propname, default_))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 /* Various places in emacs call Fget() and expect it not to quit,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 so don't quit. */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2732
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 /* It's easiest to treat symbols specially because they may not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 be an lrecord */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 if (SYMBOLP (object))
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2736 val = symbol_getprop (object, propname, default_);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 else if (STRINGP (object))
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2738 val = string_getprop (XSTRING (object), propname, default_);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 else if (LRECORDP (object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 CONST struct lrecord_implementation
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
2742 *imp = XRECORD_LHEADER_IMPLEMENTATION (object);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 if (imp->getprop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 val = (imp->getprop) (object, propname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 if (UNBOUNDP (val))
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2747 val = default_;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 goto noprops;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 noprops:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 signal_simple_error ("Object type has no properties", object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 return val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2761 DEFUN ("put", Fput, 3, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 Store OBJECT's PROPNAME property with value VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 It can be retrieved with `(get OBJECT PROPNAME)'. OBJECT can be a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 symbol, face, extent, or string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 For a string, no properties currently have predefined meanings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 For the predefined properties for extents, see `set-extent-property'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 For the predefined properties for faces, see `set-face-property'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 See also `get', `remprop', and `object-plist'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2771 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2772 (object, propname, value))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 CHECK_SYMBOL (propname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 CHECK_IMPURE (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 if (SYMBOLP (object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 symbol_putprop (object, propname, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 else if (STRINGP (object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 string_putprop (XSTRING (object), propname, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 else if (LRECORDP (object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 CONST struct lrecord_implementation
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
2784 *imp = XRECORD_LHEADER_IMPLEMENTATION (object);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 if (imp->putprop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 if (! (imp->putprop) (object, propname, value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 signal_simple_error ("Can't set property on object", propname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 goto noprops;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 noprops:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 signal_simple_error ("Object type has no settable properties", object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 return value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 pure_put (Lisp_Object sym, Lisp_Object prop, Lisp_Object val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 Fput (sym, prop, Fpurecopy (val));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2808 DEFUN ("remprop", Fremprop, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 Remove from OBJECT's property list the property PROPNAME and its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 value. OBJECT can be a symbol, face, extent, or string. Returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 non-nil if the property list was actually changed (i.e. if PROPNAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 was present in the property list). See also `get', `put', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813 `object-plist'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2814 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2815 (object, propname))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817 int retval = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 CHECK_SYMBOL (propname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 CHECK_IMPURE (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 if (SYMBOLP (object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 retval = symbol_remprop (object, propname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 else if (STRINGP (object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 retval = string_remprop (XSTRING (object), propname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 else if (LRECORDP (object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 CONST struct lrecord_implementation
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
2829 *imp = XRECORD_LHEADER_IMPLEMENTATION (object);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 if (imp->remprop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 retval = (imp->remprop) (object, propname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 if (retval == -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 signal_simple_error ("Can't remove property from object",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 propname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 goto noprops;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 noprops:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 signal_simple_error ("Object type has no removable properties", object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 return retval ? Qt : Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2849 DEFUN ("object-plist", Fobject_plist, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 Return a property list of OBJECT's props.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 For a symbol this is equivalent to `symbol-plist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 Do not modify the property list directly; this may or may not have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 the desired effects. (In particular, for a property with a special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 interpretation, this will probably have no effect at all.)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2855 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2856 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858 if (SYMBOLP (object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 return Fsymbol_plist (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860 else if (STRINGP (object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 return string_plist (XSTRING (object));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862 else if (LRECORDP (object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 CONST struct lrecord_implementation
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
2865 *imp = XRECORD_LHEADER_IMPLEMENTATION (object);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 if (imp->plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867 return (imp->plist) (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 signal_simple_error ("Object type has no properties", object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872 signal_simple_error ("Object type has no properties", object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 internal_equal (Lisp_Object o1, Lisp_Object o2, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 if (depth > 200)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 error ("Stack overflow in equal");
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
2883 #ifndef LRECORD_CONS
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 do_cdr:
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
2885 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 QUIT;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2887 if (EQ_WITH_EBOLA_NOTICE (o1, o2))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2888 return 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 /* Note that (equal 20 20.0) should be nil */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2890 else if (XTYPE (o1) != XTYPE (o2))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2891 return 0;
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
2892 #ifndef LRECORD_CONS
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 else if (CONSP (o1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
2895 if (!internal_equal (XCAR (o1), XCAR (o2), depth + 1))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2896 return 0;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
2897 o1 = XCDR (o1);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
2898 o2 = XCDR (o2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 goto do_cdr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 }
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
2901 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 #ifndef LRECORD_VECTOR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 else if (VECTORP (o1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2905 Lisp_Object *v1 = XVECTOR_DATA (o1);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2906 Lisp_Object *v2 = XVECTOR_DATA (o2);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2907 int len = XVECTOR_LENGTH (o1);
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2908 if (len != XVECTOR_LENGTH (o2))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2909 return 0;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2910 while (len--)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2911 if (!internal_equal (*v1++, *v2++, depth + 1))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2912 return 0;
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2913 return 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 }
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
2915 #endif
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
2916 #ifndef LRECORD_STRING
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 else if (STRINGP (o1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2919 Bytecount len;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2920 return (((len = XSTRING_LENGTH (o1)) == XSTRING_LENGTH (o2)) &&
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
2921 !memcmp (XSTRING_DATA (o1), XSTRING_DATA (o2), len));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 }
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
2923 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 else if (LRECORDP (o1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 CONST struct lrecord_implementation
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
2927 *imp1 = XRECORD_LHEADER_IMPLEMENTATION (o1),
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
2928 *imp2 = XRECORD_LHEADER_IMPLEMENTATION (o2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 if (imp1 != imp2)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2930 return 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 else if (imp1->equal == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 /* EQ-ness of the objects was noticed above */
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2933 return 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 else
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2935 return (imp1->equal) (o1, o2, depth);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2938 return 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2941 /* Note that we may be calling sub-objects that will use
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2942 internal_equal() (instead of internal_old_equal()). Oh well.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2943 We will get an Ebola note if there's any possibility of confusion,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2944 but that seems unlikely. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2945
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2946 static int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2947 internal_old_equal (Lisp_Object o1, Lisp_Object o2, int depth)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2948 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2949 if (depth > 200)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2950 error ("Stack overflow in equal");
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
2951 #ifndef LRECORD_CONS
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2952 do_cdr:
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
2953 #endif
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2954 QUIT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2955 if (HACKEQ_UNSAFE (o1, o2))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2956 return 1;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2957 /* Note that (equal 20 20.0) should be nil */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2958 else if (XTYPE (o1) != XTYPE (o2))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2959 return 0;
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
2960 #ifndef LRECORD_CONS
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2961 else if (CONSP (o1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2962 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
2963 if (!internal_old_equal (XCAR (o1), XCAR (o2), depth + 1))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2964 return 0;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
2965 o1 = XCDR (o1);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
2966 o2 = XCDR (o2);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2967 goto do_cdr;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2968 }
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
2969 #endif
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2970 #ifndef LRECORD_VECTOR
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2971 else if (VECTORP (o1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2972 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2973 int indice;
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2974 int len = XVECTOR_LENGTH (o1);
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2975 if (len != XVECTOR_LENGTH (o2))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2976 return 0;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2977 for (indice = 0; indice < len; indice++)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2978 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2979 if (!internal_old_equal (XVECTOR_DATA (o1) [indice],
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2980 XVECTOR_DATA (o2) [indice],
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
2981 depth + 1))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2982 return 0;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2983 }
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2984 return 1;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2985 }
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
2986 #endif
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
2987 #ifndef LRECORD_STRING
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2988 else if (STRINGP (o1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2989 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2990 Bytecount len = XSTRING_LENGTH (o1);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2991 if (len != XSTRING_LENGTH (o2))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2992 return 0;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2993 if (memcmp (XSTRING_DATA (o1), XSTRING_DATA (o2), len))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2994 return 0;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
2995 return 1;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2996 }
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
2997 #endif
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2998 else if (LRECORDP (o1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
2999 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3000 CONST struct lrecord_implementation
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
3001 *imp1 = XRECORD_LHEADER_IMPLEMENTATION (o1),
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
3002 *imp2 = XRECORD_LHEADER_IMPLEMENTATION (o2);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3003 if (imp1 != imp2)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
3004 return 0;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3005 else if (imp1->equal == 0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3006 /* EQ-ness of the objects was noticed above */
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
3007 return 0;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3008 else
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
3009 return (imp1->equal) (o1, o2, depth);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3010 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3011
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
3012 return 0;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3013 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3014
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3015 DEFUN ("equal", Fequal, 2, 2, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3016 Return t if two Lisp objects have similar structure and contents.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017 They must have the same data type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 Conses are compared by comparing the cars and the cdrs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 Vectors and strings are compared element by element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 Numbers are compared by value. Symbols must match exactly.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3021 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3022 (o1, o2))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 {
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
3024 return internal_equal (o1, o2, 0) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3027 DEFUN ("old-equal", Fold_equal, 2, 2, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3028 Return t if two Lisp objects have similar structure and contents.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3029 They must have the same data type.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3030 \(Note, however, that an exception is made for characters and integers;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
3031 this is known as the "char-int confoundance disease." See `eq' and
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3032 `old-eq'.)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3033 This function is provided only for byte-code compatibility with v19.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3034 Do not use it.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3035 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3036 (o1, o2))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3037 {
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
3038 return internal_old_equal (o1, o2, 0) ? Qt : Qnil;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3039 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3040
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3042 DEFUN ("fillarray", Ffillarray, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 Store each element of ARRAY with ITEM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 ARRAY is a vector, bit vector, or string.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3045 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3046 (array, item))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 retry:
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
3049 if (STRINGP (array))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
3050 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3051 Emchar charval;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3052 struct Lisp_String *s = XSTRING (array);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3053 Charcount len = string_char_length (s);
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
3054 Charcount i;
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
3055 CHECK_CHAR_COERCE_INT (item);
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
3056 CHECK_IMPURE (array);
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
3057 charval = XCHAR (item);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
3058 for (i = 0; i < len; i++)
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
3059 set_string_char (s, i, charval);
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
3060 bump_string_modiff (array);
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
3061 }
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
3062 else if (VECTORP (array))
10
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 2
diff changeset
3063 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3064 Lisp_Object *p = XVECTOR_DATA (array);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3065 int len = XVECTOR_LENGTH (array);
10
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 2
diff changeset
3066 CHECK_IMPURE (array);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3067 while (len--)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3068 *p++ = item;
10
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 2
diff changeset
3069 }
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
3070 else if (BIT_VECTORP (array))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3072 struct Lisp_Bit_Vector *v = XBIT_VECTOR (array);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3073 int len = bit_vector_length (v);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3074 int bit;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 CHECK_BIT (item);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076 CHECK_IMPURE (array);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3077 bit = XINT (item);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3078 while (len--)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3079 set_bit_vector_bit (v, len, bit);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 array = wrong_type_argument (Qarrayp, array);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084 goto retry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 return array;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 nconc2 (Lisp_Object s1, Lisp_Object s2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 Lisp_Object args[2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 args[0] = s1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 args[1] = s2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 return Fnconc (2, args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3098 DEFUN ("nconc", Fnconc, 0, MANY, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 Concatenate any number of lists by altering them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 Only the last argument is not altered, and need not be a list.
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 195
diff changeset
3101 Also see: `append'.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3102 If the first argument is nil, there is no way to modify it by side
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3103 effect; therefore, write `(setq foo (nconc foo list))' to be sure of
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3104 changing the value of `foo'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3105 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3106 (int nargs, Lisp_Object *args))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3108 int argnum = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 /* The modus operandi in Emacs is "caller gc-protects args".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112 However, nconc (particularly nconc2 ()) is called many times
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113 in Emacs on freshly created stuff (e.g. you see the idiom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114 nconc2 (Fcopy_sequence (foo), bar) a lot). So we help those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115 callers out by protecting the args ourselves to save them
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116 a lot of temporary-variable grief. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 GCPRO1 (args[0]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 gcpro1.nvars = nargs;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
3120
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3121 while (argnum < nargs)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3123 Lisp_Object val = args[argnum];
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3124 if (CONSP (val))
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
3125 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3126 /* Found the first cons, which will be our return value. */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3127 Lisp_Object last = val;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3128
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3129 for (argnum++; argnum < nargs; argnum++)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3130 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3131 Lisp_Object next = args[argnum];
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3132 redo:
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3133 if (CONSP (next) || argnum == nargs -1)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3134 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3135 /* (setcdr (last val) next) */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3136 while (CONSP (XCDR (last)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3137 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3138 last = XCDR (last);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3139 QUIT;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3140 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3141 XCDR (last) = next;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3142 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3143 else if (NILP (next))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3144 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3145 continue;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3146 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3147 else
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3148 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3149 next = wrong_type_argument (next, Qlistp);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3150 goto redo;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3151 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3152 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3153 RETURN_UNGCPRO (val);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3154 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3155 else if (NILP (val))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3156 argnum++;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3157 else if (argnum == nargs - 1) /* last arg? */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3158 RETURN_UNGCPRO (val);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3159 else
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3160 args[argnum] = wrong_type_argument (val, Qlistp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3162 RETURN_UNGCPRO (Qnil); /* No non-nil args provided. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166 /* This is the guts of all mapping functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 Apply fn to each element of seq, one by one,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 storing the results into elements of vals, a C vector of Lisp_Objects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 leni is the length of vals, which should also be the length of seq.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 If VALS is a null pointer, do not accumulate the results. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 mapcar1 (int leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 Lisp_Object tail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 Lisp_Object dummy = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179 struct gcpro gcpro1, gcpro2, gcpro3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 Lisp_Object result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 GCPRO3 (dummy, fn, seq);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 if (vals)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3185 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 /* Don't let vals contain any garbage when GC happens. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187 for (i = 0; i < leni; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188 vals[i] = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3189 gcpro1.var = vals;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190 gcpro1.nvars = leni;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 /* We need not explicitly protect `tail' because it is used only on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 lists, and 1) lists are not relocated and 2) the list is marked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3195 via `seq' so will not be freed */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197 if (VECTORP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 for (i = 0; i < leni; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
3201 dummy = XVECTOR_DATA (seq)[i];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202 result = call1 (fn, dummy);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 if (vals)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 vals[i] = result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 else if (BIT_VECTORP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 struct Lisp_Bit_Vector *v = XBIT_VECTOR (seq);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 for (i = 0; i < leni; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 XSETINT (dummy, bit_vector_bit (v, i));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 result = call1 (fn, dummy);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 if (vals)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 vals[i] = result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218 else if (STRINGP (seq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 for (i = 0; i < leni; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 result = call1 (fn, make_char (string_char (XSTRING (seq), i)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 if (vals)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 vals[i] = result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227 else /* Must be a list, since Flength did not get an error */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 tail = seq;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230 for (i = 0; i < leni; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 result = call1 (fn, Fcar (tail));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 if (vals)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234 vals[i] = result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235 tail = Fcdr (tail);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3242 DEFUN ("mapconcat", Fmapconcat, 3, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 Apply FN to each element of SEQ, and concat the results as strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244 In between each pair of results, stick in SEP.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
3245 Thus, " " as SEP results in spaces between the values returned by FN.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3246 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3247 (fn, seq, sep))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 {
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
3249 int len = XINT (Flength (seq));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250 Lisp_Object *args;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252 struct gcpro gcpro1;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3253 int nargs = len + len - 1;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3254
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 if (nargs < 0) return build_string ("");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
3257 args = alloca_array (Lisp_Object, nargs);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259 GCPRO1 (sep);
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
3260 mapcar1 (len, args, fn, seq);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
3263 for (i = len - 1; i >= 0; i--)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264 args[i + i] = args[i];
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
3265
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 for (i = 1; i < nargs; i += 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 args[i] = sep;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 return Fconcat (nargs, args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3272 DEFUN ("mapcar", Fmapcar, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273 Apply FUNCTION to each element of SEQUENCE, and make a list of the results.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274 The result is a list just as long as SEQUENCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 SEQUENCE may be a list, a vector, a bit vector, or a string.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3276 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3277 (fn, seq))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278 {
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
3279 int len = XINT (Flength (seq));
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
3280 Lisp_Object *args = alloca_array (Lisp_Object, len);
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
3281
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
3282 mapcar1 (len, args, fn, seq);
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
3283
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
3284 return Flist (len, args);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3287 DEFUN ("mapvector", Fmapvector, 2, 2, 0, /*
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3288 Apply FUNCTION to each element of SEQUENCE, making a vector of the results.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3289 The result is a vector of the same length as SEQUENCE.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3290 SEQUENCE may be a list, a vector or a string.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3291 */
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3292 (fn, seq))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3293 {
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3294 int len = XINT (Flength (seq));
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 211
diff changeset
3295 /* Ideally, this should call make_vector_internal, because we don't
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 211
diff changeset
3296 need initialization. */
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 211
diff changeset
3297 Lisp_Object result = make_vector (len, Qnil);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 211
diff changeset
3298 struct gcpro gcpro1;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 211
diff changeset
3299
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 211
diff changeset
3300 GCPRO1 (result);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 211
diff changeset
3301 mapcar1 (len, XVECTOR_DATA (result), fn, seq);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 211
diff changeset
3302 UNGCPRO;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 211
diff changeset
3303
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 211
diff changeset
3304 return result;
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3305 }
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3306
187
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
3307 DEFUN ("mapc", Fmapc, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 Apply FUNCTION to each element of SEQUENCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309 SEQUENCE may be a list, a vector, a bit vector, or a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310 This function is like `mapcar' but does not accumulate the results,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311 which is more efficient if you do not use the results.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3312 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3313 (fn, seq))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3314 {
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
3315 mapcar1 (XINT (Flength (seq)), 0, fn, seq);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3316
187
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
3317 return seq;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3318 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3321 /* #### this function doesn't belong in this file! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3322
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3323 DEFUN ("load-average", Fload_average, 0, 0, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3324 Return list of 1 minute, 5 minute and 15 minute load averages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3325 Each of the three load averages is multiplied by 100,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3326 then converted to integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3328 If the 5-minute or 15-minute load averages are not available, return a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3329 shortened list, containing only those averages which are available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3330
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3331 On some systems, this won't work due to permissions on /dev/kmem,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3332 in which case you can't use this.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3333 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3334 ())
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3335 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3336 double load_ave[3];
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3337 int loads = getloadavg (load_ave, countof (load_ave));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3339 if (loads == -2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3340 error ("load-average not implemented for this operating system.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3341 else if (loads < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3342 error ("could not get load-average; check permissions.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3343
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3344 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3345 Lisp_Object ret = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3346 while (loads > 0)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3347 ret = Fcons (make_int ((int) (load_ave[--loads] * 100.0)), ret);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3348 return ret;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3349 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3350 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3353 Lisp_Object Vfeatures;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3354
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3355 DEFUN ("featurep", Ffeaturep, 1, 1, 0, /*
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3356 Return non-nil if feature FEXP is present in this Emacs.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3357 Use this to conditionalize execution of lisp code based on the
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3358 presence or absence of emacs or environment extensions.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3359 FEXP can be a symbol, a number, or a list.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3360 If it is a symbol, that symbol is looked up in the `features' variable,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3361 and non-nil will be returned if found.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3362 If it is a number, the function will return non-nil if this Emacs
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3363 has an equal or greater version number than FEXP.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3364 If it is a list whose car is the symbol `and', it will return
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3365 non-nil if all the features in its cdr are non-nil.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3366 If it is a list whose car is the symbol `or', it will return non-nil
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3367 if any of the features in its cdr are non-nil.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3368 If it is a list whose car is the symbol `not', it will return
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3369 non-nil if the feature is not present.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3370
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3371 Examples:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3372
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3373 (featurep 'xemacs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3374 => ; Non-nil on XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3375
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3376 (featurep '(and xemacs gnus))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3377 => ; Non-nil on XEmacs with Gnus loaded.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3378
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3379 (featurep '(or tty-frames (and emacs 19.30)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3380 => ; Non-nil if this Emacs supports TTY frames.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3381
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3382 (featurep '(or (and xemacs 19.15) (and emacs 19.34)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3383 => ; Non-nil on XEmacs 19.15 and later, or FSF Emacs 19.34 and later.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3384
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3385 NOTE: The advanced arguments of this function (anything other than a
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3386 symbol) are not yet supported by FSF Emacs. If you feel they are useful
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3387 for supporting multiple Emacs variants, lobby Richard Stallman at
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3388 <bug-gnu-emacs@prep.ai.mit.edu>.
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3389 */
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3390 (fexp))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3391 {
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3392 #ifndef FEATUREP_SYNTAX
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3393 CHECK_SYMBOL (fexp);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3394 return NILP (Fmemq (fexp, Vfeatures)) ? Qnil : Qt;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3395 #else /* FEATUREP_SYNTAX */
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3396 static double featurep_emacs_version;
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3397
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3398 /* Brute force translation from Erik Naggum's lisp function. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3399 if (SYMBOLP (fexp))
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3400 {
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3401 /* Original definition */
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3402 return NILP (Fmemq (fexp, Vfeatures)) ? Qnil : Qt;
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3403 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3404 else if (INTP (fexp) || FLOATP (fexp))
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3405 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3406 double d = extract_float (fexp);
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3407
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3408 if (featurep_emacs_version == 0.0)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3409 {
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 165
diff changeset
3410 featurep_emacs_version = XINT (Vemacs_major_version) +
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 165
diff changeset
3411 (XINT (Vemacs_minor_version) / 100.0);
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3412 }
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
3413 return featurep_emacs_version >= d ? Qt : Qnil;
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3414 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3415 else if (CONSP (fexp))
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3416 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3417 Lisp_Object tem = XCAR (fexp);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3418 if (EQ (tem, Qnot))
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3419 {
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3420 Lisp_Object negate;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3421
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3422 tem = XCDR (fexp);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3423 negate = Fcar (tem);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3424 if (!NILP (tem))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3425 return NILP (call1 (Qfeaturep, negate)) ? Qt : Qnil;
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3426 else
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3427 return Fsignal (Qinvalid_read_syntax, list1 (tem));
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3428 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3429 else if (EQ (tem, Qand))
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3430 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3431 tem = XCDR (fexp);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3432 /* Use Fcar/Fcdr for error-checking. */
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3433 while (!NILP (tem) && !NILP (call1 (Qfeaturep, Fcar (tem))))
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3434 {
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3435 tem = Fcdr (tem);
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3436 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3437 return NILP (tem) ? Qt : Qnil;
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3438 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3439 else if (EQ (tem, Qor))
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3440 {
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3441 tem = XCDR (fexp);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3442 /* Use Fcar/Fcdr for error-checking. */
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
3443 while (!NILP (tem) && NILP (call1 (Qfeaturep, Fcar (tem))))
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3444 {
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
3445 tem = Fcdr (tem);
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3446 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3447 return NILP (tem) ? Qnil : Qt;
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3448 }
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3449 else
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3450 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3451 return Fsignal (Qinvalid_read_syntax, list1 (XCDR (fexp)));
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3452 }
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3453 }
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3454 else
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3455 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
3456 return Fsignal (Qinvalid_read_syntax, list1 (fexp));
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3457 }
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3458 }
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 165
diff changeset
3459 #endif /* FEATUREP_SYNTAX */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3460
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3461 DEFUN ("provide", Fprovide, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3462 Announce that FEATURE is a feature of the current Emacs.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3463 This function updates the value of the variable `features'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3464 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3465 (feature))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3466 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3467 Lisp_Object tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3468 CHECK_SYMBOL (feature);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3469 if (!NILP (Vautoload_queue))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3470 Vautoload_queue = Fcons (Fcons (Vfeatures, Qnil), Vautoload_queue);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3471 tem = Fmemq (feature, Vfeatures);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3472 if (NILP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3473 Vfeatures = Fcons (feature, Vfeatures);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3474 LOADHIST_ATTACH (Fcons (Qprovide, feature));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3475 return feature;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3476 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3477
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3478 DEFUN ("require", Frequire, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3479 If feature FEATURE is not loaded, load it from FILENAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3480 If FEATURE is not a member of the list `features', then the feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3481 is not loaded; so load the file FILENAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3482 If FILENAME is omitted, the printname of FEATURE is used as the file name.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3483 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3484 (feature, file_name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3485 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3486 Lisp_Object tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3487 CHECK_SYMBOL (feature);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3488 tem = Fmemq (feature, Vfeatures);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3489 LOADHIST_ATTACH (Fcons (Qrequire, feature));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3490 if (!NILP (tem))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
3491 return feature;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3492 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3493 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3494 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3496 /* Value saved here is to be restored into Vautoload_queue */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3497 record_unwind_protect (un_autoload, Vautoload_queue);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3498 Vautoload_queue = Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3500 call4 (Qload, NILP (file_name) ? Fsymbol_name (feature) : file_name,
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3501 Qnil, Qt, Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3503 tem = Fmemq (feature, Vfeatures);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3504 if (NILP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3505 error ("Required feature %s was not provided",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3506 string_data (XSYMBOL (feature)->name));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3508 /* Once loading finishes, don't undo it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3509 Vautoload_queue = Qt;
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 140
diff changeset
3510 return unbind_to (speccount, feature);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3511 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3512 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3515 Lisp_Object Qyes_or_no_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3517 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3518 syms_of_fns (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3519 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3520 defsymbol (&Qstring_lessp, "string-lessp");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3521 defsymbol (&Qidentity, "identity");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3522 defsymbol (&Qyes_or_no_p, "yes-or-no-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3523
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3524 DEFSUBR (Fidentity);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3525 DEFSUBR (Frandom);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3526 DEFSUBR (Flength);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3527 DEFSUBR (Fsafe_length);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3528 DEFSUBR (Fstring_equal);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3529 DEFSUBR (Fstring_lessp);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3530 DEFSUBR (Fstring_modified_tick);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3531 DEFSUBR (Fappend);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3532 DEFSUBR (Fconcat);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3533 DEFSUBR (Fvconcat);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3534 DEFSUBR (Fbvconcat);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3535 DEFSUBR (Fcopy_sequence);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3536 DEFSUBR (Fcopy_alist);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3537 DEFSUBR (Fcopy_tree);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3538 DEFSUBR (Fsubstring);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3539 DEFSUBR (Fsubseq);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3540 DEFSUBR (Fnthcdr);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3541 DEFSUBR (Fnth);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3542 DEFSUBR (Felt);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3543 DEFSUBR (Fmember);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3544 DEFSUBR (Fold_member);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3545 DEFSUBR (Fmemq);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3546 DEFSUBR (Fold_memq);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3547 DEFSUBR (Fassoc);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3548 DEFSUBR (Fold_assoc);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3549 DEFSUBR (Fassq);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3550 DEFSUBR (Fold_assq);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3551 DEFSUBR (Frassoc);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3552 DEFSUBR (Fold_rassoc);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3553 DEFSUBR (Frassq);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3554 DEFSUBR (Fold_rassq);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3555 DEFSUBR (Fdelete);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3556 DEFSUBR (Fold_delete);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3557 DEFSUBR (Fdelq);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3558 DEFSUBR (Fold_delq);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3559 DEFSUBR (Fremassoc);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3560 DEFSUBR (Fremassq);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3561 DEFSUBR (Fremrassoc);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3562 DEFSUBR (Fremrassq);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3563 DEFSUBR (Fnreverse);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3564 DEFSUBR (Freverse);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3565 DEFSUBR (Fsort);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3566 DEFSUBR (Fplists_eq);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3567 DEFSUBR (Fplists_equal);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3568 DEFSUBR (Flax_plists_eq);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3569 DEFSUBR (Flax_plists_equal);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3570 DEFSUBR (Fplist_get);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3571 DEFSUBR (Fplist_put);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3572 DEFSUBR (Fplist_remprop);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3573 DEFSUBR (Fplist_member);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3574 DEFSUBR (Fcheck_valid_plist);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3575 DEFSUBR (Fvalid_plist_p);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3576 DEFSUBR (Fcanonicalize_plist);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3577 DEFSUBR (Flax_plist_get);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3578 DEFSUBR (Flax_plist_put);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3579 DEFSUBR (Flax_plist_remprop);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3580 DEFSUBR (Flax_plist_member);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3581 DEFSUBR (Fcanonicalize_lax_plist);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3582 DEFSUBR (Fdestructive_alist_to_plist);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3583 DEFSUBR (Fget);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3584 DEFSUBR (Fput);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3585 DEFSUBR (Fremprop);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3586 DEFSUBR (Fobject_plist);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3587 DEFSUBR (Fequal);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 50
diff changeset
3588 DEFSUBR (Fold_equal);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3589 DEFSUBR (Ffillarray);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3590 DEFSUBR (Fnconc);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3591 DEFSUBR (Fmapcar);
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 149
diff changeset
3592 DEFSUBR (Fmapvector);
187
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
3593 DEFSUBR (Fmapc);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3594 DEFSUBR (Fmapconcat);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3595 DEFSUBR (Fload_average);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3596 DEFSUBR (Ffeaturep);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3597 DEFSUBR (Frequire);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
3598 DEFSUBR (Fprovide);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3599 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3601 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3602 init_provide_once (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3603 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3604 DEFVAR_LISP ("features", &Vfeatures /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3605 A list of symbols which are the features of the executing emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3606 Used by `featurep' and `require', and altered by `provide'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3607 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3608 Vfeatures = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3609 }