aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSpencer Baugh2025-04-08 17:13:08 -0400
committerSean Whitton2025-08-19 17:00:03 +0100
commit63662f6ceeb7644d24cbd8b50c8bd8d0c19e79ed (patch)
tree2dc99fe58c301eddf8c64bcb278fba7eccf1f860
parentab577467e4feb681246a8d28afde729c6040dfc7 (diff)
downloademacs-63662f6ceeb7644d24cbd8b50c8bd8d0c19e79ed.tar.gz
emacs-63662f6ceeb7644d24cbd8b50c8bd8d0c19e79ed.zip
Signal end-of-file with more correct data
end_of_file_error previously always signaled end-of-file with load-true-file-name if that was non-nil (and a string). However, this might be the wrong thing to do; for example, if a file being loaded calls read on a buffer. * src/lread.c (end_of_file_error): <source>: New argument; check it to determine what data to signal with. (bug#68546) (read_char_escape, read_char_literal, read_string_literal) (skip_space_and_comments, read0): Pass source to end_of_file_error.
-rw-r--r--src/lread.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/lread.c b/src/lread.c
index 57d3239e283..80172dbe7c8 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2114,12 +2114,16 @@ build_load_history (Lisp_Object filename, bool entire)
2114 information. */ 2114 information. */
2115 2115
2116static AVOID 2116static AVOID
2117end_of_file_error (void) 2117end_of_file_error (source_t *source)
2118{ 2118{
2119 if (STRINGP (Vload_true_file_name)) 2119 if (from_file_p (source))
2120 /* Only Fload calls read on a file, and Fload always binds
2121 load-true-file-name around the call. */
2120 xsignal1 (Qend_of_file, Vload_true_file_name); 2122 xsignal1 (Qend_of_file, Vload_true_file_name);
2121 2123 else if (source->get == source_buffer_get)
2122 xsignal0 (Qend_of_file); 2124 xsignal1 (Qend_of_file, source->object);
2125 else
2126 xsignal0 (Qend_of_file);
2123} 2127}
2124 2128
2125static Lisp_Object 2129static Lisp_Object
@@ -2604,7 +2608,7 @@ read_char_escape (source_t *source, int next_char)
2604 switch (c) 2608 switch (c)
2605 { 2609 {
2606 case -1: 2610 case -1:
2607 end_of_file_error (); 2611 end_of_file_error (source);
2608 2612
2609 case 'a': chr = '\a'; break; 2613 case 'a': chr = '\a'; break;
2610 case 'b': chr = '\b'; break; 2614 case 'b': chr = '\b'; break;
@@ -2777,7 +2781,7 @@ read_char_escape (source_t *source, int next_char)
2777 { 2781 {
2778 int c = readchar (source); 2782 int c = readchar (source);
2779 if (c < 0) 2783 if (c < 0)
2780 end_of_file_error (); 2784 end_of_file_error (source);
2781 if (c == '}') 2785 if (c == '}')
2782 break; 2786 break;
2783 if (c >= 0x80) 2787 if (c >= 0x80)
@@ -2819,7 +2823,7 @@ read_char_escape (source_t *source, int next_char)
2819 break; 2823 break;
2820 } 2824 }
2821 if (chr < 0) 2825 if (chr < 0)
2822 end_of_file_error (); 2826 end_of_file_error (source);
2823 eassert (chr >= 0 && chr < (1 << CHARACTERBITS)); 2827 eassert (chr >= 0 && chr < (1 << CHARACTERBITS));
2824 2828
2825 /* Apply Control modifiers, using the rules: 2829 /* Apply Control modifiers, using the rules:
@@ -2982,7 +2986,7 @@ read_char_literal (source_t *source)
2982{ 2986{
2983 int ch = readchar (source); 2987 int ch = readchar (source);
2984 if (ch < 0) 2988 if (ch < 0)
2985 end_of_file_error (); 2989 end_of_file_error (source);
2986 2990
2987 /* Accept `single space' syntax like (list ? x) where the 2991 /* Accept `single space' syntax like (list ? x) where the
2988 whitespace character is SPC or TAB. 2992 whitespace character is SPC or TAB.
@@ -3118,7 +3122,7 @@ read_string_literal (source_t *source)
3118 } 3122 }
3119 3123
3120 if (ch < 0) 3124 if (ch < 0)
3121 end_of_file_error (); 3125 end_of_file_error (source);
3122 3126
3123 if (!force_multibyte && force_singlebyte) 3127 if (!force_multibyte && force_singlebyte)
3124 { 3128 {
@@ -3548,7 +3552,7 @@ skip_space_and_comments (source_t *source)
3548 c = readchar (source); 3552 c = readchar (source);
3549 while (c >= 0 && c != '\n'); 3553 while (c >= 0 && c != '\n');
3550 if (c < 0) 3554 if (c < 0)
3551 end_of_file_error (); 3555 end_of_file_error (source);
3552 } 3556 }
3553 while (c <= 32 || c == NO_BREAK_SPACE); 3557 while (c <= 32 || c == NO_BREAK_SPACE);
3554 unreadchar (source, c); 3558 unreadchar (source, c);
@@ -3734,7 +3738,7 @@ read0 (source_t *source, bool locate_syms)
3734 Lisp_Object obj; 3738 Lisp_Object obj;
3735 int c = readchar (source); 3739 int c = readchar (source);
3736 if (c < 0) 3740 if (c < 0)
3737 end_of_file_error (); 3741 end_of_file_error (source);
3738 3742
3739 switch (c) 3743 switch (c)
3740 { 3744 {
@@ -4151,7 +4155,7 @@ read0 (source_t *source, bool locate_syms)
4151 { 4155 {
4152 c = readchar (source); 4156 c = readchar (source);
4153 if (c < 0) 4157 if (c < 0)
4154 end_of_file_error (); 4158 end_of_file_error (source);
4155 quoted = true; 4159 quoted = true;
4156 } 4160 }
4157 4161