From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#68546: 29.1.90; end-of-file has incorrect data when signaled within a load Date: Sat, 17 Feb 2024 09:14:58 +0200 Message-ID: <86il2nv9xp.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21758"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dmitry@gutov.dev, 68546@debbugs.gnu.org To: Spencer Baugh , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 17 08:18:15 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 1rbExi-0005Uw-DM for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Feb 2024 08:18:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rbExJ-00086r-Ct; Sat, 17 Feb 2024 02:17:49 -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 1rbExD-00084p-Fc for bug-gnu-emacs@gnu.org; Sat, 17 Feb 2024 02:17: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 1rbExD-0004ti-75 for bug-gnu-emacs@gnu.org; Sat, 17 Feb 2024 02:17:43 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rbExW-0003fb-5V for bug-gnu-emacs@gnu.org; Sat, 17 Feb 2024 02:18:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Feb 2024 07:18: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.170815426214070 (code B ref 68546); Sat, 17 Feb 2024 07:18:02 +0000 Original-Received: (at 68546) by debbugs.gnu.org; 17 Feb 2024 07:17:42 +0000 Original-Received: from localhost ([127.0.0.1]:60359 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbExB-0003es-OZ for submit@debbugs.gnu.org; Sat, 17 Feb 2024 02:17:42 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53474) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbEx7-0003ec-C6 for 68546@debbugs.gnu.org; Sat, 17 Feb 2024 02:17:41 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rbEub-0004Rd-JX; Sat, 17 Feb 2024 02:15:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ZKTLhtHSkCbC8ig0wpQkklcbdxR4qguJoIaZirOUFPY=; b=XF/2KQoS1Vls FJD7at2QA57yGaFE01r5nhtCf34NWeKgJKg2pvLxgYjy2hNyDtWcjqU83F3YHEIv6nJk2KRZZX/MG pUTMVpRZprkEnFO7/SsRq1JMnn6ACJ5KhwzHPZ960EfsqfFj1u9663G8x9jDd3Nc0jdJhmsNGRMCe oaUve+05av/rGtPMyvf0DMN0RXIZ9s1tF6W29EjviuVeA82XrHRCEcY+l8b4A43D0dG50BwqOJvVI ihPYVQ7L5AG9kFZyN4YmSF2/f0ZSCMn08bvqXbOu+ubXxkAwXlEbI4Lw1WpIDZ2ZNT2VdtKGoiDR6 aJxIXgxqbD9SnwfrLBhE+Q==; In-Reply-To: (message from Spencer Baugh on Fri, 16 Feb 2024 16:56:26 -0500) 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:280112 Archived-At: > Cc: dmitry@gutov.dev > From: Spencer Baugh > Date: Fri, 16 Feb 2024 16:56:26 -0500 > > Here is a straightforward fix. Adding Stefan to the discussion, since this is no longer specific to project.el. Stefan, any comments? > >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. This needs the obvious documentation changes. Also, I'm not sure I understand the rationale well enough: what other use cases do we envision where read-end-of-file-name will be bound to some other string than the name of the file being read? IOW, this is a general infrastructure change, but the use cases that justify such generality are not clear to me. > --- 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); Why !NILP instead of STRINGP? read-end-of-file-name is documented to take string values. > > 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. */ read_stream_for_error or read-end-of-file-name? If the former, I don't understand the rationale for this hunk. > + DEFVAR_LISP ("read-end-of-file-name", Vread_end_of_file_name, > + doc: /* String to be included when `read' signals `end-of-file'. ^^^^^^^^^^^^^^ "included" where? This sentence needs to be clarified, either in it or in the following text. Also, the general nature of the feature is not reflected in the variable's name: if this can be any string, why does it have "file-name" in its name? Thanks.