From: Spencer Baugh <sbaugh@janestreet.com>
To: 68546@debbugs.gnu.org
Cc: dmitry@gutov.dev
Subject: bug#68546: 29.1.90; end-of-file has incorrect data when signaled within a load
Date: Fri, 16 Feb 2024 16:56:26 -0500 [thread overview]
Message-ID: <iery1bkysxh.fsf@janestreet.com> (raw)
In-Reply-To: <ierle8nye6u.fsf@igm-qws-u22796a.mail-host-address-is-not-set> (Spencer Baugh's message of "Wed, 17 Jan 2024 14:04:09 -0500")
[-- Attachment #1: Type: text/plain, Size: 33 bytes --]
Here is a straightforward fix.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Prevent-incorrect-error-message-when-calling-read-in.patch --]
[-- Type: text/x-patch, Size: 3151 bytes --]
From d850108fa309701e4899dfbcfd5a20d1e17f86af Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@janestreet.com>
Date: Fri, 16 Feb 2024 16:53:28 -0500
Subject: [PATCH] Prevent incorrect error message when calling read inside load
Previously, if `load' eval'd a `read' expression which raised
end-of-file, the error would include load-true-file-name, even
though the `read' may be reading something completely different.
Now, end-of-file errors raised by `read' will only include
load-true-file-name if it's actually reading that file.
We do this by having read include read-end-of-file-name in the error
instead of load-true-file-name, and only binding read-end-of-file-name
around the "read" parts of readevalloop, not the "eval" parts.
(load-true-file-name is still bound throughout)
Also, when reading a file (or some other source), it is now
possible to bind read-end-of-file-name so that end-of-file
errors raised by read will include the filename (or the string
of your choice). Previously, an end-of-file error raised by
read outside of load would never include the filename.
* src/lread.c (syms_of_lread): Add read-end-of-file-name.
(readevalloop): Bind read-end-of-file-name to
load-true-file-name around read.
(end_of_file_error): Use read-end-of-file-name instead of
load-true-file-name. (bug#68546)
---
src/lread.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/lread.c b/src/lread.c
index 0e67a3f8879..54ae88c7eab 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2385,8 +2385,8 @@ readevalloop_1 (int old)
static AVOID
end_of_file_error (void)
{
- if (STRINGP (Vload_true_file_name))
- xsignal1 (Qend_of_file, Vload_true_file_name);
+ if (!NILP (Vread_end_of_file_name))
+ xsignal1 (Qend_of_file, Vread_end_of_file_name);
xsignal0 (Qend_of_file);
}
@@ -2490,6 +2490,8 @@ readevalloop (Lisp_Object readcharfun,
while (continue_reading_p)
{
specpdl_ref count1 = SPECPDL_INDEX ();
+ if (NILP (Vread_end_of_file_name))
+ specbind (Qread_end_of_file_name, Vload_true_file_name);
if (b != 0 && !BUFFER_LIVE_P (b))
error ("Reading from killed buffer");
@@ -2585,7 +2587,7 @@ readevalloop (Lisp_Object readcharfun,
if (!NILP (start) && continue_reading_p)
start = Fpoint_marker ();
- /* Restore saved point and BEGV. */
+ /* Restore saved point and BEGV, and unbind read_stream_for_error. */
unbind_to (count1, Qnil);
/* Now eval what we just read. */
@@ -5843,6 +5845,12 @@ syms_of_lread (void)
doc: /* Full name of file being loaded by `load'. */);
Vload_true_file_name = Qnil;
+ DEFVAR_LISP ("read-end-of-file-name", Vread_end_of_file_name,
+ doc: /* String to be included when `read' signals `end-of-file'.
+When loading a file, this is bound to the filename. */);
+ Vread_end_of_file_name = Qnil;
+ DEFSYM (Qread_end_of_file_name, "read-end-of-file-name");
+
DEFVAR_LISP ("user-init-file", Vuser_init_file,
doc: /* File name, including directory, of user's initialization file.
If the file loaded had extension `.elc', and the corresponding source file
--
2.39.3
next prev parent reply other threads:[~2024-02-16 21:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 19:04 bug#68546: 29.1.90; end-of-file has incorrect data when signaled within a load Spencer Baugh
2024-01-17 20:55 ` Dmitry Gutov
2024-01-25 14:05 ` Spencer Baugh
2024-01-25 14:12 ` Spencer Baugh
2024-01-26 0:55 ` Dmitry Gutov
2024-01-25 14:29 ` Eli Zaretskii
2024-01-26 0:45 ` Dmitry Gutov
2024-01-26 0:54 ` Dmitry Gutov
2024-02-16 21:56 ` Spencer Baugh [this message]
2024-02-17 7:14 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=iery1bkysxh.fsf@janestreet.com \
--to=sbaugh@janestreet.com \
--cc=68546@debbugs.gnu.org \
--cc=dmitry@gutov.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.