mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-24 22:40:51 -08:00
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.
This commit is contained in:
parent
ab577467e4
commit
63662f6cee
1 changed files with 16 additions and 12 deletions
28
src/lread.c
28
src/lread.c
|
|
@ -2114,12 +2114,16 @@ build_load_history (Lisp_Object filename, bool entire)
|
|||
information. */
|
||||
|
||||
static AVOID
|
||||
end_of_file_error (void)
|
||||
end_of_file_error (source_t *source)
|
||||
{
|
||||
if (STRINGP (Vload_true_file_name))
|
||||
if (from_file_p (source))
|
||||
/* Only Fload calls read on a file, and Fload always binds
|
||||
load-true-file-name around the call. */
|
||||
xsignal1 (Qend_of_file, Vload_true_file_name);
|
||||
|
||||
xsignal0 (Qend_of_file);
|
||||
else if (source->get == source_buffer_get)
|
||||
xsignal1 (Qend_of_file, source->object);
|
||||
else
|
||||
xsignal0 (Qend_of_file);
|
||||
}
|
||||
|
||||
static Lisp_Object
|
||||
|
|
@ -2604,7 +2608,7 @@ read_char_escape (source_t *source, int next_char)
|
|||
switch (c)
|
||||
{
|
||||
case -1:
|
||||
end_of_file_error ();
|
||||
end_of_file_error (source);
|
||||
|
||||
case 'a': chr = '\a'; break;
|
||||
case 'b': chr = '\b'; break;
|
||||
|
|
@ -2777,7 +2781,7 @@ read_char_escape (source_t *source, int next_char)
|
|||
{
|
||||
int c = readchar (source);
|
||||
if (c < 0)
|
||||
end_of_file_error ();
|
||||
end_of_file_error (source);
|
||||
if (c == '}')
|
||||
break;
|
||||
if (c >= 0x80)
|
||||
|
|
@ -2819,7 +2823,7 @@ read_char_escape (source_t *source, int next_char)
|
|||
break;
|
||||
}
|
||||
if (chr < 0)
|
||||
end_of_file_error ();
|
||||
end_of_file_error (source);
|
||||
eassert (chr >= 0 && chr < (1 << CHARACTERBITS));
|
||||
|
||||
/* Apply Control modifiers, using the rules:
|
||||
|
|
@ -2982,7 +2986,7 @@ read_char_literal (source_t *source)
|
|||
{
|
||||
int ch = readchar (source);
|
||||
if (ch < 0)
|
||||
end_of_file_error ();
|
||||
end_of_file_error (source);
|
||||
|
||||
/* Accept `single space' syntax like (list ? x) where the
|
||||
whitespace character is SPC or TAB.
|
||||
|
|
@ -3118,7 +3122,7 @@ read_string_literal (source_t *source)
|
|||
}
|
||||
|
||||
if (ch < 0)
|
||||
end_of_file_error ();
|
||||
end_of_file_error (source);
|
||||
|
||||
if (!force_multibyte && force_singlebyte)
|
||||
{
|
||||
|
|
@ -3548,7 +3552,7 @@ skip_space_and_comments (source_t *source)
|
|||
c = readchar (source);
|
||||
while (c >= 0 && c != '\n');
|
||||
if (c < 0)
|
||||
end_of_file_error ();
|
||||
end_of_file_error (source);
|
||||
}
|
||||
while (c <= 32 || c == NO_BREAK_SPACE);
|
||||
unreadchar (source, c);
|
||||
|
|
@ -3734,7 +3738,7 @@ read0 (source_t *source, bool locate_syms)
|
|||
Lisp_Object obj;
|
||||
int c = readchar (source);
|
||||
if (c < 0)
|
||||
end_of_file_error ();
|
||||
end_of_file_error (source);
|
||||
|
||||
switch (c)
|
||||
{
|
||||
|
|
@ -4151,7 +4155,7 @@ read0 (source_t *source, bool locate_syms)
|
|||
{
|
||||
c = readchar (source);
|
||||
if (c < 0)
|
||||
end_of_file_error ();
|
||||
end_of_file_error (source);
|
||||
quoted = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue