comparison src/fns.c @ 83548:c71725faff1a

Merged from emacs@sv.gnu.org. Last-minute emacsclient rewrites be damned! Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-490 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-491 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-492 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-493 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-494 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-495 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-496 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-497 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-498 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-499 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-500 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-501 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-502 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-503 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-504 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-505 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-506 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-507 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-508 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-509 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-510 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-511 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-512 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-513 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-514 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-515 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-516 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-517 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-518 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-519 Update from CVS: etc/TUTORIAL.cn: Updated. * emacs@sv.gnu.org/emacs--devo--0--patch-520 Merge from erc--emacs--22 * emacs@sv.gnu.org/emacs--devo--0--patch-521 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-522 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-523 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-524 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-525 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-526 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-527 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-528 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-529 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-530 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-531 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-532 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-533 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-534 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-535 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-161 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-162 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-163 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-164 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-165 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-166 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-167 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-168 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-169 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-170 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-588
author Karoly Lorentey <lorentey@elte.hu>
date Sun, 03 Dec 2006 15:03:30 +0000
parents 2d56e13fd23d a2250a4829ad
children b8d9a391daf3
comparison
equal deleted inserted replaced
83547:0912b745fc75 83548:c71725faff1a
101 DEFUN ("random", Frandom, Srandom, 0, 1, 0, 101 DEFUN ("random", Frandom, Srandom, 0, 1, 0,
102 doc: /* Return a pseudo-random number. 102 doc: /* Return a pseudo-random number.
103 All integers representable in Lisp are equally likely. 103 All integers representable in Lisp are equally likely.
104 On most systems, this is 29 bits' worth. 104 On most systems, this is 29 bits' worth.
105 With positive integer argument N, return random number in interval [0,N). 105 With positive integer argument N, return random number in interval [0,N).
106 With argument t, set the random number seed from the current time and pid. */) 106 With argument t, set the random number seed from the current time and pid. */)
107 (n) 107 (n)
108 Lisp_Object n; 108 Lisp_Object n;
109 { 109 {
110 EMACS_INT val; 110 EMACS_INT val;
111 Lisp_Object lispy_val; 111 Lisp_Object lispy_val;
138 DEFUN ("length", Flength, Slength, 1, 1, 0, 138 DEFUN ("length", Flength, Slength, 1, 1, 0,
139 doc: /* Return the length of vector, list or string SEQUENCE. 139 doc: /* Return the length of vector, list or string SEQUENCE.
140 A byte-code function object is also allowed. 140 A byte-code function object is also allowed.
141 If the string contains multibyte characters, this is not necessarily 141 If the string contains multibyte characters, this is not necessarily
142 the number of bytes in the string; it is the number of characters. 142 the number of bytes in the string; it is the number of characters.
143 To get the number of bytes, use `string-bytes'. */) 143 To get the number of bytes, use `string-bytes'. */)
144 (sequence) 144 (sequence)
145 register Lisp_Object sequence; 145 register Lisp_Object sequence;
146 { 146 {
147 register Lisp_Object val; 147 register Lisp_Object val;
148 register int i; 148 register int i;
149 149
150 if (STRINGP (sequence)) 150 if (STRINGP (sequence))
151 XSETFASTINT (val, SCHARS (sequence)); 151 XSETFASTINT (val, SCHARS (sequence));
152 else if (VECTORP (sequence)) 152 else if (VECTORP (sequence))
153 XSETFASTINT (val, XVECTOR (sequence)->size); 153 XSETFASTINT (val, ASIZE (sequence));
154 else if (SUB_CHAR_TABLE_P (sequence)) 154 else if (SUB_CHAR_TABLE_P (sequence))
155 XSETFASTINT (val, SUB_CHAR_TABLE_ORDINARY_SLOTS); 155 XSETFASTINT (val, SUB_CHAR_TABLE_ORDINARY_SLOTS);
156 else if (CHAR_TABLE_P (sequence)) 156 else if (CHAR_TABLE_P (sequence))
157 XSETFASTINT (val, MAX_CHAR); 157 XSETFASTINT (val, MAX_CHAR);
158 else if (BOOL_VECTOR_P (sequence)) 158 else if (BOOL_VECTOR_P (sequence))
159 XSETFASTINT (val, XBOOL_VECTOR (sequence)->size); 159 XSETFASTINT (val, XBOOL_VECTOR (sequence)->size);
160 else if (COMPILEDP (sequence)) 160 else if (COMPILEDP (sequence))
161 XSETFASTINT (val, XVECTOR (sequence)->size & PSEUDOVECTOR_SIZE_MASK); 161 XSETFASTINT (val, ASIZE (sequence) & PSEUDOVECTOR_SIZE_MASK);
162 else if (CONSP (sequence)) 162 else if (CONSP (sequence))
163 { 163 {
164 i = 0; 164 i = 0;
165 while (CONSP (sequence)) 165 while (CONSP (sequence))
166 { 166 {
191 191
192 DEFUN ("safe-length", Fsafe_length, Ssafe_length, 1, 1, 0, 192 DEFUN ("safe-length", Fsafe_length, Ssafe_length, 1, 1, 0,
193 doc: /* Return the length of a list, but avoid error or infinite loop. 193 doc: /* Return the length of a list, but avoid error or infinite loop.
194 This function never gets an error. If LIST is not really a list, 194 This function never gets an error. If LIST is not really a list,
195 it returns 0. If LIST is circular, it returns a finite value 195 it returns 0. If LIST is circular, it returns a finite value
196 which is at least the number of distinct elements. */) 196 which is at least the number of distinct elements. */)
197 (list) 197 (list)
198 Lisp_Object list; 198 Lisp_Object list;
199 { 199 {
200 Lisp_Object tail, halftail, length; 200 Lisp_Object tail, halftail, length;
201 int len = 0; 201 int len = 0;
215 return length; 215 return length;
216 } 216 }
217 217
218 DEFUN ("string-bytes", Fstring_bytes, Sstring_bytes, 1, 1, 0, 218 DEFUN ("string-bytes", Fstring_bytes, Sstring_bytes, 1, 1, 0,
219 doc: /* Return the number of bytes in STRING. 219 doc: /* Return the number of bytes in STRING.
220 If STRING is a multibyte string, this is greater than the length of STRING. */) 220 If STRING is a multibyte string, this is greater than the length of STRING. */)
221 (string) 221 (string)
222 Lisp_Object string; 222 Lisp_Object string;
223 { 223 {
224 CHECK_STRING (string); 224 CHECK_STRING (string);
225 return make_number (SBYTES (string)); 225 return make_number (SBYTES (string));
226 } 226 }
227 227
228 DEFUN ("string-equal", Fstring_equal, Sstring_equal, 2, 2, 0, 228 DEFUN ("string-equal", Fstring_equal, Sstring_equal, 2, 2, 0,
229 doc: /* Return t if two strings have identical contents. 229 doc: /* Return t if two strings have identical contents.
230 Case is significant, but text properties are ignored. 230 Case is significant, but text properties are ignored.
231 Symbols are also allowed; their print names are used instead. */) 231 Symbols are also allowed; their print names are used instead. */)
232 (s1, s2) 232 (s1, s2)
233 register Lisp_Object s1, s2; 233 register Lisp_Object s1, s2;
234 { 234 {
235 if (SYMBOLP (s1)) 235 if (SYMBOLP (s1))
236 s1 = SYMBOL_NAME (s1); 236 s1 = SYMBOL_NAME (s1);
258 258
259 The value is t if the strings (or specified portions) match. 259 The value is t if the strings (or specified portions) match.
260 If string STR1 is less, the value is a negative number N; 260 If string STR1 is less, the value is a negative number N;
261 - 1 - N is the number of characters that match at the beginning. 261 - 1 - N is the number of characters that match at the beginning.
262 If string STR1 is greater, the value is a positive number N; 262 If string STR1 is greater, the value is a positive number N;
263 N - 1 is the number of characters that match at the beginning. */) 263 N - 1 is the number of characters that match at the beginning. */)
264 (str1, start1, end1, str2, start2, end2, ignore_case) 264 (str1, start1, end1, str2, start2, end2, ignore_case)
265 Lisp_Object str1, start1, end1, start2, str2, end2, ignore_case; 265 Lisp_Object str1, start1, end1, start2, str2, end2, ignore_case;
266 { 266 {
267 register int end1_char, end2_char; 267 register int end1_char, end2_char;
268 register int i1, i1_byte, i2, i2_byte; 268 register int i1, i1_byte, i2, i2_byte;
350 } 350 }
351 351
352 DEFUN ("string-lessp", Fstring_lessp, Sstring_lessp, 2, 2, 0, 352 DEFUN ("string-lessp", Fstring_lessp, Sstring_lessp, 2, 2, 0,
353 doc: /* Return t if first arg string is less than second in lexicographic order. 353 doc: /* Return t if first arg string is less than second in lexicographic order.
354 Case is significant. 354 Case is significant.
355 Symbols are also allowed; their print names are used instead. */) 355 Symbols are also allowed; their print names are used instead. */)
356 (s1, s2) 356 (s1, s2)
357 register Lisp_Object s1, s2; 357 register Lisp_Object s1, s2;
358 { 358 {
359 register int end; 359 register int end;
360 register int i1, i1_byte, i2, i2_byte; 360 register int i1, i1_byte, i2, i2_byte;
389 389
390 #if __GNUC__ 390 #if __GNUC__
391 /* "gcc -O3" enables automatic function inlining, which optimizes out 391 /* "gcc -O3" enables automatic function inlining, which optimizes out
392 the arguments for the invocations of this function, whereas it 392 the arguments for the invocations of this function, whereas it
393 expects these values on the stack. */ 393 expects these values on the stack. */
394 static Lisp_Object concat () __attribute__((noinline)); 394 static Lisp_Object concat P_ ((int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special)) __attribute__((noinline));
395 #else /* !__GNUC__ */
396 static Lisp_Object concat P_ ((int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special));
395 #endif 397 #endif
396 398
397 /* ARGSUSED */ 399 /* ARGSUSED */
398 Lisp_Object 400 Lisp_Object
399 concat2 (s1, s2) 401 concat2 (s1, s2)
486 488
487 489
488 DEFUN ("copy-sequence", Fcopy_sequence, Scopy_sequence, 1, 1, 0, 490 DEFUN ("copy-sequence", Fcopy_sequence, Scopy_sequence, 1, 1, 0,
489 doc: /* Return a copy of a list, vector, string or char-table. 491 doc: /* Return a copy of a list, vector, string or char-table.
490 The elements of a list or vector are not copied; they are shared 492 The elements of a list or vector are not copied; they are shared
491 with the original. */) 493 with the original. */)
492 (arg) 494 (arg)
493 Lisp_Object arg; 495 Lisp_Object arg;
494 { 496 {
495 if (NILP (arg)) return arg; 497 if (NILP (arg)) return arg;
496 498
613 int this_len_byte; 615 int this_len_byte;
614 616
615 if (VECTORP (this)) 617 if (VECTORP (this))
616 for (i = 0; i < len; i++) 618 for (i = 0; i < len; i++)
617 { 619 {
618 ch = XVECTOR (this)->contents[i]; 620 ch = AREF (this, i);
619 CHECK_NUMBER (ch); 621 CHECK_NUMBER (ch);
620 this_len_byte = CHAR_BYTES (XINT (ch)); 622 this_len_byte = CHAR_BYTES (XINT (ch));
621 result_len_byte += this_len_byte; 623 result_len_byte += this_len_byte;
622 if (!SINGLE_BYTE_CHAR_P (XINT (ch))) 624 if (!SINGLE_BYTE_CHAR_P (XINT (ch)))
623 some_multibyte = 1; 625 some_multibyte = 1;
766 else 768 else
767 elt = Qnil; 769 elt = Qnil;
768 thisindex++; 770 thisindex++;
769 } 771 }
770 else 772 else
771 elt = XVECTOR (this)->contents[thisindex++]; 773 elt = AREF (this, thisindex++);
772 774
773 /* Store this element into the result. */ 775 /* Store this element into the result. */
774 if (toindex < 0) 776 if (toindex < 0)
775 { 777 {
776 XSETCAR (tail, elt); 778 XSETCAR (tail, elt);
777 prev = tail; 779 prev = tail;
778 tail = XCDR (tail); 780 tail = XCDR (tail);
779 } 781 }
780 else if (VECTORP (val)) 782 else if (VECTORP (val))
781 XVECTOR (val)->contents[toindex++] = elt; 783 AREF (val, toindex++) = elt;
782 else 784 else
783 { 785 {
784 CHECK_NUMBER (elt); 786 CHECK_NUMBER (elt);
785 if (SINGLE_BYTE_CHAR_P (XINT (elt))) 787 if (SINGLE_BYTE_CHAR_P (XINT (elt)))
786 { 788 {
1107 1, 1, 0, 1109 1, 1, 0,
1108 doc: /* Return the unibyte equivalent of STRING. 1110 doc: /* Return the unibyte equivalent of STRING.
1109 Multibyte character codes are converted to unibyte according to 1111 Multibyte character codes are converted to unibyte according to
1110 `nonascii-translation-table' or, if that is nil, `nonascii-insert-offset'. 1112 `nonascii-translation-table' or, if that is nil, `nonascii-insert-offset'.
1111 If the lookup in the translation table fails, this function takes just 1113 If the lookup in the translation table fails, this function takes just
1112 the low 8 bits of each character. */) 1114 the low 8 bits of each character. */)
1113 (string) 1115 (string)
1114 Lisp_Object string; 1116 Lisp_Object string;
1115 { 1117 {
1116 CHECK_STRING (string); 1118 CHECK_STRING (string);
1117 1119
1257 { 1259 {
1258 size = SCHARS (string); 1260 size = SCHARS (string);
1259 size_byte = SBYTES (string); 1261 size_byte = SBYTES (string);
1260 } 1262 }
1261 else 1263 else
1262 size = XVECTOR (string)->size; 1264 size = ASIZE (string);
1263 1265
1264 if (NILP (to)) 1266 if (NILP (to))
1265 { 1267 {
1266 to_char = size; 1268 to_char = size;
1267 to_byte = size_byte; 1269 to_byte = size_byte;
1295 STRING_MULTIBYTE (string)); 1297 STRING_MULTIBYTE (string));
1296 copy_text_properties (make_number (from_char), make_number (to_char), 1298 copy_text_properties (make_number (from_char), make_number (to_char),
1297 string, make_number (0), res, Qnil); 1299 string, make_number (0), res, Qnil);
1298 } 1300 }
1299 else 1301 else
1300 res = Fvector (to_char - from_char, 1302 res = Fvector (to_char - from_char, &AREF (string, from_char));
1301 XVECTOR (string)->contents + from_char);
1302 1303
1303 return res; 1304 return res;
1304 } 1305 }
1305 1306
1306 1307
1380 { 1381 {
1381 size = SCHARS (string); 1382 size = SCHARS (string);
1382 size_byte = SBYTES (string); 1383 size_byte = SBYTES (string);
1383 } 1384 }
1384 else 1385 else
1385 size = XVECTOR (string)->size; 1386 size = ASIZE (string);
1386 1387
1387 if (!(0 <= from && from <= to && to <= size)) 1388 if (!(0 <= from && from <= to && to <= size))
1388 args_out_of_range_3 (string, make_number (from), make_number (to)); 1389 args_out_of_range_3 (string, make_number (from), make_number (to));
1389 1390
1390 if (STRINGP (string)) 1391 if (STRINGP (string))
1394 STRING_MULTIBYTE (string)); 1395 STRING_MULTIBYTE (string));
1395 copy_text_properties (make_number (from), make_number (to), 1396 copy_text_properties (make_number (from), make_number (to),
1396 string, make_number (0), res, Qnil); 1397 string, make_number (0), res, Qnil);
1397 } 1398 }
1398 else 1399 else
1399 res = Fvector (to - from, 1400 res = Fvector (to - from, &AREF (string, from));
1400 XVECTOR (string)->contents + from);
1401 1401
1402 return res; 1402 return res;
1403 } 1403 }
1404 1404
1405 DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0, 1405 DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0,
2241 break; 2241 break;
2242 2242
2243 case Lisp_Vectorlike: 2243 case Lisp_Vectorlike:
2244 { 2244 {
2245 register int i; 2245 register int i;
2246 EMACS_INT size = XVECTOR (o1)->size; 2246 EMACS_INT size = ASIZE (o1);
2247 /* Pseudovectors have the type encoded in the size field, so this test 2247 /* Pseudovectors have the type encoded in the size field, so this test
2248 actually checks that the objects have the same type as well as the 2248 actually checks that the objects have the same type as well as the
2249 same size. */ 2249 same size. */
2250 if (XVECTOR (o2)->size != size) 2250 if (ASIZE (o2) != size)
2251 return 0; 2251 return 0;
2252 /* Boolvectors are compared much like strings. */ 2252 /* Boolvectors are compared much like strings. */
2253 if (BOOL_VECTOR_P (o1)) 2253 if (BOOL_VECTOR_P (o1))
2254 { 2254 {
2255 int size_in_chars 2255 int size_in_chars
2275 size &= PSEUDOVECTOR_SIZE_MASK; 2275 size &= PSEUDOVECTOR_SIZE_MASK;
2276 } 2276 }
2277 for (i = 0; i < size; i++) 2277 for (i = 0; i < size; i++)
2278 { 2278 {
2279 Lisp_Object v1, v2; 2279 Lisp_Object v1, v2;
2280 v1 = XVECTOR (o1)->contents [i]; 2280 v1 = AREF (o1, i);
2281 v2 = XVECTOR (o2)->contents [i]; 2281 v2 = AREF (o2, i);
2282 if (!internal_equal (v1, v2, depth + 1, props)) 2282 if (!internal_equal (v1, v2, depth + 1, props))
2283 return 0; 2283 return 0;
2284 } 2284 }
2285 return 1; 2285 return 1;
2286 } 2286 }
2317 { 2317 {
2318 register int size, index, charval; 2318 register int size, index, charval;
2319 if (VECTORP (array)) 2319 if (VECTORP (array))
2320 { 2320 {
2321 register Lisp_Object *p = XVECTOR (array)->contents; 2321 register Lisp_Object *p = XVECTOR (array)->contents;
2322 size = XVECTOR (array)->size; 2322 size = ASIZE (array);
2323 for (index = 0; index < size; index++) 2323 for (index = 0; index < size; index++)
2324 p[index] = item; 2324 p[index] = item;
2325 } 2325 }
2326 else if (CHAR_TABLE_P (array)) 2326 else if (CHAR_TABLE_P (array))
2327 { 2327 {
2545 { 2545 {
2546 Lisp_Object charset_info; 2546 Lisp_Object charset_info;
2547 2547
2548 charset_info = Fget (range, Qcharset); 2548 charset_info = Fget (range, Qcharset);
2549 CHECK_VECTOR (charset_info); 2549 CHECK_VECTOR (charset_info);
2550 charset_id = XINT (XVECTOR (charset_info)->contents[0]); 2550 charset_id = XINT (AREF (charset_info, 0));
2551 ch = Fmake_char_internal (make_number (charset_id), 2551 ch = Fmake_char_internal (make_number (charset_id),
2552 make_number (0), make_number (0)); 2552 make_number (0), make_number (0));
2553 } 2553 }
2554 else if (VECTORP (range)) 2554 else if (VECTORP (range))
2555 { 2555 {
2671 } 2671 }
2672 else if (INTEGERP (range)) 2672 else if (INTEGERP (range))
2673 Faset (char_table, range, value); 2673 Faset (char_table, range, value);
2674 else if (VECTORP (range)) 2674 else if (VECTORP (range))
2675 { 2675 {
2676 int size = XVECTOR (range)->size; 2676 int size = ASIZE (range);
2677 Lisp_Object *val = XVECTOR (range)->contents; 2677 Lisp_Object *val = XVECTOR (range)->contents;
2678 Lisp_Object ch = Fmake_char_internal (size <= 0 ? Qnil : val[0], 2678 Lisp_Object ch = Fmake_char_internal (size <= 0 ? Qnil : val[0],
2679 size <= 1 ? Qnil : val[1], 2679 size <= 1 ? Qnil : val[1],
2680 size <= 2 ? Qnil : val[2]); 2680 size <= 2 ? Qnil : val[2]);
2681 Faset (char_table, ch, value); 2681 Faset (char_table, ch, value);
3057 gcpro1.nvars = leni; 3057 gcpro1.nvars = leni;
3058 } 3058 }
3059 else 3059 else
3060 GCPRO2 (fn, seq); 3060 GCPRO2 (fn, seq);
3061 /* We need not explicitly protect `tail' because it is used only on lists, and 3061 /* We need not explicitly protect `tail' because it is used only on lists, and
3062 1) lists are not relocated and 2) the list is marked via `seq' so will not be freed */ 3062 1) lists are not relocated and 2) the list is marked via `seq' so will not
3063 be freed */
3063 3064
3064 if (VECTORP (seq)) 3065 if (VECTORP (seq))
3065 { 3066 {
3066 for (i = 0; i < leni; i++) 3067 for (i = 0; i < leni; i++)
3067 { 3068 {
3068 dummy = XVECTOR (seq)->contents[i]; 3069 dummy = call1 (fn, AREF (seq, i));
3069 dummy = call1 (fn, dummy);
3070 if (vals) 3070 if (vals)
3071 vals[i] = dummy; 3071 vals[i] = dummy;
3072 } 3072 }
3073 } 3073 }
3074 else if (BOOL_VECTOR_P (seq)) 3074 else if (BOOL_VECTOR_P (seq))
3075 { 3075 {
3076 for (i = 0; i < leni; i++) 3076 for (i = 0; i < leni; i++)
3077 { 3077 {
3078 int byte; 3078 int byte;
3079 byte = XBOOL_VECTOR (seq)->data[i / BOOL_VECTOR_BITS_PER_CHAR]; 3079 byte = XBOOL_VECTOR (seq)->data[i / BOOL_VECTOR_BITS_PER_CHAR];
3080 if (byte & (1 << (i % BOOL_VECTOR_BITS_PER_CHAR))) 3080 dummy = (byte & (1 << (i % BOOL_VECTOR_BITS_PER_CHAR))) ? Qt : Qnil;
3081 dummy = Qt;
3082 else
3083 dummy = Qnil;
3084
3085 dummy = call1 (fn, dummy); 3081 dummy = call1 (fn, dummy);
3086 if (vals) 3082 if (vals)
3087 vals[i] = dummy; 3083 vals[i] = dummy;
3088 } 3084 }
3089 } 3085 }
3462 3458
3463 DEFUN ("featurep", Ffeaturep, Sfeaturep, 1, 2, 0, 3459 DEFUN ("featurep", Ffeaturep, Sfeaturep, 1, 2, 0,
3464 doc: /* Returns t if FEATURE is present in this Emacs. 3460 doc: /* Returns t if FEATURE is present in this Emacs.
3465 3461
3466 Use this to conditionalize execution of lisp code based on the 3462 Use this to conditionalize execution of lisp code based on the
3467 presence or absence of emacs or environment extensions. 3463 presence or absence of Emacs or environment extensions.
3468 Use `provide' to declare that a feature is available. This function 3464 Use `provide' to declare that a feature is available. This function
3469 looks at the value of the variable `features'. The optional argument 3465 looks at the value of the variable `features'. The optional argument
3470 SUBFEATURE can be used to check a specific subfeature of FEATURE. */) 3466 SUBFEATURE can be used to check a specific subfeature of FEATURE. */)
3471 (feature, subfeature) 3467 (feature, subfeature)
3472 Lisp_Object feature, subfeature; 3468 Lisp_Object feature, subfeature;
4383 { 4379 {
4384 struct Lisp_Vector *v; 4380 struct Lisp_Vector *v;
4385 int i, old_size; 4381 int i, old_size;
4386 4382
4387 xassert (VECTORP (vec)); 4383 xassert (VECTORP (vec));
4388 old_size = XVECTOR (vec)->size; 4384 old_size = ASIZE (vec);
4389 xassert (new_size >= old_size); 4385 xassert (new_size >= old_size);
4390 4386
4391 v = allocate_vector (new_size); 4387 v = allocate_vector (new_size);
4392 bcopy (XVECTOR (vec)->contents, v->contents, 4388 bcopy (XVECTOR (vec)->contents, v->contents,
4393 old_size * sizeof *v->contents); 4389 old_size * sizeof *v->contents);
4715 /* Rehash. */ 4711 /* Rehash. */
4716 for (i = 0; i < old_size; ++i) 4712 for (i = 0; i < old_size; ++i)
4717 if (!NILP (HASH_HASH (h, i))) 4713 if (!NILP (HASH_HASH (h, i)))
4718 { 4714 {
4719 unsigned hash_code = XUINT (HASH_HASH (h, i)); 4715 unsigned hash_code = XUINT (HASH_HASH (h, i));
4720 int start_of_bucket = hash_code % XVECTOR (h->index)->size; 4716 int start_of_bucket = hash_code % ASIZE (h->index);
4721 HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket); 4717 HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket);
4722 HASH_INDEX (h, start_of_bucket) = make_number (i); 4718 HASH_INDEX (h, start_of_bucket) = make_number (i);
4723 } 4719 }
4724 } 4720 }
4725 } 4721 }
4741 4737
4742 hash_code = h->hashfn (h, key); 4738 hash_code = h->hashfn (h, key);
4743 if (hash) 4739 if (hash)
4744 *hash = hash_code; 4740 *hash = hash_code;
4745 4741
4746 start_of_bucket = hash_code % XVECTOR (h->index)->size; 4742 start_of_bucket = hash_code % ASIZE (h->index);
4747 idx = HASH_INDEX (h, start_of_bucket); 4743 idx = HASH_INDEX (h, start_of_bucket);
4748 4744
4749 /* We need not gcpro idx since it's either an integer or nil. */ 4745 /* We need not gcpro idx since it's either an integer or nil. */
4750 while (!NILP (idx)) 4746 while (!NILP (idx))
4751 { 4747 {
4788 4784
4789 /* Remember its hash code. */ 4785 /* Remember its hash code. */
4790 HASH_HASH (h, i) = make_number (hash); 4786 HASH_HASH (h, i) = make_number (hash);
4791 4787
4792 /* Add new entry to its collision chain. */ 4788 /* Add new entry to its collision chain. */
4793 start_of_bucket = hash % XVECTOR (h->index)->size; 4789 start_of_bucket = hash % ASIZE (h->index);
4794 HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket); 4790 HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket);
4795 HASH_INDEX (h, start_of_bucket) = make_number (i); 4791 HASH_INDEX (h, start_of_bucket) = make_number (i);
4796 return i; 4792 return i;
4797 } 4793 }
4798 4794
4807 unsigned hash_code; 4803 unsigned hash_code;
4808 int start_of_bucket; 4804 int start_of_bucket;
4809 Lisp_Object idx, prev; 4805 Lisp_Object idx, prev;
4810 4806
4811 hash_code = h->hashfn (h, key); 4807 hash_code = h->hashfn (h, key);
4812 start_of_bucket = hash_code % XVECTOR (h->index)->size; 4808 start_of_bucket = hash_code % ASIZE (h->index);
4813 idx = HASH_INDEX (h, start_of_bucket); 4809 idx = HASH_INDEX (h, start_of_bucket);
4814 prev = Qnil; 4810 prev = Qnil;
4815 4811
4816 /* We need not gcpro idx, prev since they're either integers or nil. */ 4812 /* We need not gcpro idx, prev since they're either integers or nil. */
4817 while (!NILP (idx)) 4813 while (!NILP (idx))
4863 HASH_KEY (h, i) = Qnil; 4859 HASH_KEY (h, i) = Qnil;
4864 HASH_VALUE (h, i) = Qnil; 4860 HASH_VALUE (h, i) = Qnil;
4865 HASH_HASH (h, i) = Qnil; 4861 HASH_HASH (h, i) = Qnil;
4866 } 4862 }
4867 4863
4868 for (i = 0; i < XVECTOR (h->index)->size; ++i) 4864 for (i = 0; i < ASIZE (h->index); ++i)
4869 XVECTOR (h->index)->contents[i] = Qnil; 4865 AREF (h->index, i) = Qnil;
4870 4866
4871 h->next_free = make_number (0); 4867 h->next_free = make_number (0);
4872 h->count = make_number (0); 4868 h->count = make_number (0);
4873 } 4869 }
4874 } 4870 }
4889 struct Lisp_Hash_Table *h; 4885 struct Lisp_Hash_Table *h;
4890 int remove_entries_p; 4886 int remove_entries_p;
4891 { 4887 {
4892 int bucket, n, marked; 4888 int bucket, n, marked;
4893 4889
4894 n = XVECTOR (h->index)->size & ~ARRAY_MARK_FLAG; 4890 n = ASIZE (h->index) & ~ARRAY_MARK_FLAG;
4895 marked = 0; 4891 marked = 0;
4896 4892
4897 for (bucket = 0; bucket < n; ++bucket) 4893 for (bucket = 0; bucket < n; ++bucket)
4898 { 4894 {
4899 Lisp_Object idx, next, prev; 4895 Lisp_Object idx, next, prev;
5103 static unsigned 5099 static unsigned
5104 sxhash_vector (vec, depth) 5100 sxhash_vector (vec, depth)
5105 Lisp_Object vec; 5101 Lisp_Object vec;
5106 int depth; 5102 int depth;
5107 { 5103 {
5108 unsigned hash = XVECTOR (vec)->size; 5104 unsigned hash = ASIZE (vec);
5109 int i, n; 5105 int i, n;
5110 5106
5111 n = min (SXHASH_MAX_LEN, XVECTOR (vec)->size); 5107 n = min (SXHASH_MAX_LEN, ASIZE (vec));
5112 for (i = 0; i < n; ++i) 5108 for (i = 0; i < n; ++i)
5113 { 5109 {
5114 unsigned hash2 = sxhash (XVECTOR (vec)->contents[i], depth + 1); 5110 unsigned hash2 = sxhash (AREF (vec, i), depth + 1);
5115 hash = SXHASH_COMBINE (hash, hash2); 5111 hash = SXHASH_COMBINE (hash, hash2);
5116 } 5112 }
5117 5113
5118 return hash; 5114 return hash;
5119 } 5115 }
5804 staticpro (&require_nesting_list); 5800 staticpro (&require_nesting_list);
5805 5801
5806 Fset (Qyes_or_no_p_history, Qnil); 5802 Fset (Qyes_or_no_p_history, Qnil);
5807 5803
5808 DEFVAR_LISP ("features", &Vfeatures, 5804 DEFVAR_LISP ("features", &Vfeatures,
5809 doc: /* A list of symbols which are the features of the executing emacs. 5805 doc: /* A list of symbols which are the features of the executing Emacs.
5810 Used by `featurep' and `require', and altered by `provide'. */); 5806 Used by `featurep' and `require', and altered by `provide'. */);
5811 Vfeatures = Fcons (intern ("emacs"), Qnil); 5807 Vfeatures = Fcons (intern ("emacs"), Qnil);
5812 Qsubfeatures = intern ("subfeatures"); 5808 Qsubfeatures = intern ("subfeatures");
5813 staticpro (&Qsubfeatures); 5809 staticpro (&Qsubfeatures);
5814 5810