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) 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; }