GNU bug report logs - #77656
[PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Spencer Baugh <sbaugh@HIDDEN>; Keywords: patch; dated Tue, 8 Apr 2025 21:43:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 77656 <at> debbugs.gnu.org:


Received: (at 77656) by debbugs.gnu.org; 12 Apr 2025 11:14:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 12 07:14:25 2025
Received: from localhost ([127.0.0.1]:54233 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u3Yoa-0003VT-P6
	for submit <at> debbugs.gnu.org; Sat, 12 Apr 2025 07:14:25 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:46192)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1u3YoX-0003VF-JS
 for 77656 <at> debbugs.gnu.org; Sat, 12 Apr 2025 07:14:22 -0400
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 <eliz@HIDDEN>)
 id 1u3YoR-0003Gv-Qa; Sat, 12 Apr 2025 07:14:15 -0400
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=1fcJ+KquM0HU98U8WFZP+zuEfMWbG2eBpHhGfb9BveM=; b=CpWhNcTXwN77
 gHLSPnzgG4IfJaAZK12loxnGxHUooA+VIz/s4XokVMm1hkHFxsX0pkDJSPgeJDrHiM0VMit2gtwpa
 tVifJtxWuK8cwQPhC0XC6kJv1GDLHuMCx4kT0HVA8KpgKd/To2aNLWEuqpOj2JehjobhhZ0CojJPQ
 mijnRm1p+eQdRUDa+6Fj2YkIx35DCTr/CT8WCjti9MXxQF/4Bqe+9cxyvQOCYrq0BSFk/d4PFtOWK
 Ueo8+OA2DwO1KHTVJVEfWvsO0fL3c91MI3TGw01TwogxBCGe8XjScyTdzbIqxyUw1TCenUkjnk54i
 /hT8FnYTqoi6G9tSSchEEw==;
Date: Sat, 12 Apr 2025 14:14:12 +0300
Message-Id: <86ikn9my2j.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Spencer Baugh <sbaugh@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>,
 Stefan Kangas <stefankangas@HIDDEN>, Andrea Corallo <acorallo@HIDDEN>
In-Reply-To: <ierplhmqqjf.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#77656: [PATCH] Don't escape "." in `prin1' unless followed by
 "?" or nothing
References: <ierplhmqqjf.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 77656
Cc: larsi@HIDDEN, 77656 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: Lars Ingebrigtsen <larsi@HIDDEN>
> Date: Tue, 08 Apr 2025 17:41:56 -0400
> From:  Spencer Baugh via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> This is a followup to 637dde4aba921435f78d0de769ad74c4f3230aa6, which
> removed some unnecessary escaping of "." and "?" when printing symbols
> in prin1.
> 
> This change removes more unnecessary escaping of "."; "." only
> needs to be escaped when it's the entire symbol or if it's
> followed by a "?".
> 
> (Actually, if we always escaped "?" (which was the case before
> 637dde4aba92) then "." only ever needs to be escaped when
> string_to_number returns non-nil.  So 637dde4aba92 could have
> just dropped the escaping of "." with no other changes, if it
> didn't also remove escaping of "?")

Any objections or comments, anyone?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#77656; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 8 Apr 2025 21:42:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 08 17:42:12 2025
Received: from localhost ([127.0.0.1]:35849 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u2Ghw-0000Gw-BN
	for submit <at> debbugs.gnu.org; Tue, 08 Apr 2025 17:42:12 -0400
Received: from lists.gnu.org ([2001:470:142::17]:34412)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>)
 id 1u2Ght-0000GZ-JP
 for submit <at> debbugs.gnu.org; Tue, 08 Apr 2025 17:42:10 -0400
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 <sbaugh@HIDDEN>)
 id 1u2Ghl-0002ra-SV
 for bug-gnu-emacs@HIDDEN; Tue, 08 Apr 2025 17:42:02 -0400
Received: from mxout5.mail.janestreet.com ([64.215.233.18])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <sbaugh@HIDDEN>)
 id 1u2Ghi-0006P2-O6
 for bug-gnu-emacs@HIDDEN; Tue, 08 Apr 2025 17:42:01 -0400
From: Spencer Baugh <sbaugh@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing
X-Debbugs-Cc: Lars Ingebrigtsen <larsi@HIDDEN>
Date: Tue, 08 Apr 2025 17:41:56 -0400
Message-ID: <ierplhmqqjf.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com;
 s=waixah; t=1744148516;
 bh=g8aTYjVJATjloZ8ggGujheXuzta0+MPiRhAA6PGrLPI=;
 h=From:To:Subject:Date;
 b=en1sCCTQ2lPu2yqS+kglnomTAqBbhfszFXePY/SSaQtipUrA6MkS8/RJuHMawCx4J
 xBnd80rgVGwY6bcf5a9+MGVap2EpHKWmJfZuZSaEtAcEPiY+yT4PWZ5o0h3a4o4HTn
 TGxy+990kujQpPippvjYmJWK9mHvgBf8MCy/4Wq0uqigMgoct1tBzqXwki9ZCb8Dc5
 DXSWbwcUhZDqwmn1i+qqy21+7CQh3RGi9s2vKtdIC4QJx+SnAm9bzVcwD9bz/V+QVM
 1b+nud1Q/YFegdA7VRhqFwLqrW6QqJaWeacMTCyW8HduSa35e2dlGqBkBC2NCgjQQ0
 djpmoh9VwOGmQ==
Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@HIDDEN;
 helo=mxout5.mail.janestreet.com
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=0.001,
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

--=-=-=
Content-Type: text/plain

Tags: patch


This is a followup to 637dde4aba921435f78d0de769ad74c4f3230aa6, which
removed some unnecessary escaping of "." and "?" when printing symbols
in prin1.

This change removes more unnecessary escaping of "."; "." only
needs to be escaped when it's the entire symbol or if it's
followed by a "?".

(Actually, if we always escaped "?" (which was the case before
637dde4aba92) then "." only ever needs to be escaped when
string_to_number returns non-nil.  So 637dde4aba92 could have
just dropped the escaping of "." with no other changes, if it
didn't also remove escaping of "?")

In GNU Emacs 30.1.50 (build 4, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2025-04-08 built on
 igm-qws-u22796a
Repository revision: 66de38ffb76fbd3ecb1cea52e655189b1b173fa1
Repository branch: emacs-30
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.10 (Green Obsidian)

Configured using:
 'configure --config-cache --with-x-toolkit=lucid --without-gpm
 --without-gconf --without-selinux --without-imagemagick --with-modules
 --with-gif=no --with-cairo --with-rsvg --without-compress-install
 --with-tree-sitter --with-native-compilation=aot'


--=-=-=
Content-Type: text/patch
Content-Disposition: attachment;
 filename=0001-Don-t-escape-.-in-prin1-unless-followed-by-or-nothin.patch

From debb205a42505eac022c51886732304d026db8a8 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Tue, 4 Jun 2024 10:35:10 -0400
Subject: [PATCH] Don't escape "." in `prin1' unless followed by "?" or nothing

This is a followup to 637dde4aba921435f78d0de769ad74c4f3230aa6, which
removed some unnecessary escaping of "." and "?" when printing symbols
in prin1.

This change removes more unnecessary escaping of "."; "." only
needs to be escaped when it's the entire symbol or if it's
followed by a "?".

(Actually, if we always escaped "?" (which was the case before
637dde4aba92) then "." only ever needs to be escaped when
string_to_number returns non-nil.  So 637dde4aba92 could have
just dropped the escaping of "." with no other changes, if it
didn't also remove escaping of "?")

* src/print.c (print_object): Only escape "." as the first
character in a symbol if followed by "?" or nothing.
* test/src/print-tests.el (test-dots): Update for new behavior.
---
 src/print.c             | 8 +++++---
 test/src/print-tests.el | 4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/print.c b/src/print.c
index c7cba5bface..c8ab73f6275 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2442,10 +2442,12 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
 	  ((c_isdigit (p[signedp]) || p[signedp] == '.')
 	   && !NILP (string_to_number (p, 10, &len))
 	   && len == size_byte)
-	  /* We don't escape "." or "?" (unless they're the first
-	     character in the symbol name).  */
+	  /* We don't escape "?" unless it's the first character in the
+	     symbol name.  */
 	  || *p == '?'
-	  || *p == '.';
+	  /* We don't escape "." unless it's the entire symbol name, or
+	     followed by a "?". */
+	  || (*p == '.' && (size_byte == 1 || *(p+1) == '?')) ;
 
 	if (! NILP (Vprint_gensym)
 	    && !SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (obj))
diff --git a/test/src/print-tests.el b/test/src/print-tests.el
index 1a04cf73f30..34254963e6d 100644
--- a/test/src/print-tests.el
+++ b/test/src/print-tests.el
@@ -415,8 +415,8 @@ test-unreadable
 
 (ert-deftest test-dots ()
   (should (equal (prin1-to-string 'foo.bar) "foo.bar"))
-  (should (equal (prin1-to-string '.foo) "\\.foo"))
-  (should (equal (prin1-to-string '.foo.) "\\.foo."))
+  (should (equal (prin1-to-string '.foo) ".foo"))
+  (should (equal (prin1-to-string '.foo.) ".foo."))
   (should (equal (prin1-to-string 'bar?bar) "bar?bar"))
   (should (equal (prin1-to-string '\?bar) "\\?bar"))
   (should (equal (prin1-to-string '\?bar?) "\\?bar?")))
-- 
2.39.3


--=-=-=--




Acknowledgement sent to Spencer Baugh <sbaugh@HIDDEN>:
New bug report received and forwarded. Copy sent to larsi@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to larsi@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#77656; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 12 Apr 2025 11:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.