Mercurial > hg > xemacs-beta
comparison src/lread.c @ 5581:56144c8593a8
Mechanically change INT to FIXNUM in our sources.
src/ChangeLog addition:
2011-10-09 Aidan Kehoe <kehoea@parhasard.net>
[...]
Mechanically change INT (where it refers to non-bignum Lisp
integers) to FIXNUM in our sources. Done for the following
functions, enums, and macros: Lisp_Type_Int_Even,
Lisp_Type_Int_Odd, INT_GCBITS, INT_VALBITS, make_int(), INTP(),
XINT(), CHECK_INT(), XREALINT(), INT_PLUS(), INT_MINUS(),
EMACS_INT_MAX (to MOST_POSITIVE_FIXNUM), EMACS_INT_MIN (to
MOST_NEGATIVE_FIXNUM), NUMBER_FITS_IN_AN_EMACS_INT() to
NUMBER_FITS_IN_A_FIXNUM(), XFLOATINT, XCHAR_OR_INT, INT_OR_FLOAT.
The EMACS_INT typedef was not changed, it does not describe
non-bignum Lisp integers.
Script that did the change available in
http://mid.gmane.org/20067.17650.181273.12014@parhasard.net .
modules/ChangeLog addition:
2011-10-09 Aidan Kehoe <kehoea@parhasard.net>
[...]
Mechanically change INT to FIXNUM, where the usage describes non-bignum
Lisp integers. See the src/ChangeLog entry for more details.
man/ChangeLog addition:
2011-10-09 Aidan Kehoe <kehoea@parhasard.net>
* internals/internals.texi (How Lisp Objects Are Represented in C):
* internals/internals.texi (Integers and Characters):
Mechanically change INT to FIXNUM, where the usage describes non-bignum
Lisp integers.
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Sun, 09 Oct 2011 09:51:57 +0100 |
| parents | 58b38d5b32d0 |
| children | cc7f8a0e569a |
comparison
equal
deleted
inserted
replaced
| 5580:a0e81357194e | 5581:56144c8593a8 |
|---|---|
| 419 pas_de_holgazan_ici (int fd, Lisp_Object victim) | 419 pas_de_holgazan_ici (int fd, Lisp_Object victim) |
| 420 { | 420 { |
| 421 Lisp_Object tem; | 421 Lisp_Object tem; |
| 422 EMACS_INT pos; | 422 EMACS_INT pos; |
| 423 | 423 |
| 424 if (!INTP (XCDR (victim))) | 424 if (!FIXNUMP (XCDR (victim))) |
| 425 invalid_byte_code ("Bogus doc string reference", victim); | 425 invalid_byte_code ("Bogus doc string reference", victim); |
| 426 pos = XINT (XCDR (victim)); | 426 pos = XFIXNUM (XCDR (victim)); |
| 427 if (pos < 0) | 427 if (pos < 0) |
| 428 pos = -pos; /* kludge to mark a user variable */ | 428 pos = -pos; /* kludge to mark a user variable */ |
| 429 tem = unparesseuxify_doc_string (fd, pos, 0, Vload_file_name_internal, 0); | 429 tem = unparesseuxify_doc_string (fd, pos, 0, Vload_file_name_internal, 0); |
| 430 if (!STRINGP (tem)) | 430 if (!STRINGP (tem)) |
| 431 signal_error_1 (Qinvalid_byte_code, tem); | 431 signal_error_1 (Qinvalid_byte_code, tem); |
| 436 load_force_doc_string_unwind (Lisp_Object oldlist) | 436 load_force_doc_string_unwind (Lisp_Object oldlist) |
| 437 { | 437 { |
| 438 struct gcpro gcpro1; | 438 struct gcpro gcpro1; |
| 439 Lisp_Object list = Vload_force_doc_string_list; | 439 Lisp_Object list = Vload_force_doc_string_list; |
| 440 Lisp_Object tail; | 440 Lisp_Object tail; |
| 441 int fd = XINT (XCAR (Vload_descriptor_list)); | 441 int fd = XFIXNUM (XCAR (Vload_descriptor_list)); |
| 442 | 442 |
| 443 GCPRO1 (list); | 443 GCPRO1 (list); |
| 444 /* restore the old value first just in case an error occurs. */ | 444 /* restore the old value first just in case an error occurs. */ |
| 445 Vload_force_doc_string_list = oldlist; | 445 Vload_force_doc_string_list = oldlist; |
| 446 | 446 |
| 503 void | 503 void |
| 504 close_load_descs (void) | 504 close_load_descs (void) |
| 505 { | 505 { |
| 506 Lisp_Object tail; | 506 Lisp_Object tail; |
| 507 LIST_LOOP (tail, Vload_descriptor_list) | 507 LIST_LOOP (tail, Vload_descriptor_list) |
| 508 retry_close (XINT (XCAR (tail))); | 508 retry_close (XFIXNUM (XCAR (tail))); |
| 509 } | 509 } |
| 510 | 510 |
| 511 #ifdef I18N3 | 511 #ifdef I18N3 |
| 512 Lisp_Object Vfile_domain; | 512 Lisp_Object Vfile_domain; |
| 513 #endif /* I18N3 */ | 513 #endif /* I18N3 */ |
| 726 block_size); | 726 block_size); |
| 727 /* NOTE: Order of these is very important. Don't rearrange them. */ | 727 /* NOTE: Order of these is very important. Don't rearrange them. */ |
| 728 internal_bind_int (&load_in_progress, 1 + load_in_progress); | 728 internal_bind_int (&load_in_progress, 1 + load_in_progress); |
| 729 record_unwind_protect (load_unwind, lispstream); | 729 record_unwind_protect (load_unwind, lispstream); |
| 730 internal_bind_lisp_object (&Vload_descriptor_list, | 730 internal_bind_lisp_object (&Vload_descriptor_list, |
| 731 Fcons (make_int (fd), Vload_descriptor_list)); | 731 Fcons (make_fixnum (fd), Vload_descriptor_list)); |
| 732 internal_bind_lisp_object (&Vload_file_name_internal, found); | 732 internal_bind_lisp_object (&Vload_file_name_internal, found); |
| 733 /* this is not a simple internal_bind. */ | 733 /* this is not a simple internal_bind. */ |
| 734 record_unwind_protect (load_force_doc_string_unwind, | 734 record_unwind_protect (load_force_doc_string_unwind, |
| 735 Vload_force_doc_string_list); | 735 Vload_force_doc_string_list); |
| 736 Vload_force_doc_string_list = Qnil; | 736 Vload_force_doc_string_list = Qnil; |
| 842 return W_OK; | 842 return W_OK; |
| 843 else if (EQ (mode, Qreadable)) | 843 else if (EQ (mode, Qreadable)) |
| 844 return R_OK; | 844 return R_OK; |
| 845 else if (INTEGERP (mode)) | 845 else if (INTEGERP (mode)) |
| 846 { | 846 { |
| 847 check_integer_range (mode, Qzero, make_int (7)); | 847 check_integer_range (mode, Qzero, make_fixnum (7)); |
| 848 return XINT (mode); | 848 return XFIXNUM (mode); |
| 849 } | 849 } |
| 850 else | 850 else |
| 851 invalid_argument ("Invalid value", mode); | 851 invalid_argument ("Invalid value", mode); |
| 852 return 0; /* unreached */ | 852 return 0; /* unreached */ |
| 853 } | 853 } |
| 1580 record_unwind_protect (save_restriction_restore, | 1580 record_unwind_protect (save_restriction_restore, |
| 1581 save_restriction_save (current_buffer)); | 1581 save_restriction_save (current_buffer)); |
| 1582 | 1582 |
| 1583 /* This both uses start and checks its type. */ | 1583 /* This both uses start and checks its type. */ |
| 1584 Fgoto_char (start, cbuf); | 1584 Fgoto_char (start, cbuf); |
| 1585 Fnarrow_to_region (make_int (BUF_BEGV (current_buffer)), end, cbuf); | 1585 Fnarrow_to_region (make_fixnum (BUF_BEGV (current_buffer)), end, cbuf); |
| 1586 readevalloop (cbuf, XBUFFER (cbuf)->filename, Feval, | 1586 readevalloop (cbuf, XBUFFER (cbuf)->filename, Feval, |
| 1587 !NILP (stream)); | 1587 !NILP (stream)); |
| 1588 | 1588 |
| 1589 return unbind_to (speccount); | 1589 return unbind_to (speccount); |
| 1590 } | 1590 } |
| 1646 | 1646 |
| 1647 tem = read0 (lispstream); | 1647 tem = read0 (lispstream); |
| 1648 /* Yeah, it's ugly. Gonna make something of it? | 1648 /* Yeah, it's ugly. Gonna make something of it? |
| 1649 At least our reader is reentrant ... */ | 1649 At least our reader is reentrant ... */ |
| 1650 tem = | 1650 tem = |
| 1651 (Fcons (tem, make_int | 1651 (Fcons (tem, make_fixnum |
| 1652 (string_index_byte_to_char | 1652 (string_index_byte_to_char |
| 1653 (string, | 1653 (string, |
| 1654 startval + Lstream_byte_count (XLSTREAM (lispstream)))))); | 1654 startval + Lstream_byte_count (XLSTREAM (lispstream)))))); |
| 1655 Lstream_delete (XLSTREAM (lispstream)); | 1655 Lstream_delete (XLSTREAM (lispstream)); |
| 1656 UNGCPRO; | 1656 UNGCPRO; |
| 1700 } | 1700 } |
| 1701 } | 1701 } |
| 1702 | 1702 |
| 1703 if (i >= 0x110000 || i < 0) | 1703 if (i >= 0x110000 || i < 0) |
| 1704 { | 1704 { |
| 1705 syntax_error ("Not a Unicode code point", make_int(i)); | 1705 syntax_error ("Not a Unicode code point", make_fixnum(i)); |
| 1706 } | 1706 } |
| 1707 | 1707 |
| 1708 lisp_char = Funicode_to_char(make_int(i), Qnil); | 1708 lisp_char = Funicode_to_char(make_fixnum(i), Qnil); |
| 1709 | 1709 |
| 1710 if (EQ(Qnil, lisp_char)) | 1710 if (EQ(Qnil, lisp_char)) |
| 1711 { | 1711 { |
| 1712 /* Will happen on non-Mule. Silent corruption is what happens | 1712 /* Will happen on non-Mule. Silent corruption is what happens |
| 1713 elsewhere, and we used to do that to be consistent, but GNU error, | 1713 elsewhere, and we used to do that to be consistent, but GNU error, |
| 1714 so people writing portable code need to be able to handle that, and | 1714 so people writing portable code need to be able to handle that, and |
| 1715 given a choice I prefer that behaviour. | 1715 given a choice I prefer that behaviour. |
| 1716 | 1716 |
| 1717 An undesirable aspect to this error is that the code point is shown | 1717 An undesirable aspect to this error is that the code point is shown |
| 1718 as a decimal integer, which is mostly unreadable. */ | 1718 as a decimal integer, which is mostly unreadable. */ |
| 1719 syntax_error ("Unsupported Unicode code point", make_int(i)); | 1719 syntax_error ("Unsupported Unicode code point", make_fixnum(i)); |
| 1720 } | 1720 } |
| 1721 | 1721 |
| 1722 return XCHAR(lisp_char); | 1722 return XCHAR(lisp_char); |
| 1723 } | 1723 } |
| 1724 | 1724 |
| 1968 number = atoi (read_buffer); | 1968 number = atoi (read_buffer); |
| 1969 else if (sizeof (long) == sizeof (EMACS_INT)) | 1969 else if (sizeof (long) == sizeof (EMACS_INT)) |
| 1970 number = atol (read_buffer); | 1970 number = atol (read_buffer); |
| 1971 else | 1971 else |
| 1972 ABORT (); | 1972 ABORT (); |
| 1973 return make_int (number); | 1973 return make_fixnum (number); |
| 1974 } | 1974 } |
| 1975 #else | 1975 #else |
| 1976 return parse_integer ((Ibyte *) read_ptr, len, 10); | 1976 return parse_integer ((Ibyte *) read_ptr, len, 10); |
| 1977 #endif | 1977 #endif |
| 1978 } | 1978 } |
| 2059 goto overflow; | 2059 goto overflow; |
| 2060 } | 2060 } |
| 2061 | 2061 |
| 2062 { | 2062 { |
| 2063 EMACS_INT int_result = negativland ? - (EMACS_INT) num : (EMACS_INT) num; | 2063 EMACS_INT int_result = negativland ? - (EMACS_INT) num : (EMACS_INT) num; |
| 2064 Lisp_Object result = make_int (int_result); | 2064 Lisp_Object result = make_fixnum (int_result); |
| 2065 if (num && ((XINT (result) < 0) != negativland)) | 2065 if (num && ((XFIXNUM (result) < 0) != negativland)) |
| 2066 goto overflow; | 2066 goto overflow; |
| 2067 if (XINT (result) != int_result) | 2067 if (XFIXNUM (result) != int_result) |
| 2068 goto overflow; | 2068 goto overflow; |
| 2069 return result; | 2069 return result; |
| 2070 } | 2070 } |
| 2071 overflow: | 2071 overflow: |
| 2072 #ifdef HAVE_BIGNUM | 2072 #ifdef HAVE_BIGNUM |
| 2077 #else | 2077 #else |
| 2078 return Fsignal (Qinvalid_read_syntax, | 2078 return Fsignal (Qinvalid_read_syntax, |
| 2079 list3 (build_msg_string | 2079 list3 (build_msg_string |
| 2080 ("Integer constant overflow in reader"), | 2080 ("Integer constant overflow in reader"), |
| 2081 make_string (buf, len), | 2081 make_string (buf, len), |
| 2082 make_int (base))); | 2082 make_fixnum (base))); |
| 2083 #endif /* HAVE_BIGNUM */ | 2083 #endif /* HAVE_BIGNUM */ |
| 2084 loser: | 2084 loser: |
| 2085 return Fsignal (Qinvalid_read_syntax, | 2085 return Fsignal (Qinvalid_read_syntax, |
| 2086 list3 (build_msg_string | 2086 list3 (build_msg_string |
| 2087 ("Invalid integer constant in reader"), | 2087 ("Invalid integer constant in reader"), |
| 2088 make_string (buf, len), | 2088 make_string (buf, len), |
| 2089 make_int (base))); | 2089 make_fixnum (base))); |
| 2090 } | 2090 } |
| 2091 | 2091 |
| 2092 | 2092 |
| 2093 static Lisp_Object | 2093 static Lisp_Object |
| 2094 read_integer (Lisp_Object readcharfun, int base) | 2094 read_integer (Lisp_Object readcharfun, int base) |
| 2198 if (c != '(') | 2198 if (c != '(') |
| 2199 RETURN_UNGCPRO (continuable_read_syntax_error ("#s not followed by paren")); | 2199 RETURN_UNGCPRO (continuable_read_syntax_error ("#s not followed by paren")); |
| 2200 list = read_list (readcharfun, ')', 0, 0); | 2200 list = read_list (readcharfun, ')', 0, 0); |
| 2201 orig_list = list; | 2201 orig_list = list; |
| 2202 { | 2202 { |
| 2203 int len = XINT (Flength (list)); | 2203 int len = XFIXNUM (Flength (list)); |
| 2204 if (len == 0) | 2204 if (len == 0) |
| 2205 RETURN_UNGCPRO (continuable_read_syntax_error | 2205 RETURN_UNGCPRO (continuable_read_syntax_error |
| 2206 ("structure type not specified")); | 2206 ("structure type not specified")); |
| 2207 if (!(len & 1)) | 2207 if (!(len & 1)) |
| 2208 RETURN_UNGCPRO | 2208 RETURN_UNGCPRO |
| 2708 { | 2708 { |
| 2709 n *= 10; | 2709 n *= 10; |
| 2710 n += c - '0'; | 2710 n += c - '0'; |
| 2711 c = readchar (readcharfun); | 2711 c = readchar (readcharfun); |
| 2712 } | 2712 } |
| 2713 found = assq_no_quit (make_int (n), Vread_objects); | 2713 found = assq_no_quit (make_fixnum (n), Vread_objects); |
| 2714 if (c == '=') | 2714 if (c == '=') |
| 2715 { | 2715 { |
| 2716 /* #n=object returns object, but associates it with | 2716 /* #n=object returns object, but associates it with |
| 2717 n for #n#. */ | 2717 n for #n#. */ |
| 2718 if (CONSP (found)) | 2718 if (CONSP (found)) |
| 2719 { | 2719 { |
| 2720 return Fsignal (Qinvalid_read_syntax, | 2720 return Fsignal (Qinvalid_read_syntax, |
| 2721 list2 (build_msg_string | 2721 list2 (build_msg_string |
| 2722 ("Multiply defined object label"), | 2722 ("Multiply defined object label"), |
| 2723 make_int (n))); | 2723 make_fixnum (n))); |
| 2724 } | 2724 } |
| 2725 else | 2725 else |
| 2726 { | 2726 { |
| 2727 Lisp_Object object; | 2727 Lisp_Object object; |
| 2728 | 2728 |
| 2729 found = Fcons (make_int (n), Qnil); | 2729 found = Fcons (make_fixnum (n), Qnil); |
| 2730 /* Make FOUND a placeholder for the object that will | 2730 /* Make FOUND a placeholder for the object that will |
| 2731 be read. (We've just consed it, and it's not | 2731 be read. (We've just consed it, and it's not |
| 2732 visible from Lisp, so there's no possibility of | 2732 visible from Lisp, so there's no possibility of |
| 2733 confusing it with something else in the read | 2733 confusing it with something else in the read |
| 2734 structure.) */ | 2734 structure.) */ |
| 2749 return XCDR (found); | 2749 return XCDR (found); |
| 2750 else | 2750 else |
| 2751 return Fsignal (Qinvalid_read_syntax, | 2751 return Fsignal (Qinvalid_read_syntax, |
| 2752 list2 (build_msg_string | 2752 list2 (build_msg_string |
| 2753 ("Undefined symbol label"), | 2753 ("Undefined symbol label"), |
| 2754 make_int (n))); | 2754 make_fixnum (n))); |
| 2755 } | 2755 } |
| 2756 return Fsignal (Qinvalid_read_syntax, | 2756 return Fsignal (Qinvalid_read_syntax, |
| 2757 list1 (build_ascstring ("#"))); | 2757 list1 (build_ascstring ("#"))); |
| 2758 } | 2758 } |
| 2759 default: | 2759 default: |
| 3157 | 3157 |
| 3158 sequence_reader (readcharfun, terminator, &s, read_list_conser); | 3158 sequence_reader (readcharfun, terminator, &s, read_list_conser); |
| 3159 | 3159 |
| 3160 UNGCPRO; | 3160 UNGCPRO; |
| 3161 tem = s.head; | 3161 tem = s.head; |
| 3162 len = XINT (Flength (tem)); | 3162 len = XFIXNUM (Flength (tem)); |
| 3163 | 3163 |
| 3164 s.head = make_vector (len, Qnil); | 3164 s.head = make_vector (len, Qnil); |
| 3165 | 3165 |
| 3166 for (i = 0, p = &(XVECTOR_DATA (s.head)[0]); | 3166 for (i = 0, p = &(XVECTOR_DATA (s.head)[0]); |
| 3167 i < len; | 3167 i < len; |
| 3190 | 3190 |
| 3191 /* Note: we tell read_list not to search for doc references | 3191 /* Note: we tell read_list not to search for doc references |
| 3192 because we need to handle the "doc reference" for the | 3192 because we need to handle the "doc reference" for the |
| 3193 instructions and constants differently. */ | 3193 instructions and constants differently. */ |
| 3194 stuff = read_list (readcharfun, terminator, 0, 0); | 3194 stuff = read_list (readcharfun, terminator, 0, 0); |
| 3195 len = XINT (Flength (stuff)); | 3195 len = XFIXNUM (Flength (stuff)); |
| 3196 if (len < COMPILED_STACK_DEPTH + 1 || len > COMPILED_DOMAIN + 1) | 3196 if (len < COMPILED_STACK_DEPTH + 1 || len > COMPILED_DOMAIN + 1) |
| 3197 return | 3197 return |
| 3198 continuable_read_syntax_error ("#[...] used with wrong number of elements"); | 3198 continuable_read_syntax_error ("#[...] used with wrong number of elements"); |
| 3199 | 3199 |
| 3200 for (iii = 0; CONSP (stuff); iii++) | 3200 for (iii = 0; CONSP (stuff); iii++) |
