Mercurial > hg > xemacs-beta
comparison src/data.c @ 444:576fb035e263 r21-2-37
Import from CVS: tag r21-2-37
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:36:19 +0200 |
parents | abe6d1db359e |
children | 3d3049ae1304 |
comparison
equal
deleted
inserted
replaced
443:a8296e22da4e | 444:576fb035e263 |
---|---|
180 /* Data type predicates */ | 180 /* Data type predicates */ |
181 | 181 |
182 DEFUN ("eq", Feq, 2, 2, 0, /* | 182 DEFUN ("eq", Feq, 2, 2, 0, /* |
183 Return t if the two args are the same Lisp object. | 183 Return t if the two args are the same Lisp object. |
184 */ | 184 */ |
185 (obj1, obj2)) | 185 (object1, object2)) |
186 { | 186 { |
187 return EQ_WITH_EBOLA_NOTICE (obj1, obj2) ? Qt : Qnil; | 187 return EQ_WITH_EBOLA_NOTICE (object1, object2) ? Qt : Qnil; |
188 } | 188 } |
189 | 189 |
190 DEFUN ("old-eq", Fold_eq, 2, 2, 0, /* | 190 DEFUN ("old-eq", Fold_eq, 2, 2, 0, /* |
191 Return t if the two args are (in most cases) the same Lisp object. | 191 Return t if the two args are (in most cases) the same Lisp object. |
192 | 192 |
197 \"char-int confoundance disease\" and appears in a number of other | 197 \"char-int confoundance disease\" and appears in a number of other |
198 functions with `old-foo' equivalents. | 198 functions with `old-foo' equivalents. |
199 | 199 |
200 Do not use this function! | 200 Do not use this function! |
201 */ | 201 */ |
202 (obj1, obj2)) | 202 (object1, object2)) |
203 { | 203 { |
204 /* #### blasphemy */ | 204 /* #### blasphemy */ |
205 return HACKEQ_UNSAFE (obj1, obj2) ? Qt : Qnil; | 205 return HACKEQ_UNSAFE (object1, object2) ? Qt : Qnil; |
206 } | 206 } |
207 | 207 |
208 DEFUN ("null", Fnull, 1, 1, 0, /* | 208 DEFUN ("null", Fnull, 1, 1, 0, /* |
209 Return t if OBJECT is nil. | 209 Return t if OBJECT is nil. |
210 */ | 210 */ |
355 else | 355 else |
356 return make_int (nargs); | 356 return make_int (nargs); |
357 } | 357 } |
358 | 358 |
359 DEFUN ("subr-interactive", Fsubr_interactive, 1, 1, 0, /* | 359 DEFUN ("subr-interactive", Fsubr_interactive, 1, 1, 0, /* |
360 Return the interactive spec of the subr object, or nil. | 360 Return the interactive spec of the subr object SUBR, or nil. |
361 If non-nil, the return value will be a list whose first element is | 361 If non-nil, the return value will be a list whose first element is |
362 `interactive' and whose second element is the interactive spec. | 362 `interactive' and whose second element is the interactive spec. |
363 */ | 363 */ |
364 (subr)) | 364 (subr)) |
365 { | 365 { |
393 { | 393 { |
394 return CHARP (object) ? Qt : Qnil; | 394 return CHARP (object) ? Qt : Qnil; |
395 } | 395 } |
396 | 396 |
397 DEFUN ("char-to-int", Fchar_to_int, 1, 1, 0, /* | 397 DEFUN ("char-to-int", Fchar_to_int, 1, 1, 0, /* |
398 Convert a character into an equivalent integer. | 398 Convert CHARACTER into an equivalent integer. |
399 The resulting integer will always be non-negative. The integers in | 399 The resulting integer will always be non-negative. The integers in |
400 the range 0 - 255 map to characters as follows: | 400 the range 0 - 255 map to characters as follows: |
401 | 401 |
402 0 - 31 Control set 0 | 402 0 - 31 Control set 0 |
403 32 - 127 ASCII | 403 32 - 127 ASCII |
407 If support for Mule does not exist, these are the only valid character | 407 If support for Mule does not exist, these are the only valid character |
408 values. When Mule support exists, the values assigned to other characters | 408 values. When Mule support exists, the values assigned to other characters |
409 may vary depending on the particular version of XEmacs, the order in which | 409 may vary depending on the particular version of XEmacs, the order in which |
410 character sets were loaded, etc., and you should not depend on them. | 410 character sets were loaded, etc., and you should not depend on them. |
411 */ | 411 */ |
412 (ch)) | 412 (character)) |
413 { | 413 { |
414 CHECK_CHAR (ch); | 414 CHECK_CHAR (character); |
415 return make_int (XCHAR (ch)); | 415 return make_int (XCHAR (character)); |
416 } | 416 } |
417 | 417 |
418 DEFUN ("int-to-char", Fint_to_char, 1, 1, 0, /* | 418 DEFUN ("int-to-char", Fint_to_char, 1, 1, 0, /* |
419 Convert an integer into the equivalent character. | 419 Convert integer INTEGER into the equivalent character. |
420 Not all integers correspond to valid characters; use `char-int-p' to | 420 Not all integers correspond to valid characters; use `char-int-p' to |
421 determine whether this is the case. If the integer cannot be converted, | 421 determine whether this is the case. If the integer cannot be converted, |
422 nil is returned. | 422 nil is returned. |
423 */ | 423 */ |
424 (integer)) | 424 (integer)) |
612 { | 612 { |
613 return CONSP (object) ? XCDR (object) : Qnil; | 613 return CONSP (object) ? XCDR (object) : Qnil; |
614 } | 614 } |
615 | 615 |
616 DEFUN ("setcar", Fsetcar, 2, 2, 0, /* | 616 DEFUN ("setcar", Fsetcar, 2, 2, 0, /* |
617 Set the car of CONSCELL to be NEWCAR. Return NEWCAR. | 617 Set the car of CONS-CELL to be NEWCAR. Return NEWCAR. |
618 */ | 618 */ |
619 (conscell, newcar)) | 619 (cons_cell, newcar)) |
620 { | 620 { |
621 if (!CONSP (conscell)) | 621 if (!CONSP (cons_cell)) |
622 conscell = wrong_type_argument (Qconsp, conscell); | 622 cons_cell = wrong_type_argument (Qconsp, cons_cell); |
623 | 623 |
624 XCAR (conscell) = newcar; | 624 XCAR (cons_cell) = newcar; |
625 return newcar; | 625 return newcar; |
626 } | 626 } |
627 | 627 |
628 DEFUN ("setcdr", Fsetcdr, 2, 2, 0, /* | 628 DEFUN ("setcdr", Fsetcdr, 2, 2, 0, /* |
629 Set the cdr of CONSCELL to be NEWCDR. Return NEWCDR. | 629 Set the cdr of CONS-CELL to be NEWCDR. Return NEWCDR. |
630 */ | 630 */ |
631 (conscell, newcdr)) | 631 (cons_cell, newcdr)) |
632 { | 632 { |
633 if (!CONSP (conscell)) | 633 if (!CONSP (cons_cell)) |
634 conscell = wrong_type_argument (Qconsp, conscell); | 634 cons_cell = wrong_type_argument (Qconsp, cons_cell); |
635 | 635 |
636 XCDR (conscell) = newcdr; | 636 XCDR (cons_cell) = newcdr; |
637 return newcdr; | 637 return newcdr; |
638 } | 638 } |
639 | 639 |
640 /* Find the function at the end of a chain of symbol function indirections. | 640 /* Find the function at the end of a chain of symbol function indirections. |
641 | 641 |
1000 } | 1000 } |
1001 } | 1001 } |
1002 | 1002 |
1003 | 1003 |
1004 DEFUN ("number-to-string", Fnumber_to_string, 1, 1, 0, /* | 1004 DEFUN ("number-to-string", Fnumber_to_string, 1, 1, 0, /* |
1005 Convert NUM to a string by printing it in decimal. | 1005 Convert NUMBER to a string by printing it in decimal. |
1006 Uses a minus sign if negative. | 1006 Uses a minus sign if negative. |
1007 NUM may be an integer or a floating point number. | 1007 NUMBER may be an integer or a floating point number. |
1008 */ | 1008 */ |
1009 (num)) | 1009 (number)) |
1010 { | 1010 { |
1011 char buffer[VALBITS]; | 1011 char buffer[VALBITS]; |
1012 | 1012 |
1013 CHECK_INT_OR_FLOAT (num); | 1013 CHECK_INT_OR_FLOAT (number); |
1014 | 1014 |
1015 #ifdef LISP_FLOAT_TYPE | 1015 #ifdef LISP_FLOAT_TYPE |
1016 if (FLOATP (num)) | 1016 if (FLOATP (number)) |
1017 { | 1017 { |
1018 char pigbuf[350]; /* see comments in float_to_string */ | 1018 char pigbuf[350]; /* see comments in float_to_string */ |
1019 | 1019 |
1020 float_to_string (pigbuf, XFLOAT_DATA (num)); | 1020 float_to_string (pigbuf, XFLOAT_DATA (number)); |
1021 return build_string (pigbuf); | 1021 return build_string (pigbuf); |
1022 } | 1022 } |
1023 #endif /* LISP_FLOAT_TYPE */ | 1023 #endif /* LISP_FLOAT_TYPE */ |
1024 | 1024 |
1025 long_to_string (buffer, XINT (num)); | 1025 long_to_string (buffer, XINT (number)); |
1026 return build_string (buffer); | 1026 return build_string (buffer); |
1027 } | 1027 } |
1028 | 1028 |
1029 static int | 1029 static int |
1030 digit_to_number (int character, int base) | 1030 digit_to_number (int character, int base) |
1037 | 1037 |
1038 return digit >= base ? -1 : digit; | 1038 return digit >= base ? -1 : digit; |
1039 } | 1039 } |
1040 | 1040 |
1041 DEFUN ("string-to-number", Fstring_to_number, 1, 2, 0, /* | 1041 DEFUN ("string-to-number", Fstring_to_number, 1, 2, 0, /* |
1042 Convert STRING to a number by parsing it as a decimal number. | 1042 Convert STRING to a number by parsing it as a number in base BASE. |
1043 This parses both integers and floating point numbers. | 1043 This parses both integers and floating point numbers. |
1044 It ignores leading spaces and tabs. | 1044 It ignores leading spaces and tabs. |
1045 | 1045 |
1046 If BASE, interpret STRING as a number in that base. If BASE isn't | 1046 If BASE is nil or omitted, base 10 is used. |
1047 present, base 10 is used. BASE must be between 2 and 16 (inclusive). | 1047 BASE must be an integer between 2 and 16 (inclusive). |
1048 Floating point numbers always use base 10. | 1048 Floating point numbers always use base 10. |
1049 */ | 1049 */ |
1050 (string, base)) | 1050 (string, base)) |
1051 { | 1051 { |
1052 char *p; | 1052 char *p; |
1086 return make_int (atoll (p)); | 1086 return make_int (atoll (p)); |
1087 #endif | 1087 #endif |
1088 } | 1088 } |
1089 else | 1089 else |
1090 { | 1090 { |
1091 int digit, negative = 1; | 1091 int negative = 1; |
1092 EMACS_INT v = 0; | 1092 EMACS_INT v = 0; |
1093 | 1093 |
1094 if (*p == '-') | 1094 if (*p == '-') |
1095 { | 1095 { |
1096 negative = -1; | 1096 negative = -1; |
1098 } | 1098 } |
1099 else if (*p == '+') | 1099 else if (*p == '+') |
1100 p++; | 1100 p++; |
1101 while (1) | 1101 while (1) |
1102 { | 1102 { |
1103 digit = digit_to_number (*p++, b); | 1103 int digit = digit_to_number (*p++, b); |
1104 if (digit < 0) | 1104 if (digit < 0) |
1105 break; | 1105 break; |
1106 v = v * b + digit; | 1106 v = v * b + digit; |
1107 } | 1107 } |
1108 return make_int (negative * v); | 1108 return make_int (negative * v); |
1415 | 1415 |
1416 DEFUN ("%", Frem, 2, 2, 0, /* | 1416 DEFUN ("%", Frem, 2, 2, 0, /* |
1417 Return remainder of first arg divided by second. | 1417 Return remainder of first arg divided by second. |
1418 Both must be integers, characters or markers. | 1418 Both must be integers, characters or markers. |
1419 */ | 1419 */ |
1420 (num1, num2)) | 1420 (number1, number2)) |
1421 { | 1421 { |
1422 EMACS_INT ival1 = integer_char_or_marker_to_int (num1); | 1422 EMACS_INT ival1 = integer_char_or_marker_to_int (number1); |
1423 EMACS_INT ival2 = integer_char_or_marker_to_int (num2); | 1423 EMACS_INT ival2 = integer_char_or_marker_to_int (number2); |
1424 | 1424 |
1425 if (ival2 == 0) | 1425 if (ival2 == 0) |
1426 Fsignal (Qarith_error, Qnil); | 1426 Fsignal (Qarith_error, Qnil); |
1427 | 1427 |
1428 return make_int (ival1 % ival2); | 1428 return make_int (ival1 % ival2); |