diff options
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 241 |
1 files changed, 107 insertions, 134 deletions
diff --git a/src/lread.c b/src/lread.c index 6b657f61ed0..38b00a66962 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -61,7 +61,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 61 | #define file_tell ftell | 61 | #define file_tell ftell |
| 62 | #endif | 62 | #endif |
| 63 | 63 | ||
| 64 | /* hash table read constants */ | 64 | /* Hash table read constants. */ |
| 65 | static Lisp_Object Qhash_table, Qdata; | 65 | static Lisp_Object Qhash_table, Qdata; |
| 66 | static Lisp_Object Qtest, Qsize; | 66 | static Lisp_Object Qtest, Qsize; |
| 67 | static Lisp_Object Qweakness; | 67 | static Lisp_Object Qweakness; |
| @@ -105,16 +105,13 @@ static Lisp_Object load_descriptor_list; | |||
| 105 | /* File for get_file_char to read from. Use by load. */ | 105 | /* File for get_file_char to read from. Use by load. */ |
| 106 | static FILE *instream; | 106 | static FILE *instream; |
| 107 | 107 | ||
| 108 | /* When nonzero, read conses in pure space */ | ||
| 109 | static int read_pure; | ||
| 110 | |||
| 111 | /* For use within read-from-string (this reader is non-reentrant!!) */ | 108 | /* For use within read-from-string (this reader is non-reentrant!!) */ |
| 112 | static EMACS_INT read_from_string_index; | 109 | static ptrdiff_t read_from_string_index; |
| 113 | static EMACS_INT read_from_string_index_byte; | 110 | static ptrdiff_t read_from_string_index_byte; |
| 114 | static EMACS_INT read_from_string_limit; | 111 | static ptrdiff_t read_from_string_limit; |
| 115 | 112 | ||
| 116 | /* Number of characters read in the current call to Fread or | 113 | /* Number of characters read in the current call to Fread or |
| 117 | Fread_from_string. */ | 114 | Fread_from_string. */ |
| 118 | static EMACS_INT readchar_count; | 115 | static EMACS_INT readchar_count; |
| 119 | 116 | ||
| 120 | /* This contains the last string skipped with #@. */ | 117 | /* This contains the last string skipped with #@. */ |
| @@ -187,7 +184,7 @@ static int readbyte_from_string (int, Lisp_Object); | |||
| 187 | /* When READCHARFUN is Qget_file_char, Qget_emacs_mule_file_char, | 184 | /* When READCHARFUN is Qget_file_char, Qget_emacs_mule_file_char, |
| 188 | Qlambda, or a cons, we use this to keep an unread character because | 185 | Qlambda, or a cons, we use this to keep an unread character because |
| 189 | a file stream can't handle multibyte-char unreading. The value -1 | 186 | a file stream can't handle multibyte-char unreading. The value -1 |
| 190 | means that there's no unread character. */ | 187 | means that there's no unread character. */ |
| 191 | static int unread_char; | 188 | static int unread_char; |
| 192 | 189 | ||
| 193 | static int | 190 | static int |
| @@ -209,7 +206,7 @@ readchar (Lisp_Object readcharfun, int *multibyte) | |||
| 209 | { | 206 | { |
| 210 | register struct buffer *inbuffer = XBUFFER (readcharfun); | 207 | register struct buffer *inbuffer = XBUFFER (readcharfun); |
| 211 | 208 | ||
| 212 | EMACS_INT pt_byte = BUF_PT_BYTE (inbuffer); | 209 | ptrdiff_t pt_byte = BUF_PT_BYTE (inbuffer); |
| 213 | 210 | ||
| 214 | if (pt_byte >= BUF_ZV_BYTE (inbuffer)) | 211 | if (pt_byte >= BUF_ZV_BYTE (inbuffer)) |
| 215 | return -1; | 212 | return -1; |
| @@ -238,7 +235,7 @@ readchar (Lisp_Object readcharfun, int *multibyte) | |||
| 238 | { | 235 | { |
| 239 | register struct buffer *inbuffer = XMARKER (readcharfun)->buffer; | 236 | register struct buffer *inbuffer = XMARKER (readcharfun)->buffer; |
| 240 | 237 | ||
| 241 | EMACS_INT bytepos = marker_byte_position (readcharfun); | 238 | ptrdiff_t bytepos = marker_byte_position (readcharfun); |
| 242 | 239 | ||
| 243 | if (bytepos >= BUF_ZV_BYTE (inbuffer)) | 240 | if (bytepos >= BUF_ZV_BYTE (inbuffer)) |
| 244 | return -1; | 241 | return -1; |
| @@ -372,8 +369,8 @@ unreadchar (Lisp_Object readcharfun, int c) | |||
| 372 | else if (BUFFERP (readcharfun)) | 369 | else if (BUFFERP (readcharfun)) |
| 373 | { | 370 | { |
| 374 | struct buffer *b = XBUFFER (readcharfun); | 371 | struct buffer *b = XBUFFER (readcharfun); |
| 375 | EMACS_INT charpos = BUF_PT (b); | 372 | ptrdiff_t charpos = BUF_PT (b); |
| 376 | EMACS_INT bytepos = BUF_PT_BYTE (b); | 373 | ptrdiff_t bytepos = BUF_PT_BYTE (b); |
| 377 | 374 | ||
| 378 | if (! NILP (BVAR (b, enable_multibyte_characters))) | 375 | if (! NILP (BVAR (b, enable_multibyte_characters))) |
| 379 | BUF_DEC_POS (b, bytepos); | 376 | BUF_DEC_POS (b, bytepos); |
| @@ -385,7 +382,7 @@ unreadchar (Lisp_Object readcharfun, int c) | |||
| 385 | else if (MARKERP (readcharfun)) | 382 | else if (MARKERP (readcharfun)) |
| 386 | { | 383 | { |
| 387 | struct buffer *b = XMARKER (readcharfun)->buffer; | 384 | struct buffer *b = XMARKER (readcharfun)->buffer; |
| 388 | EMACS_INT bytepos = XMARKER (readcharfun)->bytepos; | 385 | ptrdiff_t bytepos = XMARKER (readcharfun)->bytepos; |
| 389 | 386 | ||
| 390 | XMARKER (readcharfun)->charpos--; | 387 | XMARKER (readcharfun)->charpos--; |
| 391 | if (! NILP (BVAR (b, enable_multibyte_characters))) | 388 | if (! NILP (BVAR (b, enable_multibyte_characters))) |
| @@ -447,7 +444,7 @@ readbyte_from_file (int c, Lisp_Object readcharfun) | |||
| 447 | c = getc (instream); | 444 | c = getc (instream); |
| 448 | 445 | ||
| 449 | #ifdef EINTR | 446 | #ifdef EINTR |
| 450 | /* Interrupted reads have been observed while reading over the network */ | 447 | /* Interrupted reads have been observed while reading over the network. */ |
| 451 | while (c == EOF && ferror (instream) && errno == EINTR) | 448 | while (c == EOF && ferror (instream) && errno == EINTR) |
| 452 | { | 449 | { |
| 453 | UNBLOCK_INPUT; | 450 | UNBLOCK_INPUT; |
| @@ -608,8 +605,11 @@ read_filtered_event (int no_switch_frame, int ascii_required, | |||
| 608 | int sec, usec; | 605 | int sec, usec; |
| 609 | double duration = extract_float (seconds); | 606 | double duration = extract_float (seconds); |
| 610 | 607 | ||
| 611 | sec = (int) duration; | 608 | if (0 < duration) |
| 612 | usec = (duration - sec) * 1000000; | 609 | duration_to_sec_usec (duration, &sec, &usec); |
| 610 | else | ||
| 611 | sec = usec = 0; | ||
| 612 | |||
| 613 | EMACS_GET_TIME (end_time); | 613 | EMACS_GET_TIME (end_time); |
| 614 | EMACS_SET_SECS_USECS (wait_time, sec, usec); | 614 | EMACS_SET_SECS_USECS (wait_time, sec, usec); |
| 615 | EMACS_ADD_TIME (end_time, end_time, wait_time); | 615 | EMACS_ADD_TIME (end_time, end_time, wait_time); |
| @@ -1022,7 +1022,7 @@ Return t if the file exists and loads successfully. */) | |||
| 1022 | { | 1022 | { |
| 1023 | register FILE *stream; | 1023 | register FILE *stream; |
| 1024 | register int fd = -1; | 1024 | register int fd = -1; |
| 1025 | int count = SPECPDL_INDEX (); | 1025 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1026 | struct gcpro gcpro1, gcpro2, gcpro3; | 1026 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 1027 | Lisp_Object found, efound, hist_file_name; | 1027 | Lisp_Object found, efound, hist_file_name; |
| 1028 | /* 1 means we printed the ".el is newer" message. */ | 1028 | /* 1 means we printed the ".el is newer" message. */ |
| @@ -1067,7 +1067,7 @@ Return t if the file exists and loads successfully. */) | |||
| 1067 | 1067 | ||
| 1068 | 1068 | ||
| 1069 | /* Avoid weird lossage with null string as arg, | 1069 | /* Avoid weird lossage with null string as arg, |
| 1070 | since it would try to load a directory as a Lisp file */ | 1070 | since it would try to load a directory as a Lisp file. */ |
| 1071 | if (SBYTES (file) > 0) | 1071 | if (SBYTES (file) > 0) |
| 1072 | { | 1072 | { |
| 1073 | ptrdiff_t size = SBYTES (file); | 1073 | ptrdiff_t size = SBYTES (file); |
| @@ -1171,7 +1171,7 @@ Return t if the file exists and loads successfully. */) | |||
| 1171 | Vload_source_file_function. */ | 1171 | Vload_source_file_function. */ |
| 1172 | specbind (Qlexical_binding, Qnil); | 1172 | specbind (Qlexical_binding, Qnil); |
| 1173 | 1173 | ||
| 1174 | /* Get the name for load-history. */ | 1174 | /* Get the name for load-history. */ |
| 1175 | hist_file_name = (! NILP (Vpurify_flag) | 1175 | hist_file_name = (! NILP (Vpurify_flag) |
| 1176 | ? Fconcat (2, (tmp[0] = Ffile_name_directory (file), | 1176 | ? Fconcat (2, (tmp[0] = Ffile_name_directory (file), |
| 1177 | tmp[1] = Ffile_name_nondirectory (found), | 1177 | tmp[1] = Ffile_name_nondirectory (found), |
| @@ -1324,7 +1324,7 @@ Return t if the file exists and loads successfully. */) | |||
| 1324 | } | 1324 | } |
| 1325 | unbind_to (count, Qnil); | 1325 | unbind_to (count, Qnil); |
| 1326 | 1326 | ||
| 1327 | /* Run any eval-after-load forms for this file */ | 1327 | /* Run any eval-after-load forms for this file. */ |
| 1328 | if (!NILP (Ffboundp (Qdo_after_load_evaluation))) | 1328 | if (!NILP (Ffboundp (Qdo_after_load_evaluation))) |
| 1329 | call1 (Qdo_after_load_evaluation, hist_file_name) ; | 1329 | call1 (Qdo_after_load_evaluation, hist_file_name) ; |
| 1330 | 1330 | ||
| @@ -1356,7 +1356,7 @@ Return t if the file exists and loads successfully. */) | |||
| 1356 | } | 1356 | } |
| 1357 | 1357 | ||
| 1358 | static Lisp_Object | 1358 | static Lisp_Object |
| 1359 | load_unwind (Lisp_Object arg) /* used as unwind-protect function in load */ | 1359 | load_unwind (Lisp_Object arg) /* Used as unwind-protect function in load. */ |
| 1360 | { | 1360 | { |
| 1361 | FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer; | 1361 | FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer; |
| 1362 | if (stream != NULL) | 1362 | if (stream != NULL) |
| @@ -1442,16 +1442,16 @@ int | |||
| 1442 | openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate) | 1442 | openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate) |
| 1443 | { | 1443 | { |
| 1444 | register int fd; | 1444 | register int fd; |
| 1445 | EMACS_INT fn_size = 100; | 1445 | ptrdiff_t fn_size = 100; |
| 1446 | char buf[100]; | 1446 | char buf[100]; |
| 1447 | register char *fn = buf; | 1447 | register char *fn = buf; |
| 1448 | int absolute = 0; | 1448 | int absolute = 0; |
| 1449 | EMACS_INT want_length; | 1449 | ptrdiff_t want_length; |
| 1450 | Lisp_Object filename; | 1450 | Lisp_Object filename; |
| 1451 | struct stat st; | 1451 | struct stat st; |
| 1452 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; | 1452 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; |
| 1453 | Lisp_Object string, tail, encoded_fn; | 1453 | Lisp_Object string, tail, encoded_fn; |
| 1454 | EMACS_INT max_suffix_len = 0; | 1454 | ptrdiff_t max_suffix_len = 0; |
| 1455 | 1455 | ||
| 1456 | CHECK_STRING (str); | 1456 | CHECK_STRING (str); |
| 1457 | 1457 | ||
| @@ -1475,13 +1475,13 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto | |||
| 1475 | { | 1475 | { |
| 1476 | filename = Fexpand_file_name (str, XCAR (path)); | 1476 | filename = Fexpand_file_name (str, XCAR (path)); |
| 1477 | if (!complete_filename_p (filename)) | 1477 | if (!complete_filename_p (filename)) |
| 1478 | /* If there are non-absolute elts in PATH (eg ".") */ | 1478 | /* If there are non-absolute elts in PATH (eg "."). */ |
| 1479 | /* Of course, this could conceivably lose if luser sets | 1479 | /* Of course, this could conceivably lose if luser sets |
| 1480 | default-directory to be something non-absolute... */ | 1480 | default-directory to be something non-absolute... */ |
| 1481 | { | 1481 | { |
| 1482 | filename = Fexpand_file_name (filename, BVAR (current_buffer, directory)); | 1482 | filename = Fexpand_file_name (filename, BVAR (current_buffer, directory)); |
| 1483 | if (!complete_filename_p (filename)) | 1483 | if (!complete_filename_p (filename)) |
| 1484 | /* Give up on this path element! */ | 1484 | /* Give up on this path element! */ |
| 1485 | continue; | 1485 | continue; |
| 1486 | } | 1486 | } |
| 1487 | 1487 | ||
| @@ -1561,7 +1561,9 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto | |||
| 1561 | { | 1561 | { |
| 1562 | /* Check that we can access or open it. */ | 1562 | /* Check that we can access or open it. */ |
| 1563 | if (NATNUMP (predicate)) | 1563 | if (NATNUMP (predicate)) |
| 1564 | fd = (access (pfn, XFASTINT (predicate)) == 0) ? 1 : -1; | 1564 | fd = (((XFASTINT (predicate) & ~INT_MAX) == 0 |
| 1565 | && access (pfn, XFASTINT (predicate)) == 0) | ||
| 1566 | ? 1 : -1); | ||
| 1565 | else | 1567 | else |
| 1566 | fd = emacs_open (pfn, O_RDONLY, 0); | 1568 | fd = emacs_open (pfn, O_RDONLY, 0); |
| 1567 | 1569 | ||
| @@ -1606,12 +1608,12 @@ build_load_history (Lisp_Object filename, int entire) | |||
| 1606 | { | 1608 | { |
| 1607 | tem = XCAR (tail); | 1609 | tem = XCAR (tail); |
| 1608 | 1610 | ||
| 1609 | /* Find the feature's previous assoc list... */ | 1611 | /* Find the feature's previous assoc list... */ |
| 1610 | if (!NILP (Fequal (filename, Fcar (tem)))) | 1612 | if (!NILP (Fequal (filename, Fcar (tem)))) |
| 1611 | { | 1613 | { |
| 1612 | foundit = 1; | 1614 | foundit = 1; |
| 1613 | 1615 | ||
| 1614 | /* If we're loading the entire file, remove old data. */ | 1616 | /* If we're loading the entire file, remove old data. */ |
| 1615 | if (entire) | 1617 | if (entire) |
| 1616 | { | 1618 | { |
| 1617 | if (NILP (prev)) | 1619 | if (NILP (prev)) |
| @@ -1653,13 +1655,6 @@ build_load_history (Lisp_Object filename, int entire) | |||
| 1653 | } | 1655 | } |
| 1654 | 1656 | ||
| 1655 | static Lisp_Object | 1657 | static Lisp_Object |
| 1656 | unreadpure (Lisp_Object junk) /* Used as unwind-protect function in readevalloop */ | ||
| 1657 | { | ||
| 1658 | read_pure = 0; | ||
| 1659 | return Qnil; | ||
| 1660 | } | ||
| 1661 | |||
| 1662 | static Lisp_Object | ||
| 1663 | readevalloop_1 (Lisp_Object old) | 1658 | readevalloop_1 (Lisp_Object old) |
| 1664 | { | 1659 | { |
| 1665 | load_convert_to_unibyte = ! NILP (old); | 1660 | load_convert_to_unibyte = ! NILP (old); |
| @@ -1695,7 +1690,7 @@ readevalloop (Lisp_Object readcharfun, | |||
| 1695 | { | 1690 | { |
| 1696 | register int c; | 1691 | register int c; |
| 1697 | register Lisp_Object val; | 1692 | register Lisp_Object val; |
| 1698 | int count = SPECPDL_INDEX (); | 1693 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1699 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 1694 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 1700 | struct buffer *b = 0; | 1695 | struct buffer *b = 0; |
| 1701 | int continue_reading_p; | 1696 | int continue_reading_p; |
| @@ -1735,7 +1730,7 @@ readevalloop (Lisp_Object readcharfun, | |||
| 1735 | 1730 | ||
| 1736 | GCPRO4 (sourcename, readfun, start, end); | 1731 | GCPRO4 (sourcename, readfun, start, end); |
| 1737 | 1732 | ||
| 1738 | /* Try to ensure sourcename is a truename, except whilst preloading. */ | 1733 | /* Try to ensure sourcename is a truename, except whilst preloading. */ |
| 1739 | if (NILP (Vpurify_flag) | 1734 | if (NILP (Vpurify_flag) |
| 1740 | && !NILP (sourcename) && !NILP (Ffile_name_absolute_p (sourcename)) | 1735 | && !NILP (sourcename) && !NILP (Ffile_name_absolute_p (sourcename)) |
| 1741 | && !NILP (Ffboundp (Qfile_truename))) | 1736 | && !NILP (Ffboundp (Qfile_truename))) |
| @@ -1746,7 +1741,7 @@ readevalloop (Lisp_Object readcharfun, | |||
| 1746 | continue_reading_p = 1; | 1741 | continue_reading_p = 1; |
| 1747 | while (continue_reading_p) | 1742 | while (continue_reading_p) |
| 1748 | { | 1743 | { |
| 1749 | int count1 = SPECPDL_INDEX (); | 1744 | ptrdiff_t count1 = SPECPDL_INDEX (); |
| 1750 | 1745 | ||
| 1751 | if (b != 0 && NILP (BVAR (b, name))) | 1746 | if (b != 0 && NILP (BVAR (b, name))) |
| 1752 | error ("Reading from killed buffer"); | 1747 | error ("Reading from killed buffer"); |
| @@ -1800,8 +1795,7 @@ readevalloop (Lisp_Object readcharfun, | |||
| 1800 | 1795 | ||
| 1801 | if (!NILP (Vpurify_flag) && c == '(') | 1796 | if (!NILP (Vpurify_flag) && c == '(') |
| 1802 | { | 1797 | { |
| 1803 | record_unwind_protect (unreadpure, Qnil); | 1798 | val = read_list (0, readcharfun); |
| 1804 | val = read_list (-1, readcharfun); | ||
| 1805 | } | 1799 | } |
| 1806 | else | 1800 | else |
| 1807 | { | 1801 | { |
| @@ -1872,7 +1866,7 @@ DO-ALLOW-PRINT, if non-nil, specifies that `print' and related | |||
| 1872 | This function preserves the position of point. */) | 1866 | This function preserves the position of point. */) |
| 1873 | (Lisp_Object buffer, Lisp_Object printflag, Lisp_Object filename, Lisp_Object unibyte, Lisp_Object do_allow_print) | 1867 | (Lisp_Object buffer, Lisp_Object printflag, Lisp_Object filename, Lisp_Object unibyte, Lisp_Object do_allow_print) |
| 1874 | { | 1868 | { |
| 1875 | int count = SPECPDL_INDEX (); | 1869 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1876 | Lisp_Object tem, buf; | 1870 | Lisp_Object tem, buf; |
| 1877 | 1871 | ||
| 1878 | if (NILP (buffer)) | 1872 | if (NILP (buffer)) |
| @@ -1917,7 +1911,7 @@ This function does not move point. */) | |||
| 1917 | (Lisp_Object start, Lisp_Object end, Lisp_Object printflag, Lisp_Object read_function) | 1911 | (Lisp_Object start, Lisp_Object end, Lisp_Object printflag, Lisp_Object read_function) |
| 1918 | { | 1912 | { |
| 1919 | /* FIXME: Do the eval-sexp-add-defvars dance! */ | 1913 | /* FIXME: Do the eval-sexp-add-defvars dance! */ |
| 1920 | int count = SPECPDL_INDEX (); | 1914 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1921 | Lisp_Object tem, cbuf; | 1915 | Lisp_Object tem, cbuf; |
| 1922 | 1916 | ||
| 1923 | cbuf = Fcurrent_buffer (); | 1917 | cbuf = Fcurrent_buffer (); |
| @@ -1929,7 +1923,7 @@ This function does not move point. */) | |||
| 1929 | specbind (Qstandard_output, tem); | 1923 | specbind (Qstandard_output, tem); |
| 1930 | specbind (Qeval_buffer_list, Fcons (cbuf, Veval_buffer_list)); | 1924 | specbind (Qeval_buffer_list, Fcons (cbuf, Veval_buffer_list)); |
| 1931 | 1925 | ||
| 1932 | /* readevalloop calls functions which check the type of start and end. */ | 1926 | /* `readevalloop' calls functions which check the type of start and end. */ |
| 1933 | readevalloop (cbuf, 0, BVAR (XBUFFER (cbuf), filename), | 1927 | readevalloop (cbuf, 0, BVAR (XBUFFER (cbuf), filename), |
| 1934 | !NILP (printflag), Qnil, read_function, | 1928 | !NILP (printflag), Qnil, read_function, |
| 1935 | start, end); | 1929 | start, end); |
| @@ -1972,16 +1966,16 @@ START and END optionally delimit a substring of STRING from which to read; | |||
| 1972 | { | 1966 | { |
| 1973 | Lisp_Object ret; | 1967 | Lisp_Object ret; |
| 1974 | CHECK_STRING (string); | 1968 | CHECK_STRING (string); |
| 1975 | /* read_internal_start sets read_from_string_index. */ | 1969 | /* `read_internal_start' sets `read_from_string_index'. */ |
| 1976 | ret = read_internal_start (string, start, end); | 1970 | ret = read_internal_start (string, start, end); |
| 1977 | return Fcons (ret, make_number (read_from_string_index)); | 1971 | return Fcons (ret, make_number (read_from_string_index)); |
| 1978 | } | 1972 | } |
| 1979 | 1973 | ||
| 1980 | /* Function to set up the global context we need in toplevel read | 1974 | /* Function to set up the global context we need in toplevel read |
| 1981 | calls. */ | 1975 | calls. */ |
| 1982 | static Lisp_Object | 1976 | static Lisp_Object |
| 1983 | read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end) | 1977 | read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end) |
| 1984 | /* start, end only used when stream is a string. */ | 1978 | /* `start', `end' only used when stream is a string. */ |
| 1985 | { | 1979 | { |
| 1986 | Lisp_Object retval; | 1980 | Lisp_Object retval; |
| 1987 | 1981 | ||
| @@ -1995,7 +1989,7 @@ read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end) | |||
| 1995 | if (STRINGP (stream) | 1989 | if (STRINGP (stream) |
| 1996 | || ((CONSP (stream) && STRINGP (XCAR (stream))))) | 1990 | || ((CONSP (stream) && STRINGP (XCAR (stream))))) |
| 1997 | { | 1991 | { |
| 1998 | EMACS_INT startval, endval; | 1992 | ptrdiff_t startval, endval; |
| 1999 | Lisp_Object string; | 1993 | Lisp_Object string; |
| 2000 | 1994 | ||
| 2001 | if (STRINGP (stream)) | 1995 | if (STRINGP (stream)) |
| @@ -2008,9 +2002,9 @@ read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end) | |||
| 2008 | else | 2002 | else |
| 2009 | { | 2003 | { |
| 2010 | CHECK_NUMBER (end); | 2004 | CHECK_NUMBER (end); |
| 2011 | endval = XINT (end); | 2005 | if (! (0 <= XINT (end) && XINT (end) <= SCHARS (string))) |
| 2012 | if (endval < 0 || endval > SCHARS (string)) | ||
| 2013 | args_out_of_range (string, end); | 2006 | args_out_of_range (string, end); |
| 2007 | endval = XINT (end); | ||
| 2014 | } | 2008 | } |
| 2015 | 2009 | ||
| 2016 | if (NILP (start)) | 2010 | if (NILP (start)) |
| @@ -2018,9 +2012,9 @@ read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end) | |||
| 2018 | else | 2012 | else |
| 2019 | { | 2013 | { |
| 2020 | CHECK_NUMBER (start); | 2014 | CHECK_NUMBER (start); |
| 2021 | startval = XINT (start); | 2015 | if (! (0 <= XINT (start) && XINT (start) <= endval)) |
| 2022 | if (startval < 0 || startval > endval) | ||
| 2023 | args_out_of_range (string, start); | 2016 | args_out_of_range (string, start); |
| 2017 | startval = XINT (start); | ||
| 2024 | } | 2018 | } |
| 2025 | read_from_string_index = startval; | 2019 | read_from_string_index = startval; |
| 2026 | read_from_string_index_byte = string_char_to_byte (string, startval); | 2020 | read_from_string_index_byte = string_char_to_byte (string, startval); |
| @@ -2046,7 +2040,7 @@ invalid_syntax (const char *s) | |||
| 2046 | 2040 | ||
| 2047 | 2041 | ||
| 2048 | /* Use this for recursive reads, in contexts where internal tokens | 2042 | /* Use this for recursive reads, in contexts where internal tokens |
| 2049 | are not allowed. */ | 2043 | are not allowed. */ |
| 2050 | 2044 | ||
| 2051 | static Lisp_Object | 2045 | static Lisp_Object |
| 2052 | read0 (Lisp_Object readcharfun) | 2046 | read0 (Lisp_Object readcharfun) |
| @@ -2073,7 +2067,7 @@ read_escape (Lisp_Object readcharfun, int stringp) | |||
| 2073 | { | 2067 | { |
| 2074 | register int c = READCHAR; | 2068 | register int c = READCHAR; |
| 2075 | /* \u allows up to four hex digits, \U up to eight. Default to the | 2069 | /* \u allows up to four hex digits, \U up to eight. Default to the |
| 2076 | behavior for \u, and change this value in the case that \U is seen. */ | 2070 | behavior for \u, and change this value in the case that \U is seen. */ |
| 2077 | int unicode_hex_count = 4; | 2071 | int unicode_hex_count = 4; |
| 2078 | 2072 | ||
| 2079 | switch (c) | 2073 | switch (c) |
| @@ -2259,8 +2253,8 @@ read_escape (Lisp_Object readcharfun, int stringp) | |||
| 2259 | while (++count <= unicode_hex_count) | 2253 | while (++count <= unicode_hex_count) |
| 2260 | { | 2254 | { |
| 2261 | c = READCHAR; | 2255 | c = READCHAR; |
| 2262 | /* isdigit and isalpha may be locale-specific, which we don't | 2256 | /* `isdigit' and `isalpha' may be locale-specific, which we don't |
| 2263 | want. */ | 2257 | want. */ |
| 2264 | if (c >= '0' && c <= '9') i = (i << 4) + (c - '0'); | 2258 | if (c >= '0' && c <= '9') i = (i << 4) + (c - '0'); |
| 2265 | else if (c >= 'a' && c <= 'f') i = (i << 4) + (c - 'a') + 10; | 2259 | else if (c >= 'a' && c <= 'f') i = (i << 4) + (c - 'a') + 10; |
| 2266 | else if (c >= 'A' && c <= 'F') i = (i << 4) + (c - 'A') + 10; | 2260 | else if (c >= 'A' && c <= 'F') i = (i << 4) + (c - 'A') + 10; |
| @@ -2414,13 +2408,13 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2414 | { | 2408 | { |
| 2415 | /* Accept extended format for hashtables (extensible to | 2409 | /* Accept extended format for hashtables (extensible to |
| 2416 | other types), e.g. | 2410 | other types), e.g. |
| 2417 | #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */ | 2411 | #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */ |
| 2418 | Lisp_Object tmp = read_list (0, readcharfun); | 2412 | Lisp_Object tmp = read_list (0, readcharfun); |
| 2419 | Lisp_Object head = CAR_SAFE (tmp); | 2413 | Lisp_Object head = CAR_SAFE (tmp); |
| 2420 | Lisp_Object data = Qnil; | 2414 | Lisp_Object data = Qnil; |
| 2421 | Lisp_Object val = Qnil; | 2415 | Lisp_Object val = Qnil; |
| 2422 | /* The size is 2 * number of allowed keywords to | 2416 | /* The size is 2 * number of allowed keywords to |
| 2423 | make-hash-table. */ | 2417 | make-hash-table. */ |
| 2424 | Lisp_Object params[10]; | 2418 | Lisp_Object params[10]; |
| 2425 | Lisp_Object ht; | 2419 | Lisp_Object ht; |
| 2426 | Lisp_Object key = Qnil; | 2420 | Lisp_Object key = Qnil; |
| @@ -2432,36 +2426,36 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2432 | 2426 | ||
| 2433 | tmp = CDR_SAFE (tmp); | 2427 | tmp = CDR_SAFE (tmp); |
| 2434 | 2428 | ||
| 2435 | /* This is repetitive but fast and simple. */ | 2429 | /* This is repetitive but fast and simple. */ |
| 2436 | params[param_count] = QCsize; | 2430 | params[param_count] = QCsize; |
| 2437 | params[param_count+1] = Fplist_get (tmp, Qsize); | 2431 | params[param_count + 1] = Fplist_get (tmp, Qsize); |
| 2438 | if (!NILP (params[param_count + 1])) | 2432 | if (!NILP (params[param_count + 1])) |
| 2439 | param_count += 2; | 2433 | param_count += 2; |
| 2440 | 2434 | ||
| 2441 | params[param_count] = QCtest; | 2435 | params[param_count] = QCtest; |
| 2442 | params[param_count+1] = Fplist_get (tmp, Qtest); | 2436 | params[param_count + 1] = Fplist_get (tmp, Qtest); |
| 2443 | if (!NILP (params[param_count + 1])) | 2437 | if (!NILP (params[param_count + 1])) |
| 2444 | param_count += 2; | 2438 | param_count += 2; |
| 2445 | 2439 | ||
| 2446 | params[param_count] = QCweakness; | 2440 | params[param_count] = QCweakness; |
| 2447 | params[param_count+1] = Fplist_get (tmp, Qweakness); | 2441 | params[param_count + 1] = Fplist_get (tmp, Qweakness); |
| 2448 | if (!NILP (params[param_count + 1])) | 2442 | if (!NILP (params[param_count + 1])) |
| 2449 | param_count += 2; | 2443 | param_count += 2; |
| 2450 | 2444 | ||
| 2451 | params[param_count] = QCrehash_size; | 2445 | params[param_count] = QCrehash_size; |
| 2452 | params[param_count+1] = Fplist_get (tmp, Qrehash_size); | 2446 | params[param_count + 1] = Fplist_get (tmp, Qrehash_size); |
| 2453 | if (!NILP (params[param_count + 1])) | 2447 | if (!NILP (params[param_count + 1])) |
| 2454 | param_count += 2; | 2448 | param_count += 2; |
| 2455 | 2449 | ||
| 2456 | params[param_count] = QCrehash_threshold; | 2450 | params[param_count] = QCrehash_threshold; |
| 2457 | params[param_count+1] = Fplist_get (tmp, Qrehash_threshold); | 2451 | params[param_count + 1] = Fplist_get (tmp, Qrehash_threshold); |
| 2458 | if (!NILP (params[param_count + 1])) | 2452 | if (!NILP (params[param_count + 1])) |
| 2459 | param_count += 2; | 2453 | param_count += 2; |
| 2460 | 2454 | ||
| 2461 | /* This is the hashtable data. */ | 2455 | /* This is the hashtable data. */ |
| 2462 | data = Fplist_get (tmp, Qdata); | 2456 | data = Fplist_get (tmp, Qdata); |
| 2463 | 2457 | ||
| 2464 | /* Now use params to make a new hashtable and fill it. */ | 2458 | /* Now use params to make a new hashtable and fill it. */ |
| 2465 | ht = Fmake_hash_table (param_count, params); | 2459 | ht = Fmake_hash_table (param_count, params); |
| 2466 | 2460 | ||
| 2467 | while (CONSP (data)) | 2461 | while (CONSP (data)) |
| @@ -2498,16 +2492,17 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2498 | if (c == '[') | 2492 | if (c == '[') |
| 2499 | { | 2493 | { |
| 2500 | Lisp_Object tmp; | 2494 | Lisp_Object tmp; |
| 2501 | EMACS_INT depth, size; | 2495 | int depth; |
| 2496 | ptrdiff_t size; | ||
| 2502 | 2497 | ||
| 2503 | tmp = read_vector (readcharfun, 0); | 2498 | tmp = read_vector (readcharfun, 0); |
| 2504 | if (!INTEGERP (AREF (tmp, 0))) | 2499 | size = ASIZE (tmp); |
| 2500 | if (size == 0) | ||
| 2501 | error ("Invalid size char-table"); | ||
| 2502 | if (! RANGED_INTEGERP (1, AREF (tmp, 0), 3)) | ||
| 2505 | error ("Invalid depth in char-table"); | 2503 | error ("Invalid depth in char-table"); |
| 2506 | depth = XINT (AREF (tmp, 0)); | 2504 | depth = XINT (AREF (tmp, 0)); |
| 2507 | if (depth < 1 || depth > 3) | 2505 | if (chartab_size[depth] != size - 2) |
| 2508 | error ("Invalid depth in char-table"); | ||
| 2509 | size = ASIZE (tmp) - 2; | ||
| 2510 | if (chartab_size [depth] != size) | ||
| 2511 | error ("Invalid size char-table"); | 2506 | error ("Invalid size char-table"); |
| 2512 | XSETPVECTYPE (XVECTOR (tmp), PVEC_SUB_CHAR_TABLE); | 2507 | XSETPVECTYPE (XVECTOR (tmp), PVEC_SUB_CHAR_TABLE); |
| 2513 | return tmp; | 2508 | return tmp; |
| @@ -2728,7 +2723,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2728 | n for #n#. */ | 2723 | n for #n#. */ |
| 2729 | if (c == '=') | 2724 | if (c == '=') |
| 2730 | { | 2725 | { |
| 2731 | /* Make a placeholder for #n# to use temporarily */ | 2726 | /* Make a placeholder for #n# to use temporarily. */ |
| 2732 | Lisp_Object placeholder; | 2727 | Lisp_Object placeholder; |
| 2733 | Lisp_Object cell; | 2728 | Lisp_Object cell; |
| 2734 | 2729 | ||
| @@ -2736,10 +2731,10 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2736 | cell = Fcons (make_number (n), placeholder); | 2731 | cell = Fcons (make_number (n), placeholder); |
| 2737 | read_objects = Fcons (cell, read_objects); | 2732 | read_objects = Fcons (cell, read_objects); |
| 2738 | 2733 | ||
| 2739 | /* Read the object itself. */ | 2734 | /* Read the object itself. */ |
| 2740 | tem = read0 (readcharfun); | 2735 | tem = read0 (readcharfun); |
| 2741 | 2736 | ||
| 2742 | /* Now put it everywhere the placeholder was... */ | 2737 | /* Now put it everywhere the placeholder was... */ |
| 2743 | substitute_object_in_subtree (tem, placeholder); | 2738 | substitute_object_in_subtree (tem, placeholder); |
| 2744 | 2739 | ||
| 2745 | /* ...and #n# will use the real value from now on. */ | 2740 | /* ...and #n# will use the real value from now on. */ |
| @@ -2922,7 +2917,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2922 | 2917 | ||
| 2923 | ch = read_escape (readcharfun, 1); | 2918 | ch = read_escape (readcharfun, 1); |
| 2924 | 2919 | ||
| 2925 | /* CH is -1 if \ newline has just been seen */ | 2920 | /* CH is -1 if \ newline has just been seen. */ |
| 2926 | if (ch == -1) | 2921 | if (ch == -1) |
| 2927 | { | 2922 | { |
| 2928 | if (p == read_buffer) | 2923 | if (p == read_buffer) |
| @@ -2937,7 +2932,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2937 | force_singlebyte = 1; | 2932 | force_singlebyte = 1; |
| 2938 | else if (! ASCII_CHAR_P (ch)) | 2933 | else if (! ASCII_CHAR_P (ch)) |
| 2939 | force_multibyte = 1; | 2934 | force_multibyte = 1; |
| 2940 | else /* i.e. ASCII_CHAR_P (ch) */ | 2935 | else /* I.e. ASCII_CHAR_P (ch). */ |
| 2941 | { | 2936 | { |
| 2942 | /* Allow `\C- ' and `\C-?'. */ | 2937 | /* Allow `\C- ' and `\C-?'. */ |
| 2943 | if (modifiers == CHAR_CTL) | 2938 | if (modifiers == CHAR_CTL) |
| @@ -2987,28 +2982,19 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2987 | 2982 | ||
| 2988 | /* If purifying, and string starts with \ newline, | 2983 | /* If purifying, and string starts with \ newline, |
| 2989 | return zero instead. This is for doc strings | 2984 | return zero instead. This is for doc strings |
| 2990 | that we are really going to find in etc/DOC.nn.nn */ | 2985 | that we are really going to find in etc/DOC.nn.nn. */ |
| 2991 | if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel) | 2986 | if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel) |
| 2992 | return make_number (0); | 2987 | return make_number (0); |
| 2993 | 2988 | ||
| 2994 | if (force_multibyte) | 2989 | if (! force_multibyte && force_singlebyte) |
| 2995 | /* READ_BUFFER already contains valid multibyte forms. */ | ||
| 2996 | ; | ||
| 2997 | else if (force_singlebyte) | ||
| 2998 | { | 2990 | { |
| 2991 | /* READ_BUFFER contains raw 8-bit bytes and no multibyte | ||
| 2992 | forms. Convert it to unibyte. */ | ||
| 2999 | nchars = str_as_unibyte ((unsigned char *) read_buffer, | 2993 | nchars = str_as_unibyte ((unsigned char *) read_buffer, |
| 3000 | p - read_buffer); | 2994 | p - read_buffer); |
| 3001 | p = read_buffer + nchars; | 2995 | p = read_buffer + nchars; |
| 3002 | } | 2996 | } |
| 3003 | else | ||
| 3004 | { | ||
| 3005 | /* Otherwise, READ_BUFFER contains only ASCII. */ | ||
| 3006 | } | ||
| 3007 | 2997 | ||
| 3008 | if (read_pure) | ||
| 3009 | return make_pure_string (read_buffer, nchars, p - read_buffer, | ||
| 3010 | (force_multibyte | ||
| 3011 | || (p - read_buffer != nchars))); | ||
| 3012 | return make_specified_string (read_buffer, nchars, p - read_buffer, | 2998 | return make_specified_string (read_buffer, nchars, p - read_buffer, |
| 3013 | (force_multibyte | 2999 | (force_multibyte |
| 3014 | || (p - read_buffer != nchars))); | 3000 | || (p - read_buffer != nchars))); |
| @@ -3102,25 +3088,24 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3102 | } | 3088 | } |
| 3103 | { | 3089 | { |
| 3104 | Lisp_Object name, result; | 3090 | Lisp_Object name, result; |
| 3105 | EMACS_INT nbytes = p - read_buffer; | 3091 | ptrdiff_t nbytes = p - read_buffer; |
| 3106 | EMACS_INT nchars | 3092 | ptrdiff_t nchars |
| 3107 | = (multibyte | 3093 | = (multibyte |
| 3108 | ? multibyte_chars_in_text ((unsigned char *) read_buffer, | 3094 | ? multibyte_chars_in_text ((unsigned char *) read_buffer, |
| 3109 | nbytes) | 3095 | nbytes) |
| 3110 | : nbytes); | 3096 | : nbytes); |
| 3111 | 3097 | ||
| 3112 | if (uninterned_symbol && ! NILP (Vpurify_flag)) | 3098 | name = ((uninterned_symbol && ! NILP (Vpurify_flag) |
| 3113 | name = make_pure_string (read_buffer, nchars, nbytes, multibyte); | 3099 | ? make_pure_string : make_specified_string) |
| 3114 | else | 3100 | (read_buffer, nchars, nbytes, multibyte)); |
| 3115 | name = make_specified_string (read_buffer, nchars, nbytes, multibyte); | ||
| 3116 | result = (uninterned_symbol ? Fmake_symbol (name) | 3101 | result = (uninterned_symbol ? Fmake_symbol (name) |
| 3117 | : Fintern (name, Qnil)); | 3102 | : Fintern (name, Qnil)); |
| 3118 | 3103 | ||
| 3119 | if (EQ (Vread_with_symbol_positions, Qt) | 3104 | if (EQ (Vread_with_symbol_positions, Qt) |
| 3120 | || EQ (Vread_with_symbol_positions, readcharfun)) | 3105 | || EQ (Vread_with_symbol_positions, readcharfun)) |
| 3121 | Vread_symbol_positions_list = | 3106 | Vread_symbol_positions_list |
| 3122 | Fcons (Fcons (result, make_number (start_position)), | 3107 | = Fcons (Fcons (result, make_number (start_position)), |
| 3123 | Vread_symbol_positions_list); | 3108 | Vread_symbol_positions_list); |
| 3124 | return result; | 3109 | return result; |
| 3125 | } | 3110 | } |
| 3126 | } | 3111 | } |
| @@ -3128,7 +3113,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3128 | } | 3113 | } |
| 3129 | 3114 | ||
| 3130 | 3115 | ||
| 3131 | /* List of nodes we've seen during substitute_object_in_subtree. */ | 3116 | /* List of nodes we've seen during substitute_object_in_subtree. */ |
| 3132 | static Lisp_Object seen_list; | 3117 | static Lisp_Object seen_list; |
| 3133 | 3118 | ||
| 3134 | static void | 3119 | static void |
| @@ -3136,23 +3121,23 @@ substitute_object_in_subtree (Lisp_Object object, Lisp_Object placeholder) | |||
| 3136 | { | 3121 | { |
| 3137 | Lisp_Object check_object; | 3122 | Lisp_Object check_object; |
| 3138 | 3123 | ||
| 3139 | /* We haven't seen any objects when we start. */ | 3124 | /* We haven't seen any objects when we start. */ |
| 3140 | seen_list = Qnil; | 3125 | seen_list = Qnil; |
| 3141 | 3126 | ||
| 3142 | /* Make all the substitutions. */ | 3127 | /* Make all the substitutions. */ |
| 3143 | check_object | 3128 | check_object |
| 3144 | = substitute_object_recurse (object, placeholder, object); | 3129 | = substitute_object_recurse (object, placeholder, object); |
| 3145 | 3130 | ||
| 3146 | /* Clear seen_list because we're done with it. */ | 3131 | /* Clear seen_list because we're done with it. */ |
| 3147 | seen_list = Qnil; | 3132 | seen_list = Qnil; |
| 3148 | 3133 | ||
| 3149 | /* The returned object here is expected to always eq the | 3134 | /* The returned object here is expected to always eq the |
| 3150 | original. */ | 3135 | original. */ |
| 3151 | if (!EQ (check_object, object)) | 3136 | if (!EQ (check_object, object)) |
| 3152 | error ("Unexpected mutation error in reader"); | 3137 | error ("Unexpected mutation error in reader"); |
| 3153 | } | 3138 | } |
| 3154 | 3139 | ||
| 3155 | /* Feval doesn't get called from here, so no gc protection is needed. */ | 3140 | /* Feval doesn't get called from here, so no gc protection is needed. */ |
| 3156 | #define SUBSTITUTE(get_val, set_val) \ | 3141 | #define SUBSTITUTE(get_val, set_val) \ |
| 3157 | do { \ | 3142 | do { \ |
| 3158 | Lisp_Object old_value = get_val; \ | 3143 | Lisp_Object old_value = get_val; \ |
| @@ -3169,11 +3154,11 @@ substitute_object_in_subtree (Lisp_Object object, Lisp_Object placeholder) | |||
| 3169 | static Lisp_Object | 3154 | static Lisp_Object |
| 3170 | substitute_object_recurse (Lisp_Object object, Lisp_Object placeholder, Lisp_Object subtree) | 3155 | substitute_object_recurse (Lisp_Object object, Lisp_Object placeholder, Lisp_Object subtree) |
| 3171 | { | 3156 | { |
| 3172 | /* If we find the placeholder, return the target object. */ | 3157 | /* If we find the placeholder, return the target object. */ |
| 3173 | if (EQ (placeholder, subtree)) | 3158 | if (EQ (placeholder, subtree)) |
| 3174 | return object; | 3159 | return object; |
| 3175 | 3160 | ||
| 3176 | /* If we've been to this node before, don't explore it again. */ | 3161 | /* If we've been to this node before, don't explore it again. */ |
| 3177 | if (!EQ (Qnil, Fmemq (subtree, seen_list))) | 3162 | if (!EQ (Qnil, Fmemq (subtree, seen_list))) |
| 3178 | return subtree; | 3163 | return subtree; |
| 3179 | 3164 | ||
| @@ -3223,7 +3208,7 @@ substitute_object_recurse (Lisp_Object object, Lisp_Object placeholder, Lisp_Obj | |||
| 3223 | case Lisp_String: | 3208 | case Lisp_String: |
| 3224 | { | 3209 | { |
| 3225 | /* Check for text properties in each interval. | 3210 | /* Check for text properties in each interval. |
| 3226 | substitute_in_interval contains part of the logic. */ | 3211 | substitute_in_interval contains part of the logic. */ |
| 3227 | 3212 | ||
| 3228 | INTERVAL root_interval = STRING_INTERVALS (subtree); | 3213 | INTERVAL root_interval = STRING_INTERVALS (subtree); |
| 3229 | Lisp_Object arg = Fcons (object, placeholder); | 3214 | Lisp_Object arg = Fcons (object, placeholder); |
| @@ -3234,7 +3219,7 @@ substitute_object_recurse (Lisp_Object object, Lisp_Object placeholder, Lisp_Obj | |||
| 3234 | return subtree; | 3219 | return subtree; |
| 3235 | } | 3220 | } |
| 3236 | 3221 | ||
| 3237 | /* Other types don't recurse any further. */ | 3222 | /* Other types don't recurse any further. */ |
| 3238 | default: | 3223 | default: |
| 3239 | return subtree; | 3224 | return subtree; |
| 3240 | } | 3225 | } |
| @@ -3421,7 +3406,7 @@ read_vector (Lisp_Object readcharfun, int bytecodeflag) | |||
| 3421 | 3406 | ||
| 3422 | tem = read_list (1, readcharfun); | 3407 | tem = read_list (1, readcharfun); |
| 3423 | len = Flength (tem); | 3408 | len = Flength (tem); |
| 3424 | vector = (read_pure ? make_pure_vector (XINT (len)) : Fmake_vector (len, Qnil)); | 3409 | vector = Fmake_vector (len, Qnil); |
| 3425 | 3410 | ||
| 3426 | size = ASIZE (vector); | 3411 | size = ASIZE (vector); |
| 3427 | ptr = XVECTOR (vector)->contents; | 3412 | ptr = XVECTOR (vector)->contents; |
| @@ -3468,7 +3453,7 @@ read_vector (Lisp_Object readcharfun, int bytecodeflag) | |||
| 3468 | } | 3453 | } |
| 3469 | 3454 | ||
| 3470 | /* Now handle the bytecode slot. */ | 3455 | /* Now handle the bytecode slot. */ |
| 3471 | ptr[COMPILED_BYTECODE] = read_pure ? Fpurecopy (bytestr) : bytestr; | 3456 | ptr[COMPILED_BYTECODE] = bytestr; |
| 3472 | } | 3457 | } |
| 3473 | else if (i == COMPILED_DOC_STRING | 3458 | else if (i == COMPILED_DOC_STRING |
| 3474 | && STRINGP (item) | 3459 | && STRINGP (item) |
| @@ -3480,7 +3465,7 @@ read_vector (Lisp_Object readcharfun, int bytecodeflag) | |||
| 3480 | item = Fstring_as_multibyte (item); | 3465 | item = Fstring_as_multibyte (item); |
| 3481 | } | 3466 | } |
| 3482 | } | 3467 | } |
| 3483 | ptr[i] = read_pure ? Fpurecopy (item) : item; | 3468 | ptr[i] = item; |
| 3484 | otem = XCONS (tem); | 3469 | otem = XCONS (tem); |
| 3485 | tem = Fcdr (tem); | 3470 | tem = Fcdr (tem); |
| 3486 | free_cons (otem); | 3471 | free_cons (otem); |
| @@ -3488,17 +3473,11 @@ read_vector (Lisp_Object readcharfun, int bytecodeflag) | |||
| 3488 | return vector; | 3473 | return vector; |
| 3489 | } | 3474 | } |
| 3490 | 3475 | ||
| 3491 | /* FLAG = 1 means check for ] to terminate rather than ) and . | 3476 | /* FLAG = 1 means check for ] to terminate rather than ) and . */ |
| 3492 | FLAG = -1 means check for starting with defun | ||
| 3493 | and make structure pure. */ | ||
| 3494 | 3477 | ||
| 3495 | static Lisp_Object | 3478 | static Lisp_Object |
| 3496 | read_list (int flag, register Lisp_Object readcharfun) | 3479 | read_list (int flag, register Lisp_Object readcharfun) |
| 3497 | { | 3480 | { |
| 3498 | /* -1 means check next element for defun, | ||
| 3499 | 0 means don't check, | ||
| 3500 | 1 means already checked and found defun. */ | ||
| 3501 | int defunflag = flag < 0 ? -1 : 0; | ||
| 3502 | Lisp_Object val, tail; | 3481 | Lisp_Object val, tail; |
| 3503 | register Lisp_Object elt, tem; | 3482 | register Lisp_Object elt, tem; |
| 3504 | struct gcpro gcpro1, gcpro2; | 3483 | struct gcpro gcpro1, gcpro2; |
| @@ -3540,7 +3519,7 @@ read_list (int flag, register Lisp_Object readcharfun) | |||
| 3540 | We don't use Fexpand_file_name because that would make | 3519 | We don't use Fexpand_file_name because that would make |
| 3541 | the directory absolute now. */ | 3520 | the directory absolute now. */ |
| 3542 | elt = concat2 (build_string ("../lisp/"), | 3521 | elt = concat2 (build_string ("../lisp/"), |
| 3543 | Ffile_name_nondirectory (elt)); | 3522 | Ffile_name_nondirectory (elt)); |
| 3544 | } | 3523 | } |
| 3545 | else if (EQ (elt, Vload_file_name) | 3524 | else if (EQ (elt, Vload_file_name) |
| 3546 | && ! NILP (elt) | 3525 | && ! NILP (elt) |
| @@ -3660,24 +3639,18 @@ read_list (int flag, register Lisp_Object readcharfun) | |||
| 3660 | } | 3639 | } |
| 3661 | invalid_syntax ("] in a list"); | 3640 | invalid_syntax ("] in a list"); |
| 3662 | } | 3641 | } |
| 3663 | tem = (read_pure && flag <= 0 | 3642 | tem = Fcons (elt, Qnil); |
| 3664 | ? pure_cons (elt, Qnil) | ||
| 3665 | : Fcons (elt, Qnil)); | ||
| 3666 | if (!NILP (tail)) | 3643 | if (!NILP (tail)) |
| 3667 | XSETCDR (tail, tem); | 3644 | XSETCDR (tail, tem); |
| 3668 | else | 3645 | else |
| 3669 | val = tem; | 3646 | val = tem; |
| 3670 | tail = tem; | 3647 | tail = tem; |
| 3671 | if (defunflag < 0) | ||
| 3672 | defunflag = EQ (elt, Qdefun); | ||
| 3673 | else if (defunflag > 0) | ||
| 3674 | read_pure = 1; | ||
| 3675 | } | 3648 | } |
| 3676 | } | 3649 | } |
| 3677 | 3650 | ||
| 3678 | static Lisp_Object initial_obarray; | 3651 | static Lisp_Object initial_obarray; |
| 3679 | 3652 | ||
| 3680 | /* oblookup stores the bucket number here, for the sake of Funintern. */ | 3653 | /* `oblookup' stores the bucket number here, for the sake of Funintern. */ |
| 3681 | 3654 | ||
| 3682 | static size_t oblookup_last_bucket_number; | 3655 | static size_t oblookup_last_bucket_number; |
| 3683 | 3656 | ||
| @@ -3888,7 +3861,7 @@ OBARRAY defaults to the value of the variable `obarray'. */) | |||
| 3888 | Also store the bucket number in oblookup_last_bucket_number. */ | 3861 | Also store the bucket number in oblookup_last_bucket_number. */ |
| 3889 | 3862 | ||
| 3890 | Lisp_Object | 3863 | Lisp_Object |
| 3891 | oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_INT size_byte) | 3864 | oblookup (Lisp_Object obarray, register const char *ptr, ptrdiff_t size, ptrdiff_t size_byte) |
| 3892 | { | 3865 | { |
| 3893 | size_t hash; | 3866 | size_t hash; |
| 3894 | size_t obsize; | 3867 | size_t obsize; |
| @@ -3909,7 +3882,7 @@ oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_I | |||
| 3909 | if (EQ (bucket, make_number (0))) | 3882 | if (EQ (bucket, make_number (0))) |
| 3910 | ; | 3883 | ; |
| 3911 | else if (!SYMBOLP (bucket)) | 3884 | else if (!SYMBOLP (bucket)) |
| 3912 | error ("Bad data in guts of obarray"); /* Like CADR error message */ | 3885 | error ("Bad data in guts of obarray"); /* Like CADR error message. */ |
| 3913 | else | 3886 | else |
| 3914 | for (tail = bucket; ; XSETSYMBOL (tail, XSYMBOL (tail)->next)) | 3887 | for (tail = bucket; ; XSETSYMBOL (tail, XSYMBOL (tail)->next)) |
| 3915 | { | 3888 | { |
| @@ -4016,7 +3989,7 @@ defsubr (struct Lisp_Subr *sname) | |||
| 4016 | XSETSUBR (XSYMBOL (sym)->function, sname); | 3989 | XSETSUBR (XSYMBOL (sym)->function, sname); |
| 4017 | } | 3990 | } |
| 4018 | 3991 | ||
| 4019 | #ifdef NOTDEF /* use fset in subr.el now */ | 3992 | #ifdef NOTDEF /* Use fset in subr.el now! */ |
| 4020 | void | 3993 | void |
| 4021 | defalias (struct Lisp_Subr *sname, char *string) | 3994 | defalias (struct Lisp_Subr *sname, char *string) |
| 4022 | { | 3995 | { |
| @@ -4361,7 +4334,7 @@ dir_warning (const char *format, Lisp_Object dirname) | |||
| 4361 | { | 4334 | { |
| 4362 | fprintf (stderr, format, SDATA (dirname)); | 4335 | fprintf (stderr, format, SDATA (dirname)); |
| 4363 | 4336 | ||
| 4364 | /* Don't log the warning before we've initialized!! */ | 4337 | /* Don't log the warning before we've initialized!! */ |
| 4365 | if (initialized) | 4338 | if (initialized) |
| 4366 | { | 4339 | { |
| 4367 | char *buffer; | 4340 | char *buffer; |