aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarl Heuer1994-09-27 02:58:30 +0000
committerKarl Heuer1994-09-27 02:58:30 +0000
commit7650760ef8fa2f89739cb235e09f172073f1c902 (patch)
treeecdb34e09e8749d3f27d9416d070312f7a0b7bd9 /src
parente35d291dabddafd5da137b2a387b61cfea4c567e (diff)
downloademacs-7650760ef8fa2f89739cb235e09f172073f1c902.tar.gz
emacs-7650760ef8fa2f89739cb235e09f172073f1c902.zip
(Frandom, Flength, Fstring_equal, Fstring_lessp, Fcopy_sequence, concat, Felt,
internal_equal, Ffillarray, mapcar1): Use type test macros.
Diffstat (limited to 'src')
-rw-r--r--src/fns.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/src/fns.c b/src/fns.c
index aa1489afb50..8eede17b37c 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -64,7 +64,7 @@ With argument t, set the random number seed from the current time and pid.")
64 64
65 if (EQ (limit, Qt)) 65 if (EQ (limit, Qt))
66 srandom (getpid () + time (0)); 66 srandom (getpid () + time (0));
67 if (XTYPE (limit) == Lisp_Int && XINT (limit) > 0) 67 if (INTEGERP (limit) && XINT (limit) > 0)
68 { 68 {
69 if (XFASTINT (limit) >= 0x40000000) 69 if (XFASTINT (limit) >= 0x40000000)
70 /* This case may occur on 64-bit machines. */ 70 /* This case may occur on 64-bit machines. */
@@ -101,8 +101,7 @@ A byte-code function object is also allowed.")
101 register int i; 101 register int i;
102 102
103 retry: 103 retry:
104 if (XTYPE (obj) == Lisp_Vector || XTYPE (obj) == Lisp_String 104 if (VECTORP (obj) || STRINGP (obj) || COMPILEDP (obj))
105 || XTYPE (obj) == Lisp_Compiled)
106 return Farray_length (obj); 105 return Farray_length (obj);
107 else if (CONSP (obj)) 106 else if (CONSP (obj))
108 { 107 {
@@ -134,9 +133,9 @@ Symbols are also allowed; their print names are used instead.")
134 (s1, s2) 133 (s1, s2)
135 register Lisp_Object s1, s2; 134 register Lisp_Object s1, s2;
136{ 135{
137 if (XTYPE (s1) == Lisp_Symbol) 136 if (SYMBOLP (s1))
138 XSETSTRING (s1, XSYMBOL (s1)->name), XSETTYPE (s1, Lisp_String); 137 XSETSTRING (s1, XSYMBOL (s1)->name), XSETTYPE (s1, Lisp_String);
139 if (XTYPE (s2) == Lisp_Symbol) 138 if (SYMBOLP (s2))
140 XSETSTRING (s2, XSYMBOL (s2)->name), XSETTYPE (s2, Lisp_String); 139 XSETSTRING (s2, XSYMBOL (s2)->name), XSETTYPE (s2, Lisp_String);
141 CHECK_STRING (s1, 0); 140 CHECK_STRING (s1, 0);
142 CHECK_STRING (s2, 1); 141 CHECK_STRING (s2, 1);
@@ -158,9 +157,9 @@ Symbols are also allowed; their print names are used instead.")
158 register unsigned char *p1, *p2; 157 register unsigned char *p1, *p2;
159 register int end; 158 register int end;
160 159
161 if (XTYPE (s1) == Lisp_Symbol) 160 if (SYMBOLP (s1))
162 XSETSTRING (s1, XSYMBOL (s1)->name), XSETTYPE (s1, Lisp_String); 161 XSETSTRING (s1, XSYMBOL (s1)->name), XSETTYPE (s1, Lisp_String);
163 if (XTYPE (s2) == Lisp_Symbol) 162 if (SYMBOLP (s2))
164 XSETSTRING (s2, XSYMBOL (s2)->name), XSETTYPE (s2, Lisp_String); 163 XSETSTRING (s2, XSYMBOL (s2)->name), XSETTYPE (s2, Lisp_String);
165 CHECK_STRING (s1, 0); 164 CHECK_STRING (s1, 0);
166 CHECK_STRING (s2, 1); 165 CHECK_STRING (s2, 1);
@@ -255,7 +254,7 @@ with the original.")
255 Lisp_Object arg; 254 Lisp_Object arg;
256{ 255{
257 if (NILP (arg)) return arg; 256 if (NILP (arg)) return arg;
258 if (!CONSP (arg) && XTYPE (arg) != Lisp_Vector && XTYPE (arg) != Lisp_String) 257 if (!CONSP (arg) && !VECTORP (arg) && !STRINGP (arg))
259 arg = wrong_type_argument (Qsequencep, arg); 258 arg = wrong_type_argument (Qsequencep, arg);
260 return concat (1, &arg, CONSP (arg) ? Lisp_Cons : XTYPE (arg), 0); 259 return concat (1, &arg, CONSP (arg) ? Lisp_Cons : XTYPE (arg), 0);
261} 260}
@@ -289,11 +288,10 @@ concat (nargs, args, target_type, last_special)
289 for (argnum = 0; argnum < nargs; argnum++) 288 for (argnum = 0; argnum < nargs; argnum++)
290 { 289 {
291 this = args[argnum]; 290 this = args[argnum];
292 if (!(CONSP (this) || NILP (this) 291 if (!(CONSP (this) || NILP (this) || VECTORP (this) || STRINGP (this)
293 || XTYPE (this) == Lisp_Vector || XTYPE (this) == Lisp_String 292 || COMPILEDP (this)))
294 || XTYPE (this) == Lisp_Compiled))
295 { 293 {
296 if (XTYPE (this) == Lisp_Int) 294 if (INTEGERP (this))
297 args[argnum] = Fnumber_to_string (this); 295 args[argnum] = Fnumber_to_string (this);
298 else 296 else
299 args[argnum] = wrong_type_argument (Qsequencep, this); 297 args[argnum] = wrong_type_argument (Qsequencep, this);
@@ -337,7 +335,7 @@ concat (nargs, args, target_type, last_special)
337 if (!CONSP (this)) 335 if (!CONSP (this))
338 thislen = Flength (this), thisleni = XINT (thislen); 336 thislen = Flength (this), thisleni = XINT (thislen);
339 337
340 if (XTYPE (this) == Lisp_String && XTYPE (val) == Lisp_String 338 if (STRINGP (this) && STRINGP (val)
341 && ! NULL_INTERVAL_P (XSTRING (this)->intervals)) 339 && ! NULL_INTERVAL_P (XSTRING (this)->intervals))
342 { 340 {
343 copy_text_properties (make_number (0), thislen, this, 341 copy_text_properties (make_number (0), thislen, this,
@@ -356,7 +354,7 @@ concat (nargs, args, target_type, last_special)
356 else 354 else
357 { 355 {
358 if (thisindex >= thisleni) break; 356 if (thisindex >= thisleni) break;
359 if (XTYPE (this) == Lisp_String) 357 if (STRINGP (this))
360 XFASTINT (elt) = XSTRING (this)->data[thisindex++]; 358 XFASTINT (elt) = XSTRING (this)->data[thisindex++];
361 else 359 else
362 elt = XVECTOR (this)->contents[thisindex++]; 360 elt = XVECTOR (this)->contents[thisindex++];
@@ -369,11 +367,11 @@ concat (nargs, args, target_type, last_special)
369 prev = tail; 367 prev = tail;
370 tail = XCONS (tail)->cdr; 368 tail = XCONS (tail)->cdr;
371 } 369 }
372 else if (XTYPE (val) == Lisp_Vector) 370 else if (VECTORP (val))
373 XVECTOR (val)->contents[toindex++] = elt; 371 XVECTOR (val)->contents[toindex++] = elt;
374 else 372 else
375 { 373 {
376 while (XTYPE (elt) != Lisp_Int) 374 while (!INTEGERP (elt))
377 elt = wrong_type_argument (Qintegerp, elt); 375 elt = wrong_type_argument (Qintegerp, elt);
378 { 376 {
379#ifdef MASSC_REGISTER_BUG 377#ifdef MASSC_REGISTER_BUG
@@ -486,10 +484,9 @@ DEFUN ("elt", Felt, Selt, 2, 2, 0,
486 CHECK_NUMBER (n, 0); 484 CHECK_NUMBER (n, 0);
487 while (1) 485 while (1)
488 { 486 {
489 if (XTYPE (seq) == Lisp_Cons || NILP (seq)) 487 if (CONSP (seq) || NILP (seq))
490 return Fcar (Fnthcdr (n, seq)); 488 return Fcar (Fnthcdr (n, seq));
491 else if (XTYPE (seq) == Lisp_String 489 else if (STRINGP (seq) || VECTORP (seq))
492 || XTYPE (seq) == Lisp_Vector)
493 return Faref (seq, n); 490 return Faref (seq, n);
494 else 491 else
495 seq = wrong_type_argument (Qsequencep, seq); 492 seq = wrong_type_argument (Qsequencep, seq);
@@ -889,8 +886,7 @@ do_cdr:
889 return (extract_float (o1) == extract_float (o2)) ? Qt : Qnil; 886 return (extract_float (o1) == extract_float (o2)) ? Qt : Qnil;
890#endif 887#endif
891 if (XTYPE (o1) != XTYPE (o2)) return Qnil; 888 if (XTYPE (o1) != XTYPE (o2)) return Qnil;
892 if (XTYPE (o1) == Lisp_Cons 889 if (CONSP (o1) || OVERLAYP (o1))
893 || XTYPE (o1) == Lisp_Overlay)
894 { 890 {
895 Lisp_Object v1; 891 Lisp_Object v1;
896 v1 = internal_equal (Fcar (o1), Fcar (o2), depth + 1); 892 v1 = internal_equal (Fcar (o1), Fcar (o2), depth + 1);
@@ -899,15 +895,14 @@ do_cdr:
899 o1 = Fcdr (o1), o2 = Fcdr (o2); 895 o1 = Fcdr (o1), o2 = Fcdr (o2);
900 goto do_cdr; 896 goto do_cdr;
901 } 897 }
902 if (XTYPE (o1) == Lisp_Marker) 898 if (MARKERP (o1))
903 { 899 {
904 return ((XMARKER (o1)->buffer == XMARKER (o2)->buffer 900 return ((XMARKER (o1)->buffer == XMARKER (o2)->buffer
905 && (XMARKER (o1)->buffer == 0 901 && (XMARKER (o1)->buffer == 0
906 || XMARKER (o1)->bufpos == XMARKER (o2)->bufpos)) 902 || XMARKER (o1)->bufpos == XMARKER (o2)->bufpos))
907 ? Qt : Qnil); 903 ? Qt : Qnil);
908 } 904 }
909 if (XTYPE (o1) == Lisp_Vector 905 if (VECTORP (o1) || COMPILEDP (o1))
910 || XTYPE (o1) == Lisp_Compiled)
911 { 906 {
912 register int index; 907 register int index;
913 if (XVECTOR (o1)->size != XVECTOR (o2)->size) 908 if (XVECTOR (o1)->size != XVECTOR (o2)->size)
@@ -922,7 +917,7 @@ do_cdr:
922 } 917 }
923 return Qt; 918 return Qt;
924 } 919 }
925 if (XTYPE (o1) == Lisp_String) 920 if (STRINGP (o1))
926 { 921 {
927 if (XSTRING (o1)->size != XSTRING (o2)->size) 922 if (XSTRING (o1)->size != XSTRING (o2)->size)
928 return Qnil; 923 return Qnil;
@@ -940,14 +935,14 @@ DEFUN ("fillarray", Ffillarray, Sfillarray, 2, 2, 0,
940{ 935{
941 register int size, index, charval; 936 register int size, index, charval;
942 retry: 937 retry:
943 if (XTYPE (array) == Lisp_Vector) 938 if (VECTORP (array))
944 { 939 {
945 register Lisp_Object *p = XVECTOR (array)->contents; 940 register Lisp_Object *p = XVECTOR (array)->contents;
946 size = XVECTOR (array)->size; 941 size = XVECTOR (array)->size;
947 for (index = 0; index < size; index++) 942 for (index = 0; index < size; index++)
948 p[index] = item; 943 p[index] = item;
949 } 944 }
950 else if (XTYPE (array) == Lisp_String) 945 else if (STRINGP (array))
951 { 946 {
952 register unsigned char *p = XSTRING (array)->data; 947 register unsigned char *p = XSTRING (array)->data;
953 CHECK_NUMBER (item, 1); 948 CHECK_NUMBER (item, 1);
@@ -1046,7 +1041,7 @@ mapcar1 (leni, vals, fn, seq)
1046 /* We need not explicitly protect `tail' because it is used only on lists, and 1041 /* We need not explicitly protect `tail' because it is used only on lists, and
1047 1) lists are not relocated and 2) the list is marked via `seq' so will not be freed */ 1042 1) lists are not relocated and 2) the list is marked via `seq' so will not be freed */
1048 1043
1049 if (XTYPE (seq) == Lisp_Vector) 1044 if (VECTORP (seq))
1050 { 1045 {
1051 for (i = 0; i < leni; i++) 1046 for (i = 0; i < leni; i++)
1052 { 1047 {
@@ -1054,7 +1049,7 @@ mapcar1 (leni, vals, fn, seq)
1054 vals[i] = call1 (fn, dummy); 1049 vals[i] = call1 (fn, dummy);
1055 } 1050 }
1056 } 1051 }
1057 else if (XTYPE (seq) == Lisp_String) 1052 else if (STRINGP (seq))
1058 { 1053 {
1059 for (i = 0; i < leni; i++) 1054 for (i = 0; i < leni; i++)
1060 { 1055 {