diff options
| author | Dave Love | 2002-06-24 18:23:15 +0000 |
|---|---|---|
| committer | Dave Love | 2002-06-24 18:23:15 +0000 |
| commit | 1da3b9e4a6fd6e08ee23543d201515c6df7cad4f (patch) | |
| tree | 04552a3cf86b93a6755d212d794718b254d72fd6 /src | |
| parent | 380adc3cb3816128eee6fa53b15409dbfc37e0a5 (diff) | |
| download | emacs-1da3b9e4a6fd6e08ee23543d201515c6df7cad4f.tar.gz emacs-1da3b9e4a6fd6e08ee23543d201515c6df7cad4f.zip | |
Remove some unused variables.
(safe_to_load_p): If safe, return the magic number version byte.
(Fload): Maybe use load-with-code-conversion.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lread.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/src/lread.c b/src/lread.c index 360fa68386d..d2d55be637a 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Lisp parsing and input streams. | 1 | /* Lisp parsing and input streams. |
| 2 | Copyright (C) 1985, 86, 87, 88, 89, 93, 94, 95, 97, 98, 99, 2000, 2001 | 2 | Copyright (C) 1985, 86, 87, 88, 89, 93, 94, 95, 97, 98, 99, 2000, 01, 02 |
| 3 | Free Software Foundation, Inc. | 3 | Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| @@ -190,7 +190,6 @@ int load_dangerous_libraries; | |||
| 190 | 190 | ||
| 191 | static Lisp_Object Vbytecomp_version_regexp; | 191 | static Lisp_Object Vbytecomp_version_regexp; |
| 192 | 192 | ||
| 193 | static void to_multibyte P_ ((char **, char **, int *)); | ||
| 194 | static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object, | 193 | static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object, |
| 195 | Lisp_Object (*) (), int, | 194 | Lisp_Object (*) (), int, |
| 196 | Lisp_Object, Lisp_Object)); | 195 | Lisp_Object, Lisp_Object)); |
| @@ -221,7 +220,6 @@ readchar (readcharfun) | |||
| 221 | register struct buffer *inbuffer = XBUFFER (readcharfun); | 220 | register struct buffer *inbuffer = XBUFFER (readcharfun); |
| 222 | 221 | ||
| 223 | int pt_byte = BUF_PT_BYTE (inbuffer); | 222 | int pt_byte = BUF_PT_BYTE (inbuffer); |
| 224 | int orig_pt_byte = pt_byte; | ||
| 225 | 223 | ||
| 226 | if (readchar_backlog > 0) | 224 | if (readchar_backlog > 0) |
| 227 | /* We get the address of the byte just passed, | 225 | /* We get the address of the byte just passed, |
| @@ -257,7 +255,6 @@ readchar (readcharfun) | |||
| 257 | register struct buffer *inbuffer = XMARKER (readcharfun)->buffer; | 255 | register struct buffer *inbuffer = XMARKER (readcharfun)->buffer; |
| 258 | 256 | ||
| 259 | int bytepos = marker_byte_position (readcharfun); | 257 | int bytepos = marker_byte_position (readcharfun); |
| 260 | int orig_bytepos = bytepos; | ||
| 261 | 258 | ||
| 262 | if (readchar_backlog > 0) | 259 | if (readchar_backlog > 0) |
| 263 | /* We get the address of the byte just passed, | 260 | /* We get the address of the byte just passed, |
| @@ -568,7 +565,7 @@ safe_to_load_p (fd) | |||
| 568 | { | 565 | { |
| 569 | char buf[512]; | 566 | char buf[512]; |
| 570 | int nbytes, i; | 567 | int nbytes, i; |
| 571 | int safe_p = 1; | 568 | int safe_p = 1, version = 0; |
| 572 | 569 | ||
| 573 | /* Read the first few bytes from the file, and look for a line | 570 | /* Read the first few bytes from the file, and look for a line |
| 574 | specifying the byte compiler version used. */ | 571 | specifying the byte compiler version used. */ |
| @@ -578,15 +575,18 @@ safe_to_load_p (fd) | |||
| 578 | buf[nbytes] = '\0'; | 575 | buf[nbytes] = '\0'; |
| 579 | 576 | ||
| 580 | /* Skip to the next newline, skipping over the initial `ELC' | 577 | /* Skip to the next newline, skipping over the initial `ELC' |
| 581 | with NUL bytes following it. */ | 578 | with NUL bytes following it, but note the version. */ |
| 582 | for (i = 0; i < nbytes && buf[i] != '\n'; ++i) | 579 | for (i = 0; i < nbytes && buf[i] != '\n'; ++i) |
| 583 | ; | 580 | if (i == 4) |
| 581 | version = buf[i]; | ||
| 584 | 582 | ||
| 585 | if (i < nbytes | 583 | if (i < nbytes |
| 586 | && fast_c_string_match_ignore_case (Vbytecomp_version_regexp, | 584 | && fast_c_string_match_ignore_case (Vbytecomp_version_regexp, |
| 587 | buf + i) < 0) | 585 | buf + i) < 0) |
| 588 | safe_p = 0; | 586 | safe_p = 0; |
| 589 | } | 587 | } |
| 588 | if (safe_p) | ||
| 589 | safe_p = version; | ||
| 590 | 590 | ||
| 591 | lseek (fd, 0, SEEK_SET); | 591 | lseek (fd, 0, SEEK_SET); |
| 592 | return safe_p; | 592 | return safe_p; |
| @@ -752,9 +752,9 @@ Return t if file exists. */) | |||
| 752 | if (fd != -2) | 752 | if (fd != -2) |
| 753 | { | 753 | { |
| 754 | struct stat s1, s2; | 754 | struct stat s1, s2; |
| 755 | int result; | 755 | int result, version; |
| 756 | 756 | ||
| 757 | if (!safe_to_load_p (fd)) | 757 | if (!(version = safe_to_load_p (fd))) |
| 758 | { | 758 | { |
| 759 | safe_p = 0; | 759 | safe_p = 0; |
| 760 | if (!load_dangerous_libraries) | 760 | if (!load_dangerous_libraries) |
| @@ -766,6 +766,24 @@ Return t if file exists. */) | |||
| 766 | 766 | ||
| 767 | compiled = 1; | 767 | compiled = 1; |
| 768 | 768 | ||
| 769 | if (version == 20) /* 21 isn't used */ | ||
| 770 | /* We're loading something compiled with Mule 3, 4 or 5, | ||
| 771 | and thus potentially emacs-mule-encoded; load it with | ||
| 772 | code conversion. (Perhaps the test should actually be | ||
| 773 | <22?) We could check further on whether the comment | ||
| 774 | mentions multibyte and only code-convert if it does. I | ||
| 775 | doubt it's worth the effort. -- fx */ | ||
| 776 | { | ||
| 777 | Lisp_Object val; | ||
| 778 | |||
| 779 | if (fd >= 0) | ||
| 780 | emacs_close (fd); | ||
| 781 | val = call4 (intern ("load-with-code-conversion"), found, file, | ||
| 782 | NILP (noerror) ? Qnil : Qt, | ||
| 783 | NILP (nomessage) ? Qnil : Qt); | ||
| 784 | return unbind_to (count, val); | ||
| 785 | } | ||
| 786 | |||
| 769 | #ifdef DOS_NT | 787 | #ifdef DOS_NT |
| 770 | fmode = "rb"; | 788 | fmode = "rb"; |
| 771 | #endif /* DOS_NT */ | 789 | #endif /* DOS_NT */ |