From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs 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 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6273"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: dmitry@gutov.dev To: 68546@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 16 22:57:03 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rb6Cd-0001RD-3G for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 16 Feb 2024 22:57:03 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb6CL-00080e-0z; Fri, 16 Feb 2024 16:56:45 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rb6CJ-00080S-MJ for bug-gnu-emacs@gnu.org; Fri, 16 Feb 2024 16:56:43 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rb6CJ-0006vG-Aa for bug-gnu-emacs@gnu.org; Fri, 16 Feb 2024 16:56:43 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rb6Cc-000381-AB for bug-gnu-emacs@gnu.org; Fri, 16 Feb 2024 16:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 16 Feb 2024 21:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68546 X-GNU-PR-Package: emacs Original-Received: via spool by 68546-submit@debbugs.gnu.org id=B68546.170812061512012 (code B ref 68546); Fri, 16 Feb 2024 21:57:02 +0000 Original-Received: (at 68546) by debbugs.gnu.org; 16 Feb 2024 21:56:55 +0000 Original-Received: from localhost ([127.0.0.1]:60300 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rb6CV-00037f-4w for submit@debbugs.gnu.org; Fri, 16 Feb 2024 16:56:55 -0500 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:42185) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rb6CS-00037S-LZ for 68546@debbugs.gnu.org; Fri, 16 Feb 2024 16:56:53 -0500 In-Reply-To: (Spencer Baugh's message of "Wed, 17 Jan 2024 14:04:09 -0500") DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1708120587; bh=HHMKD51uUjskJ8tLiOP6uDYAEvZzbo0+Yi0nZt5GmAw=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=3Gh7MCz8hZK0HxgxLYWeM9oaAJpENMWqQWQX0XUL41DC5F0OCtexkTp2VYtqev3Zo Cq/64ehO7BOWeNbL9b481oA0v/j5oVTjDCrH8LPH1YBs5BGSY4gP7fPwvoeMXtBFj/ 9mwpc3k3ULn16+4sxx+FjGpfgtI7gwqbi2z0fxxsRI1Ho/fkvkUGB9b+su7dqkmaq4 M9ad48s0diKVJ1GQxIEB7bGC5DMZLRwefKoZYjxzfP8u8YyTM97w8mszVRD3a5qXGg NpYYJDsRlQXv8cjH96sCE0x0BpeZjyylCjtMChDLcg7jl+s/xQKczjFyY+Dc8Zln1q K9kCHAWIJRpPQ== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:280107 Archived-At: --=-=-= Content-Type: text/plain Here is a straightforward fix. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Prevent-incorrect-error-message-when-calling-read-in.patch >From d850108fa309701e4899dfbcfd5a20d1e17f86af Mon Sep 17 00:00:00 2001 From: Spencer Baugh 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 --=-=-=--