Mercurial > hg > xemacs-beta
comparison src/data.c @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 859a2309aef8 |
children | cf808b4c4290 |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
68 Lisp_Object Qfloatp; | 68 Lisp_Object Qfloatp; |
69 #endif | 69 #endif |
70 Lisp_Object Qnumberp, Qnumber_or_marker_p, Qnumber_char_or_marker_p; | 70 Lisp_Object Qnumberp, Qnumber_or_marker_p, Qnumber_char_or_marker_p; |
71 | 71 |
72 Lisp_Object Qweak_listp; | 72 Lisp_Object Qweak_listp; |
73 | |
74 #ifdef DEBUG_XEMACS | |
75 | |
76 int debug_issue_ebola_notices; | |
77 | |
78 int debug_ebola_backtrace_length; | |
79 | |
80 int | |
81 eq_with_ebola_notice (Lisp_Object obj1, Lisp_Object obj2) | |
82 { | |
83 if (((CHARP (obj1) && INTP (obj2)) || (CHARP (obj2) && INTP (obj1))) | |
84 && (debug_issue_ebola_notices >= 2 | |
85 || XREALINT (obj1) == XREALINT (obj2))) | |
86 { | |
87 stderr_out ("Ebola warning!! ("); | |
88 Fprinc (obj1, Qexternal_debugging_output); | |
89 stderr_out (" and "); | |
90 Fprinc (obj2, Qexternal_debugging_output); | |
91 stderr_out (")\n"); | |
92 debug_short_backtrace (debug_ebola_backtrace_length); | |
93 } | |
94 | |
95 return EQ (obj1, obj2); | |
96 } | |
97 | |
98 #endif /* DEBUG_XEMACS */ | |
99 | |
100 | |
73 | 101 |
74 Lisp_Object | 102 Lisp_Object |
75 wrong_type_argument (Lisp_Object predicate, Lisp_Object value) | 103 wrong_type_argument (Lisp_Object predicate, Lisp_Object value) |
76 { | 104 { |
77 /* This function can GC */ | 105 /* This function can GC */ |
175 futzing like with ints. */ | 203 futzing like with ints. */ |
176 Lisp_Object | 204 Lisp_Object |
177 make_char (Emchar num) | 205 make_char (Emchar num) |
178 { | 206 { |
179 Lisp_Object val; | 207 Lisp_Object val; |
180 val = make_int (num); | 208 /* Don't use XSETCHAR here -- it's defined in terms of make_char (). */ |
209 XSETOBJ (val, Lisp_Char, num); | |
181 return val; | 210 return val; |
182 } | 211 } |
183 | 212 |
184 /* Data type predicates */ | 213 /* Data type predicates */ |
185 | 214 |
186 DEFUN ("eq", Feq, 2, 2, 0, /* | 215 DEFUN ("eq", Feq, 2, 2, 0, /* |
187 T if the two args are the same Lisp object. | 216 T if the two args are the same Lisp object. |
188 */ | 217 */ |
189 (obj1, obj2)) | 218 (obj1, obj2)) |
190 { | 219 { |
191 return EQ (obj1, obj2) ? Qt : Qnil; | 220 return EQ_WITH_EBOLA_NOTICE (obj1, obj2) ? Qt : Qnil; |
221 } | |
222 | |
223 DEFUN ("old-eq", Fold_eq, 2, 2, 0, /* | |
224 T if the two args are (in most cases) the same Lisp object. | |
225 | |
226 Special kludge: A character is considered `old-eq' to its equivalent integer | |
227 even though they are not the same object and are in fact of different | |
228 types. This is ABSOLUTELY AND UTTERLY HORRENDOUS but is necessary to | |
229 preserve byte-code compatibility with v19. This kludge is known as the | |
230 \"char-int confoundance disease\" and appears in a number of other | |
231 functions with `old-foo' equivalents. | |
232 | |
233 Do not use this function! | |
234 */ | |
235 (obj1, obj2)) | |
236 { | |
237 /* The miscreant responsible for this blasphemy is known as | |
238 Richard M. Stallman, and he will burn in hell for it. */ | |
239 return HACKEQ_UNSAFE (obj1, obj2) ? Qt : Qnil; | |
192 } | 240 } |
193 | 241 |
194 DEFUN ("null", Fnull, 1, 1, 0, /* | 242 DEFUN ("null", Fnull, 1, 1, 0, /* |
195 T if OBJECT is nil. | 243 T if OBJECT is nil. |
196 */ | 244 */ |
344 } | 392 } |
345 | 393 |
346 | 394 |
347 DEFUN ("characterp", Fcharacterp, 1, 1, 0, /* | 395 DEFUN ("characterp", Fcharacterp, 1, 1, 0, /* |
348 t if OBJECT is a character. | 396 t if OBJECT is a character. |
349 A character is an integer that can be inserted into a buffer with | 397 Unlike in FSF Emacs, a character is its own primitive type. |
350 `insert-char'. All integers are considered valid characters and are | 398 Any character can be converted into an equivalent integer using |
351 modded with 256 to get the actual character to use. | 399 `char-int'. To convert the other way, use `int-char'; however, |
400 only some integers can be converted into characters. Such an integer | |
401 is called a `char-int'; see `char-int-p'. | |
402 | |
403 Some functions that work on integers (e.g. the comparison functions | |
404 <, <=, =, /=, etc. and the arithmetic functions +, -, *, etc.) | |
405 accept characters and implicitly convert them into integers. In | |
406 general, functions that work on characters also accept char-ints and | |
407 implicitly convert them into characters. WARNING: Neither of these | |
408 behaviors is very desirable, and they are maintained for backward | |
409 compatibility with old E-Lisp programs that confounded characters and | |
410 integers willy-nilly. These behaviors may change in the future; therefore, | |
411 do not rely on them. Instead, use the character-specific functions such | |
412 as `char='. | |
352 */ | 413 */ |
353 (object)) | 414 (object)) |
354 { | 415 { |
355 return CHARP (object) ? Qt : Qnil; | 416 return CHARP (object) ? Qt : Qnil; |
356 } | 417 } |
357 | 418 |
419 DEFUN ("char-int", Fchar_int, 1, 1, 0, /* | |
420 Convert a character into an equivalent integer. | |
421 The resulting integer will always be non-negative. The integers in | |
422 the range 0 - 255 map to characters as follows: | |
423 | |
424 0 - 31 Control set 0 | |
425 32 - 127 ASCII | |
426 128 - 159 Control set 1 | |
427 160 - 255 Right half of ISO-8859-1 | |
428 | |
429 If support for Mule does not exist, these are the only valid character | |
430 values. When Mule support exists, the values assigned to other characters | |
431 may vary depending on the particular version of XEmacs, the order in which | |
432 character sets were loaded, etc., and you should not depend on them. | |
433 */ | |
434 (ch)) | |
435 { | |
436 CHECK_CHAR (ch); | |
437 return make_int (XCHAR (ch)); | |
438 } | |
439 | |
440 DEFUN ("int-char", Fint_char, 1, 1, 0, /* | |
441 Convert an integer into the equivalent character. | |
442 Not all integers correspond to valid characters; use `char-int-p' to | |
443 determine whether this is the case. If the integer cannot be converted, | |
444 nil is returned. | |
445 */ | |
446 (integer)) | |
447 { | |
448 CHECK_INT (integer); | |
449 if (CHAR_INTP (integer)) | |
450 return make_char (XINT (integer)); | |
451 else | |
452 return Qnil; | |
453 } | |
454 | |
455 DEFUN ("char-int-p", Fchar_int_p, 1, 1, 0, /* | |
456 t if OBJECT is an integer that can be converted into a character. | |
457 See `char-int'. | |
458 */ | |
459 (object)) | |
460 { | |
461 return CHAR_INTP (object) ? Qt : Qnil; | |
462 } | |
463 | |
464 DEFUN ("char-or-char-int-p", Fchar_or_char_int_p, 1, 1, 0, /* | |
465 t if OBJECT is a character or an integer that can be converted into one. | |
466 */ | |
467 (object)) | |
468 { | |
469 return CHAR_OR_CHAR_INTP (object) ? Qt : Qnil; | |
470 } | |
471 | |
358 DEFUN ("char-or-string-p", Fchar_or_string_p, 1, 1, 0, /* | 472 DEFUN ("char-or-string-p", Fchar_or_string_p, 1, 1, 0, /* |
359 t if OBJECT is a character or a string. | 473 t if OBJECT is a character (or a char-int) or a string. |
474 It is semi-hateful that we allow a char-int here, as it goes against | |
475 the name of this function, but it makes the most sense considering the | |
476 other steps we take to maintain compatibility with the old character/integer | |
477 confoundedness in older versions of E-Lisp. | |
360 */ | 478 */ |
361 (object)) | 479 (object)) |
362 { | 480 { |
363 return CHAR_OR_CHAR_INTP (object) || STRINGP (object) ? Qt : Qnil; | 481 return CHAR_OR_CHAR_INTP (object) || STRINGP (object) ? Qt : Qnil; |
364 } | 482 } |
377 (object)) | 495 (object)) |
378 { | 496 { |
379 return INTP (object) || MARKERP (object) ? Qt : Qnil; | 497 return INTP (object) || MARKERP (object) ? Qt : Qnil; |
380 } | 498 } |
381 | 499 |
500 DEFUN ("integer-or-char-p", Finteger_or_char_p, 1, 1, 0, /* | |
501 t if OBJECT is an integer or a character. | |
502 */ | |
503 (object)) | |
504 { | |
505 return INTP (object) || CHARP (object) ? Qt : Qnil; | |
506 } | |
507 | |
508 DEFUN ("integer-char-or-marker-p", Finteger_char_or_marker_p, 1, 1, 0, /* | |
509 t if OBJECT is an integer, character or a marker (editor pointer). | |
510 */ | |
511 (object)) | |
512 { | |
513 return INTP (object) || CHARP (object) || MARKERP (object) ? Qt : Qnil; | |
514 } | |
515 | |
382 DEFUN ("natnump", Fnatnump, 1, 1, 0, /* | 516 DEFUN ("natnump", Fnatnump, 1, 1, 0, /* |
383 t if OBJECT is a nonnegative integer. | 517 t if OBJECT is a nonnegative integer. |
384 */ | 518 */ |
385 (object)) | 519 (object)) |
386 { | 520 { |
407 t if OBJECT is a number or a marker. | 541 t if OBJECT is a number or a marker. |
408 */ | 542 */ |
409 (object)) | 543 (object)) |
410 { | 544 { |
411 return INT_OR_FLOATP (object) || MARKERP (object) ? Qt : Qnil; | 545 return INT_OR_FLOATP (object) || MARKERP (object) ? Qt : Qnil; |
546 } | |
547 | |
548 DEFUN ("number-char-or-marker-p", Fnumber_char_or_marker_p, 1, 1, 0, /* | |
549 t if OBJECT is a number, character or a marker. | |
550 */ | |
551 (object)) | |
552 { | |
553 return (INT_OR_FLOATP (object) || | |
554 CHARP (object) || | |
555 MARKERP (object)) | |
556 ? Qt : Qnil; | |
412 } | 557 } |
413 | 558 |
414 #ifdef LISP_FLOAT_TYPE | 559 #ifdef LISP_FLOAT_TYPE |
415 DEFUN ("floatp", Ffloatp, 1, 1, 0, /* | 560 DEFUN ("floatp", Ffloatp, 1, 1, 0, /* |
416 t if OBJECT is a floating point number. | 561 t if OBJECT is a floating point number. |
428 { | 573 { |
429 if (CONSP (object)) return Qcons; | 574 if (CONSP (object)) return Qcons; |
430 if (SYMBOLP (object)) return Qsymbol; | 575 if (SYMBOLP (object)) return Qsymbol; |
431 if (KEYWORDP (object)) return Qkeyword; | 576 if (KEYWORDP (object)) return Qkeyword; |
432 if (INTP (object)) return Qinteger; | 577 if (INTP (object)) return Qinteger; |
578 if (CHARP (object)) return Qcharacter; | |
433 if (STRINGP (object)) return Qstring; | 579 if (STRINGP (object)) return Qstring; |
434 if (VECTORP (object)) return Qvector; | 580 if (VECTORP (object)) return Qvector; |
435 | 581 |
436 assert (LRECORDP (object)); | 582 assert (LRECORDP (object)); |
437 return intern (XRECORD_LHEADER (object)->implementation->name); | 583 return intern (XRECORD_LHEADER (object)->implementation->name); |
873 case grtr: return f1 > f2 ? Qt : Qnil; | 1019 case grtr: return f1 > f2 ? Qt : Qnil; |
874 case grtr_or_equal: return f1 >= f2 ? Qt : Qnil; | 1020 case grtr_or_equal: return f1 >= f2 ? Qt : Qnil; |
875 } | 1021 } |
876 } | 1022 } |
877 #endif /* LISP_FLOAT_TYPE */ | 1023 #endif /* LISP_FLOAT_TYPE */ |
878 | 1024 |
879 switch (comparison) | 1025 switch (comparison) |
880 { | 1026 { |
881 case equal: return XINT (num1) == XINT (num2) ? Qt : Qnil; | 1027 case equal: return XINT (num1) == XINT (num2) ? Qt : Qnil; |
882 case notequal: return XINT (num1) != XINT (num2) ? Qt : Qnil; | 1028 case notequal: return XINT (num1) != XINT (num2) ? Qt : Qnil; |
883 case less: return XINT (num1) < XINT (num2) ? Qt : Qnil; | 1029 case less: return XINT (num1) < XINT (num2) ? Qt : Qnil; |
889 abort (); | 1035 abort (); |
890 return Qnil; /* suppress compiler warning */ | 1036 return Qnil; /* suppress compiler warning */ |
891 } | 1037 } |
892 | 1038 |
893 DEFUN ("=", Feqlsign, 2, 2, 0, /* | 1039 DEFUN ("=", Feqlsign, 2, 2, 0, /* |
894 T if two args, both numbers or markers, are equal. | 1040 T if two args, both numbers, characters or markers, are equal. |
895 */ | 1041 */ |
896 (num1, num2)) | 1042 (num1, num2)) |
897 { | 1043 { |
898 return arithcompare (num1, num2, equal); | 1044 return arithcompare (num1, num2, equal); |
899 } | 1045 } |
900 | 1046 |
901 DEFUN ("<", Flss, 2, 2, 0, /* | 1047 DEFUN ("<", Flss, 2, 2, 0, /* |
902 T if first arg is less than second arg. | 1048 T if first arg is less than second arg. |
903 Both must be numbers or markers. | 1049 Both must be numbers, characters or markers. |
904 */ | 1050 */ |
905 (num1, num2)) | 1051 (num1, num2)) |
906 { | 1052 { |
907 return arithcompare (num1, num2, less); | 1053 return arithcompare (num1, num2, less); |
908 } | 1054 } |
909 | 1055 |
910 DEFUN (">", Fgtr, 2, 2, 0, /* | 1056 DEFUN (">", Fgtr, 2, 2, 0, /* |
911 T if first arg is greater than second arg. | 1057 T if first arg is greater than second arg. |
912 Both must be numbers or markers. | 1058 Both must be numbers, characters or markers. |
913 */ | 1059 */ |
914 (num1, num2)) | 1060 (num1, num2)) |
915 { | 1061 { |
916 return arithcompare (num1, num2, grtr); | 1062 return arithcompare (num1, num2, grtr); |
917 } | 1063 } |
918 | 1064 |
919 DEFUN ("<=", Fleq, 2, 2, 0, /* | 1065 DEFUN ("<=", Fleq, 2, 2, 0, /* |
920 T if first arg is less than or equal to second arg. | 1066 T if first arg is less than or equal to second arg. |
921 Both must be numbers or markers. | 1067 Both must be numbers, characters or markers. |
922 */ | 1068 */ |
923 (num1, num2)) | 1069 (num1, num2)) |
924 { | 1070 { |
925 return arithcompare (num1, num2, less_or_equal); | 1071 return arithcompare (num1, num2, less_or_equal); |
926 } | 1072 } |
927 | 1073 |
928 DEFUN (">=", Fgeq, 2, 2, 0, /* | 1074 DEFUN (">=", Fgeq, 2, 2, 0, /* |
929 T if first arg is greater than or equal to second arg. | 1075 T if first arg is greater than or equal to second arg. |
930 Both must be numbers or markers. | 1076 Both must be numbers, characters or markers. |
931 */ | 1077 */ |
932 (num1, num2)) | 1078 (num1, num2)) |
933 { | 1079 { |
934 return arithcompare (num1, num2, grtr_or_equal); | 1080 return arithcompare (num1, num2, grtr_or_equal); |
935 } | 1081 } |
936 | 1082 |
937 DEFUN ("/=", Fneq, 2, 2, 0, /* | 1083 DEFUN ("/=", Fneq, 2, 2, 0, /* |
938 T if first arg is not equal to second arg. | 1084 T if first arg is not equal to second arg. |
939 Both must be numbers or markers. | 1085 Both must be numbers, characters or markers. |
940 */ | 1086 */ |
941 (num1, num2)) | 1087 (num1, num2)) |
942 { | 1088 { |
943 return arithcompare (num1, num2, notequal); | 1089 return arithcompare (num1, num2, notequal); |
944 } | 1090 } |
1091 | |
1092 #if 0 | |
1093 /* I tried implementing Common Lisp multi-arg comparison functions, | |
1094 but failed because the byte-compiler needs to be hacked as well. */ | |
1095 | |
1096 static Lisp_Object | |
1097 arithcompare_many (enum comparison comparison, int nargs, Lisp_Object *args) | |
1098 { | |
1099 REGISTER int argnum; | |
1100 for (argnum = 1; argnum < nargs; argnum++) | |
1101 if (EQ (arithcompare ( args[argnum-1], args[argnum], comparison), Qnil)) | |
1102 return Qnil; | |
1103 | |
1104 return Qt; | |
1105 } | |
1106 | |
1107 xxxDEFUN ("=", Feqlsign, 1, MANY, 0, /* | |
1108 T if all the arguments are equal. | |
1109 The arguments may be numbers, characters or markers. | |
1110 */ | |
1111 (int nargs, Lisp_Object *args)) | |
1112 { | |
1113 return arithcompare (equal, nargs, args); | |
1114 } | |
1115 | |
1116 xxxDEFUN ("<", Flss, 1, MANY, 0, /* | |
1117 T if the sequence of arguments is monotonically increasing. | |
1118 The arguments may be numbers, characters or markers. | |
1119 */ | |
1120 (int nargs, Lisp_Object *args)) | |
1121 { | |
1122 return arithcompare (less, nargs, args); | |
1123 } | |
1124 | |
1125 xxxDEFUN (">", Fgtr, 1, MANY, 0, /* | |
1126 T if the sequence of arguments is monotonically decreasing. | |
1127 The arguments may be numbers, characters or markers. | |
1128 */ | |
1129 (int nargs, Lisp_Object *args)) | |
1130 { | |
1131 return arithcompare (grtr, nargs, args); | |
1132 } | |
1133 | |
1134 xxxDEFUN ("<=", Fleq, 1, MANY, 0, /* | |
1135 T if the sequence of arguments is monotonically nondecreasing. | |
1136 The arguments may be numbers, characters or markers. | |
1137 */ | |
1138 (int nargs, Lisp_Object *args)) | |
1139 { | |
1140 return arithcompare (less_or_equal, nargs, args); | |
1141 } | |
1142 | |
1143 xxxDEFUN (">=", Fgeq, 1, MANY, 0, /* | |
1144 T if the sequence of arguments is monotonically nonincreasing. | |
1145 The arguments may be numbers, characters or markers. | |
1146 */ | |
1147 (int nargs, Lisp_Object *args)) | |
1148 { | |
1149 return arithcompare_many (grtr_or_equal, nargs, args); | |
1150 } | |
1151 | |
1152 xxxDEFUN ("/=", Fneq, 1, MANY, 0, /* | |
1153 T if the sequence of arguments is monotonically increasing. | |
1154 The arguments may be numbers, characters or markers. | |
1155 */ | |
1156 (int nargs, Lisp_Object *args)) | |
1157 { | |
1158 return arithcompare_many (notequal, nargs, args); | |
1159 } | |
1160 #endif /* 0 - disabled for now */ | |
945 | 1161 |
946 DEFUN ("zerop", Fzerop, 1, 1, 0, /* | 1162 DEFUN ("zerop", Fzerop, 1, 1, 0, /* |
947 T if NUMBER is zero. | 1163 T if NUMBER is zero. |
948 */ | 1164 */ |
949 (number)) | 1165 (number)) |
1048 return value; | 1264 return value; |
1049 } | 1265 } |
1050 | 1266 |
1051 enum arithop | 1267 enum arithop |
1052 { Aadd, Asub, Amult, Adiv, Alogand, Alogior, Alogxor, Amax, Amin }; | 1268 { Aadd, Asub, Amult, Adiv, Alogand, Alogior, Alogxor, Amax, Amin }; |
1269 | |
1053 | 1270 |
1054 #ifdef LISP_FLOAT_TYPE | 1271 #ifdef LISP_FLOAT_TYPE |
1055 static Lisp_Object | 1272 static Lisp_Object |
1056 float_arith_driver (double accum, int argnum, enum arithop code, int nargs, | 1273 float_arith_driver (double accum, int argnum, enum arithop code, int nargs, |
1057 Lisp_Object *args) | 1274 Lisp_Object *args) |
1098 } | 1315 } |
1099 break; | 1316 break; |
1100 case Alogand: | 1317 case Alogand: |
1101 case Alogior: | 1318 case Alogior: |
1102 case Alogxor: | 1319 case Alogxor: |
1103 return wrong_type_argument (Qinteger_or_marker_p, val); | 1320 return wrong_type_argument (Qinteger_char_or_marker_p, val); |
1104 case Amax: | 1321 case Amax: |
1105 if (!argnum || isnan (next) || next > accum) | 1322 if (!argnum || isnan (next) || next > accum) |
1106 accum = next; | 1323 accum = next; |
1107 break; | 1324 break; |
1108 case Amin: | 1325 case Amin: |
1186 return val; | 1403 return val; |
1187 } | 1404 } |
1188 | 1405 |
1189 DEFUN ("+", Fplus, 0, MANY, 0, /* | 1406 DEFUN ("+", Fplus, 0, MANY, 0, /* |
1190 Return sum of any number of arguments. | 1407 Return sum of any number of arguments. |
1191 The arguments should all be numbers or markers. | 1408 The arguments should all be numbers, characters or markers. |
1192 */ | 1409 */ |
1193 (int nargs, Lisp_Object *args)) | 1410 (int nargs, Lisp_Object *args)) |
1194 { | 1411 { |
1195 return arith_driver (Aadd, nargs, args); | 1412 return arith_driver (Aadd, nargs, args); |
1196 } | 1413 } |
1197 | 1414 |
1198 DEFUN ("-", Fminus, 0, MANY, 0, /* | 1415 DEFUN ("-", Fminus, 0, MANY, 0, /* |
1199 Negate number or subtract numbers or markers. | 1416 Negate number or subtract numbers, characters or markers. |
1200 With one arg, negates it. With more than one arg, | 1417 With one arg, negates it. With more than one arg, |
1201 subtracts all but the first from the first. | 1418 subtracts all but the first from the first. |
1202 */ | 1419 */ |
1203 (int nargs, Lisp_Object *args)) | 1420 (int nargs, Lisp_Object *args)) |
1204 { | 1421 { |
1205 return arith_driver (Asub, nargs, args); | 1422 return arith_driver (Asub, nargs, args); |
1206 } | 1423 } |
1207 | 1424 |
1208 DEFUN ("*", Ftimes, 0, MANY, 0, /* | 1425 DEFUN ("*", Ftimes, 0, MANY, 0, /* |
1209 Return product of any number of arguments. | 1426 Return product of any number of arguments. |
1210 The arguments should all be numbers or markers. | 1427 The arguments should all be numbers, characters or markers. |
1211 */ | 1428 */ |
1212 (int nargs, Lisp_Object *args)) | 1429 (int nargs, Lisp_Object *args)) |
1213 { | 1430 { |
1214 return arith_driver (Amult, nargs, args); | 1431 return arith_driver (Amult, nargs, args); |
1215 } | 1432 } |
1216 | 1433 |
1217 DEFUN ("/", Fquo, 2, MANY, 0, /* | 1434 DEFUN ("/", Fquo, 2, MANY, 0, /* |
1218 Return first argument divided by all the remaining arguments. | 1435 Return first argument divided by all the remaining arguments. |
1219 The arguments must be numbers or markers. | 1436 The arguments must be numbers, characters or markers. |
1220 */ | 1437 */ |
1221 (int nargs, Lisp_Object *args)) | 1438 (int nargs, Lisp_Object *args)) |
1222 { | 1439 { |
1223 return arith_driver (Adiv, nargs, args); | 1440 return arith_driver (Adiv, nargs, args); |
1224 } | 1441 } |
1225 | 1442 |
1226 DEFUN ("%", Frem, 2, 2, 0, /* | 1443 DEFUN ("%", Frem, 2, 2, 0, /* |
1227 Return remainder of first arg divided by second. | 1444 Return remainder of first arg divided by second. |
1228 Both must be integers or markers. | 1445 Both must be integers, characters or markers. |
1229 */ | 1446 */ |
1230 (num1, num2)) | 1447 (num1, num2)) |
1231 { | 1448 { |
1232 CHECK_INT_COERCE_CHAR_OR_MARKER (num1); | 1449 CHECK_INT_COERCE_CHAR_OR_MARKER (num1); |
1233 CHECK_INT_COERCE_CHAR_OR_MARKER (num2); | 1450 CHECK_INT_COERCE_CHAR_OR_MARKER (num2); |
1254 | 1471 |
1255 | 1472 |
1256 DEFUN ("mod", Fmod, 2, 2, 0, /* | 1473 DEFUN ("mod", Fmod, 2, 2, 0, /* |
1257 Return X modulo Y. | 1474 Return X modulo Y. |
1258 The result falls between zero (inclusive) and Y (exclusive). | 1475 The result falls between zero (inclusive) and Y (exclusive). |
1259 Both X and Y must be numbers or markers. | 1476 Both X and Y must be numbers, characters or markers. |
1260 If either argument is a float, a float will be returned. | 1477 If either argument is a float, a float will be returned. |
1261 */ | 1478 */ |
1262 (x, y)) | 1479 (x, y)) |
1263 { | 1480 { |
1264 EMACS_INT i1, i2; | 1481 EMACS_INT i1, i2; |
1304 } | 1521 } |
1305 | 1522 |
1306 | 1523 |
1307 DEFUN ("max", Fmax, 1, MANY, 0, /* | 1524 DEFUN ("max", Fmax, 1, MANY, 0, /* |
1308 Return largest of all the arguments. | 1525 Return largest of all the arguments. |
1309 All arguments must be numbers or markers. | 1526 All arguments must be numbers, characters or markers. |
1310 The value is always a number; markers are converted to numbers. | 1527 The value is always a number; markers and characters are converted |
1528 to numbers. | |
1311 */ | 1529 */ |
1312 (int nargs, Lisp_Object *args)) | 1530 (int nargs, Lisp_Object *args)) |
1313 { | 1531 { |
1314 return arith_driver (Amax, nargs, args); | 1532 return arith_driver (Amax, nargs, args); |
1315 } | 1533 } |
1316 | 1534 |
1317 DEFUN ("min", Fmin, 1, MANY, 0, /* | 1535 DEFUN ("min", Fmin, 1, MANY, 0, /* |
1318 Return smallest of all the arguments. | 1536 Return smallest of all the arguments. |
1319 All arguments must be numbers or markers. | 1537 All arguments must be numbers, characters or markers. |
1320 The value is always a number; markers are converted to numbers. | 1538 The value is always a number; markers and characters are converted |
1539 to numbers. | |
1321 */ | 1540 */ |
1322 (int nargs, Lisp_Object *args)) | 1541 (int nargs, Lisp_Object *args)) |
1323 { | 1542 { |
1324 return arith_driver (Amin, nargs, args); | 1543 return arith_driver (Amin, nargs, args); |
1325 } | 1544 } |
1326 | 1545 |
1327 DEFUN ("logand", Flogand, 0, MANY, 0, /* | 1546 DEFUN ("logand", Flogand, 0, MANY, 0, /* |
1328 Return bitwise-and of all the arguments. | 1547 Return bitwise-and of all the arguments. |
1329 Arguments may be integers, or markers converted to integers. | 1548 Arguments may be integers, or markers or characters converted to integers. |
1330 */ | 1549 */ |
1331 (int nargs, Lisp_Object *args)) | 1550 (int nargs, Lisp_Object *args)) |
1332 { | 1551 { |
1333 return arith_driver (Alogand, nargs, args); | 1552 return arith_driver (Alogand, nargs, args); |
1334 } | 1553 } |
1335 | 1554 |
1336 DEFUN ("logior", Flogior, 0, MANY, 0, /* | 1555 DEFUN ("logior", Flogior, 0, MANY, 0, /* |
1337 Return bitwise-or of all the arguments. | 1556 Return bitwise-or of all the arguments. |
1338 Arguments may be integers, or markers converted to integers. | 1557 Arguments may be integers, or markers or characters converted to integers. |
1339 */ | 1558 */ |
1340 (int nargs, Lisp_Object *args)) | 1559 (int nargs, Lisp_Object *args)) |
1341 { | 1560 { |
1342 return arith_driver (Alogior, nargs, args); | 1561 return arith_driver (Alogior, nargs, args); |
1343 } | 1562 } |
1344 | 1563 |
1345 DEFUN ("logxor", Flogxor, 0, MANY, 0, /* | 1564 DEFUN ("logxor", Flogxor, 0, MANY, 0, /* |
1346 Return bitwise-exclusive-or of all the arguments. | 1565 Return bitwise-exclusive-or of all the arguments. |
1347 Arguments may be integers, or markers converted to integers. | 1566 Arguments may be integers, or markers or characters converted to integers. |
1348 */ | 1567 */ |
1349 (int nargs, Lisp_Object *args)) | 1568 (int nargs, Lisp_Object *args)) |
1350 { | 1569 { |
1351 return arith_driver (Alogxor, nargs, args); | 1570 return arith_driver (Alogxor, nargs, args); |
1352 } | 1571 } |
1360 { | 1579 { |
1361 CHECK_INT_COERCE_CHAR (value); | 1580 CHECK_INT_COERCE_CHAR (value); |
1362 CHECK_INT (count); | 1581 CHECK_INT (count); |
1363 | 1582 |
1364 return make_int (XINT (count) > 0 ? | 1583 return make_int (XINT (count) > 0 ? |
1365 XINT (value) << XINT (count) : | 1584 XINT (value) << XINT (count) : |
1366 XINT (value) >> -XINT (count)); | 1585 XINT (value) >> -XINT (count)); |
1367 } | 1586 } |
1368 | 1587 |
1369 DEFUN ("lsh", Flsh, 2, 2, 0, /* | 1588 DEFUN ("lsh", Flsh, 2, 2, 0, /* |
1370 Return VALUE with its bits shifted left by COUNT. | 1589 Return VALUE with its bits shifted left by COUNT. |
1371 If COUNT is negative, shifting is actually to the right. | 1590 If COUNT is negative, shifting is actually to the right. |
1372 In this case, zeros are shifted in on the left. | 1591 In this case, zeros are shifted in on the left. |
1373 */ | 1592 */ |
1374 (value, count)) | 1593 (value, count)) |
1375 { | 1594 { |
1376 Lisp_Object val; | 1595 Lisp_Object val; |
1377 | 1596 |
1378 CHECK_INT_COERCE_CHAR (value); | 1597 CHECK_INT_COERCE_CHAR (value); |
1379 CHECK_INT (count); | 1598 CHECK_INT (count); |
1380 | 1599 |
1381 if (XINT (count) > 0) | 1600 { |
1382 XSETINT (val, (EMACS_UINT) XUINT (value) << XINT (count)); | 1601 int C_count = XINT (count); |
1383 else | 1602 EMACS_UINT C_value = (EMACS_UINT) XUINT (value); |
1384 XSETINT (val, (EMACS_UINT) XUINT (value) >> -XINT (count)); | 1603 XSETINT (val, C_count > 0 ? C_value << C_count : C_value >> -C_count); |
1604 } | |
1385 return val; | 1605 return val; |
1386 } | 1606 } |
1387 | 1607 |
1388 DEFUN ("1+", Fadd1, 1, 1, 0, /* | 1608 DEFUN ("1+", Fadd1, 1, 1, 0, /* |
1389 Return NUMBER plus one. NUMBER may be a number or a marker. | 1609 Return NUMBER plus one. NUMBER may be a number or a marker. |
1390 Markers are converted to integers. | 1610 Markers and characters are converted to integers. |
1391 */ | 1611 */ |
1392 (number)) | 1612 (number)) |
1393 { | 1613 { |
1394 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (number); | 1614 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (number); |
1395 | 1615 |
1401 return (make_int (XINT (number) + 1)); | 1621 return (make_int (XINT (number) + 1)); |
1402 } | 1622 } |
1403 | 1623 |
1404 DEFUN ("1-", Fsub1, 1, 1, 0, /* | 1624 DEFUN ("1-", Fsub1, 1, 1, 0, /* |
1405 Return NUMBER minus one. NUMBER may be a number or a marker. | 1625 Return NUMBER minus one. NUMBER may be a number or a marker. |
1406 Markers are converted to integers. | 1626 Markers and characters are converted to integers. |
1407 */ | 1627 */ |
1408 (number)) | 1628 (number)) |
1409 { | 1629 { |
1410 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (number); | 1630 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (number); |
1411 | 1631 |
1475 weak_list_equal (Lisp_Object o1, Lisp_Object o2, int depth) | 1695 weak_list_equal (Lisp_Object o1, Lisp_Object o2, int depth) |
1476 { | 1696 { |
1477 struct weak_list *w1 = XWEAK_LIST (o1); | 1697 struct weak_list *w1 = XWEAK_LIST (o1); |
1478 struct weak_list *w2 = XWEAK_LIST (o2); | 1698 struct weak_list *w2 = XWEAK_LIST (o2); |
1479 | 1699 |
1480 return (w1->type != w2->type && | 1700 return (w1->type == w2->type) && |
1481 internal_equal (w1->list, w2->list, depth + 1)); | 1701 internal_equal (w1->list, w2->list, depth + 1); |
1482 } | 1702 } |
1483 | 1703 |
1484 static unsigned long | 1704 static unsigned long |
1485 weak_list_hash (Lisp_Object obj, int depth) | 1705 weak_list_hash (Lisp_Object obj, int depth) |
1486 { | 1706 { |
1755 decode_weak_list_type (Lisp_Object symbol) | 1975 decode_weak_list_type (Lisp_Object symbol) |
1756 { | 1976 { |
1757 CHECK_SYMBOL (symbol); | 1977 CHECK_SYMBOL (symbol); |
1758 if (EQ (symbol, Qsimple)) return WEAK_LIST_SIMPLE; | 1978 if (EQ (symbol, Qsimple)) return WEAK_LIST_SIMPLE; |
1759 if (EQ (symbol, Qassoc)) return WEAK_LIST_ASSOC; | 1979 if (EQ (symbol, Qassoc)) return WEAK_LIST_ASSOC; |
1980 if (EQ (symbol, Qold_assoc)) return WEAK_LIST_ASSOC; /* EBOLA ALERT! */ | |
1760 if (EQ (symbol, Qkey_assoc)) return WEAK_LIST_KEY_ASSOC; | 1981 if (EQ (symbol, Qkey_assoc)) return WEAK_LIST_KEY_ASSOC; |
1761 if (EQ (symbol, Qvalue_assoc)) return WEAK_LIST_VALUE_ASSOC; | 1982 if (EQ (symbol, Qvalue_assoc)) return WEAK_LIST_VALUE_ASSOC; |
1762 | 1983 |
1763 signal_simple_error ("Invalid weak list type", symbol); | 1984 signal_simple_error ("Invalid weak list type", symbol); |
1764 return WEAK_LIST_SIMPLE; /* not reached */ | 1985 return WEAK_LIST_SIMPLE; /* not reached */ |
1975 defsymbol (&Qvectorp, "vectorp"); | 2196 defsymbol (&Qvectorp, "vectorp"); |
1976 defsymbol (&Qcompiled_functionp, "compiled-function-p"); | 2197 defsymbol (&Qcompiled_functionp, "compiled-function-p"); |
1977 defsymbol (&Qchar_or_string_p, "char-or-string-p"); | 2198 defsymbol (&Qchar_or_string_p, "char-or-string-p"); |
1978 defsymbol (&Qmarkerp, "markerp"); | 2199 defsymbol (&Qmarkerp, "markerp"); |
1979 defsymbol (&Qinteger_or_marker_p, "integer-or-marker-p"); | 2200 defsymbol (&Qinteger_or_marker_p, "integer-or-marker-p"); |
1980 /* HACK for 19.x only. */ | 2201 defsymbol (&Qinteger_or_char_p, "integer-or-char-p"); |
1981 defsymbol (&Qinteger_char_or_marker_p, "integer-or-marker-p"); | 2202 defsymbol (&Qinteger_char_or_marker_p, "integer-char-or-marker-p"); |
1982 | 2203 |
1983 #ifdef LISP_FLOAT_TYPE | 2204 #ifdef LISP_FLOAT_TYPE |
1984 defsymbol (&Qfloatp, "floatp"); | 2205 defsymbol (&Qfloatp, "floatp"); |
1985 #endif /* LISP_FLOAT_TYPE */ | 2206 #endif /* LISP_FLOAT_TYPE */ |
1986 defsymbol (&Qnumberp, "numberp"); | 2207 defsymbol (&Qnumberp, "numberp"); |
1987 defsymbol (&Qnumber_or_marker_p, "number-or-marker-p"); | 2208 defsymbol (&Qnumber_or_marker_p, "number-or-marker-p"); |
1988 /* HACK for 19.x only. */ | 2209 defsymbol (&Qnumber_char_or_marker_p, "number-char-or-marker-p"); |
1989 defsymbol (&Qnumber_char_or_marker_p, "number-or-marker-p"); | |
1990 | 2210 |
1991 defsymbol (&Qcdr, "cdr"); | 2211 defsymbol (&Qcdr, "cdr"); |
1992 | 2212 |
1993 defsymbol (&Qweak_listp, "weak-list-p"); | 2213 defsymbol (&Qweak_listp, "weak-list-p"); |
1994 | 2214 |
1995 DEFSUBR (Fwrong_type_argument); | 2215 DEFSUBR (Fwrong_type_argument); |
1996 | 2216 |
1997 DEFSUBR (Feq); | 2217 DEFSUBR (Feq); |
2218 DEFSUBR (Fold_eq); | |
1998 DEFSUBR (Fnull); | 2219 DEFSUBR (Fnull); |
1999 DEFSUBR (Flistp); | 2220 DEFSUBR (Flistp); |
2000 DEFSUBR (Fnlistp); | 2221 DEFSUBR (Fnlistp); |
2001 DEFSUBR (Fconsp); | 2222 DEFSUBR (Fconsp); |
2002 DEFSUBR (Fatom); | 2223 DEFSUBR (Fatom); |
2003 DEFSUBR (Fchar_or_string_p); | 2224 DEFSUBR (Fchar_or_string_p); |
2004 DEFSUBR (Fcharacterp); | 2225 DEFSUBR (Fcharacterp); |
2226 DEFSUBR (Fchar_int_p); | |
2227 DEFSUBR (Fchar_int); | |
2228 DEFSUBR (Fint_char); | |
2229 DEFSUBR (Fchar_or_char_int_p); | |
2005 DEFSUBR (Fintegerp); | 2230 DEFSUBR (Fintegerp); |
2006 DEFSUBR (Finteger_or_marker_p); | 2231 DEFSUBR (Finteger_or_marker_p); |
2232 DEFSUBR (Finteger_or_char_p); | |
2233 DEFSUBR (Finteger_char_or_marker_p); | |
2007 DEFSUBR (Fnumberp); | 2234 DEFSUBR (Fnumberp); |
2008 DEFSUBR (Fnumber_or_marker_p); | 2235 DEFSUBR (Fnumber_or_marker_p); |
2236 DEFSUBR (Fnumber_char_or_marker_p); | |
2009 #ifdef LISP_FLOAT_TYPE | 2237 #ifdef LISP_FLOAT_TYPE |
2010 DEFSUBR (Ffloatp); | 2238 DEFSUBR (Ffloatp); |
2011 #endif /* LISP_FLOAT_TYPE */ | 2239 #endif /* LISP_FLOAT_TYPE */ |
2012 DEFSUBR (Fnatnump); | 2240 DEFSUBR (Fnatnump); |
2013 DEFSUBR (Fsymbolp); | 2241 DEFSUBR (Fsymbolp); |
2081 void | 2309 void |
2082 vars_of_data (void) | 2310 vars_of_data (void) |
2083 { | 2311 { |
2084 /* This must not be staticpro'd */ | 2312 /* This must not be staticpro'd */ |
2085 Vall_weak_lists = Qnil; | 2313 Vall_weak_lists = Qnil; |
2086 } | 2314 |
2315 #ifdef DEBUG_XEMACS | |
2316 DEFVAR_INT ("debug-issue-ebola-notices", &debug_issue_ebola_notices /* | |
2317 If non-nil, note when your code may be suffering from char-int confoundance. | |
2318 That is to say, if XEmacs encounters a usage of `eq', `memq', `equal', | |
2319 etc. where a int and a char with the same value are being compared, | |
2320 it will issue a notice on stderr to this effect, along with a backtrace. | |
2321 In such situations, the result would be different in XEmacs 19 versus | |
2322 XEmacs 20, and you probably don't want this. | |
2323 | |
2324 Note that in order to see these notices, you have to byte compile your | |
2325 code under XEmacs 20 -- any code byte-compiled under XEmacs 19 will | |
2326 have its chars and ints all confounded in the byte code, making it | |
2327 impossible to accurately determine Ebola infection. | |
2328 */ ); | |
2329 | |
2330 debug_issue_ebola_notices = 2; /* #### temporary hack */ | |
2331 | |
2332 DEFVAR_INT ("debug-ebola-backtrace-length", | |
2333 &debug_ebola_backtrace_length /* | |
2334 Length (in stack frames) of short backtrace printed out in Ebola notices. | |
2335 See `debug-issue-ebola-notices'. | |
2336 */ ); | |
2337 debug_ebola_backtrace_length = 8; | |
2338 | |
2339 #endif /* DEBUG_XEMACS */ | |
2340 } |