From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#30217: Ambiguity in NEWS in emacs-26.0.91 Date: Tue, 23 Jan 2018 19:02:13 -0500 Message-ID: <87vafsm8e2.fsf@users.sourceforge.net> References: <20180122221743.GB4888@ACM> <5074511f-b3b3-45aa-80b4-130be08f30ec@default> <87efmho17g.fsf@users.sourceforge.net> <4c079376-7659-4962-aa73-39a4b4ed76e0@default> <878tcpnyio.fsf@users.sourceforge.net> <132fe701-a996-4708-bf39-4ee95230b8fa@default> <871sigohv9.fsf@users.sourceforge.net> <1a1fbaea-f291-414d-aaef-bf41ea4a5873@default> <87y3komb9o.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1516752365 25599 195.159.176.226 (24 Jan 2018 00:06:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 24 Jan 2018 00:06:05 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cc: Alan Mackenzie , 30217@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 24 01:06:01 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ee8ZT-0005Kr-IB for geb-bug-gnu-emacs@m.gmane.org; Wed, 24 Jan 2018 01:05:43 +0100 Original-Received: from localhost ([::1]:35158 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ee8bT-0003GW-S2 for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Jan 2018 19:07:47 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ee8YB-0002MM-Rv for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 19:07:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ee8Wu-0003Nt-D8 for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 19:04:23 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60475) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ee8Wt-0003Ls-RN for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 19:03:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ee8Wr-0004yY-Kq for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 19:03:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Jan 2018 00:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30217-submit@debbugs.gnu.org id=B30217.151675214519076 (code B ref 30217); Wed, 24 Jan 2018 00:03:01 +0000 Original-Received: (at 30217) by debbugs.gnu.org; 24 Jan 2018 00:02:25 +0000 Original-Received: from localhost ([127.0.0.1]:40139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ee8WG-0004xc-Dy for submit@debbugs.gnu.org; Tue, 23 Jan 2018 19:02:24 -0500 Original-Received: from mail-io0-f180.google.com ([209.85.223.180]:41289) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ee8WE-0004xP-NE for 30217@debbugs.gnu.org; Tue, 23 Jan 2018 19:02:23 -0500 Original-Received: by mail-io0-f180.google.com with SMTP id f4so2882002ioh.8 for <30217@debbugs.gnu.org>; Tue, 23 Jan 2018 16:02:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=zFqTjNeKvY4KAJaZinOVKKxnckzdw2GMIQc93pG+c1g=; b=Jmut+J5Oo6ogGO8ZftC39+0n/M6xgYoJiAZVr8MzX+X4Ehw4LNCWVfnyHm5a4EDvYe LxezIGWC2VrfoIAumtukr6o7RjPNbGOgoBXTlJKkkN1ECrx5fMPWW8mnat6GOXBopxdl em7MBfVsz2/NzhhyEY0Xj+Uue3fdxdEGY/3oN7/1zAbvSHOdGTg4kUm8F7bZhCcxC7HA uJbqy5vSymcT7CdlNB5/++2+1l543vfRD0+hLI/PJSHHbaCndg77ompZt426GH10Rz25 ODoDRONkkuDrjLfXgUlXADuA4ORoMNS3yiKbgwVT5frv+uCP23/tsXueDp9OrmXhsLvZ TN1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=zFqTjNeKvY4KAJaZinOVKKxnckzdw2GMIQc93pG+c1g=; b=CERFMZ+Z79ovLb8W6XqNrirrl2s1iih5DnkWoEfItTY8T/Tj8C8y+FjEiaEIzQEny7 3gwT06jAtpsuXI0C8vn7kmaq+PclDI8qgDFv0D9/LHikBRZzEC6lrRoqSKOqX5pDxffz BhyZBnQTpkapTOxbbVb12DDkPTfO0u3Uxw/6044VFc7YLQysFQobFmHecw8pzKFKdUYZ LGyFfOYDzVc+MHeYbK2HzNcKRwb1bvYkvyY6BN501jow6+Ry8lQYd1FlqNUJsRLMBob5 6zm/WybvFIEGj8XtSEAYTR2UVZHSgdLUgVv5Oz+NXpxeVYu5YOyUc9XPoDVt4Mz8GYYk PD0Q== X-Gm-Message-State: AKwxytd4r3vSnc4cdzXeFlEj3ei9gm4ZUJvCyWn6XDCDMCKLqDLKZB5q pWS1BTtDajow2KM+39w+BlrxCA== X-Google-Smtp-Source: AH8x226iL92fbjvDSS0en+6duFshfLDCrmFLoZJxPUgSj06eh3PVWSB7YDV4nYP0qCpz+wFh6M0fZQ== X-Received: by 10.107.37.19 with SMTP id l19mr6662936iol.193.1516752136963; Tue, 23 Jan 2018 16:02:16 -0800 (PST) Original-Received: from zebian ([45.2.119.34]) by smtp.googlemail.com with ESMTPSA id s70sm18933itb.0.2018.01.23.16.02.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jan 2018 16:02:15 -0800 (PST) In-Reply-To: (Drew Adams's message of "Tue, 23 Jan 2018 15:19:07 -0800 (PST)") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:142457 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Drew Adams writes: > Of course something about escaping has changed. > \=E2=80=99bar is now read differently from =E2=80=99bar. Oh, I see. I was considering that since the meaning of \=E2=80=99bar hasn't changed, then escaping hasn't changed (though non-escaped syntax has). Anyway, thinking about this made realize I broke read->print round-tripping for these symbols, because I didn't change print to add the backslash. Attached is a patch which does this, but I'm not sure if it can go into emacs-26. If not, then I think we should at least delay introduction of the reader change to Emacs 27. --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename=0001-Fix-round-tripping-of-read-print-for-symbols-with-st.patch Content-Transfer-Encoding: quoted-printable Content-Description: patch >From c661d622d7109dcddd957524c4dd4457b41c1561 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 23 Jan 2018 18:50:23 -0500 Subject: [PATCH] Fix round tripping of read->print for symbols with strange quotes Since 2017-07-22 "Signal error for symbol names with strange quotes (Bug#2967)", symbol names beginning with certain quote characters require an escaping backslash. However, the corresponding change for printing missed, so that (eq (read (prin1-to-string SYM)) SYM) does not give `t' for such symbols. * src/character.c (confusable_symbol_character_p): New function, extracted from test `read1'. * src/lread.c (read1): Use it. * src/print.c (print_object): Use it to print a backslash for symbols starting with characters that `read1' requires to be escaped. * test/src/print-tests.el (print-read-roundtrip): New test. * etc/NEWS: Clarify the announcement for the earlier reader change (Bug#30217). --- etc/NEWS | 12 +++++++++--- src/character.c | 26 ++++++++++++++++++++++++++ src/character.h | 2 ++ src/lread.c | 17 +++-------------- src/print.c | 3 ++- test/src/print-tests.el | 4 ++++ 6 files changed, 46 insertions(+), 18 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index f5859d7a60..c760738105 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1385,9 +1385,15 @@ renamed to 'lread--old-style-backquotes'. No user c= ode should use this variable. =20 --- -** To avoid confusion caused by "smart quotes", the reader no longer -accepts Lisp symbols which begin with the following quotation -characters: =E2=80=98=E2=80=99=E2=80=9B=E2=80=9C=E2=80=9D=E2=80=9F=E3=80= =9E=EF=BC=82=EF=BC=87, unless they are escaped with backslash. +** To avoid confusion caused by "smart quotes", the reader signals an +error when reading Lisp symbols which begin with one of the following +quotation characters: =E2=80=98=E2=80=99=E2=80=9B=E2=80=9C=E2=80=9D=E2=80= =9F=E3=80=9E=EF=BC=82=EF=BC=87. A symbol beginning with such a +character can be written by escaping the quotation character with a +backslash. For example: + + (read "=E2=80=98smart") =3D> (invalid-read-syntax "strange quote" "=E2= =80=98") + (read "\\=E2=80=98smart") =3D=3D (intern "=E2=80=98smart") + =20 +++ ** 'default-file-name-coding-system' now defaults to a coding system diff --git a/src/character.c b/src/character.c index fa817a5031..4a934c7801 100644 --- a/src/character.c +++ b/src/character.c @@ -1050,6 +1050,32 @@ blankp (int c) return XINT (category) =3D=3D UNICODE_CATEGORY_Zs; /* separator, space */ } =20 + +/* Return true for characters that would read as symbol characters, + but graphically may be confused with some kind of punctuation. We + require an escaping backslash, when such characters begin a + symbol. */ +bool +confusable_symbol_character_p (int ch) +{ + switch (ch) + { + case 0x2018: /* LEFT SINGLE QUOTATION MARK */ + case 0x2019: /* RIGHT SINGLE QUOTATION MARK */ + case 0x201B: /* SINGLE HIGH-REVERSED-9 QUOTATION MARK */ + case 0x201C: /* LEFT DOUBLE QUOTATION MARK */ + case 0x201D: /* RIGHT DOUBLE QUOTATION MARK */ + case 0x201F: /* DOUBLE HIGH-REVERSED-9 QUOTATION MARK */ + case 0x301E: /* DOUBLE PRIME QUOTATION MARK */ + case 0xFF02: /* FULLWIDTH QUOTATION MARK */ + case 0xFF07: /* FULLWIDTH APOSTROPHE */ + return true; + + default: + return false; + } +} + signed char HEXDIGIT_CONST hexdigit[UCHAR_MAX + 1] =3D { #if HEXDIGIT_IS_CONST diff --git a/src/character.h b/src/character.h index c716885d46..d9e2d7bfc6 100644 --- a/src/character.h +++ b/src/character.h @@ -682,6 +682,8 @@ char_surrogate_p (int c) extern bool printablep (int); extern bool blankp (int); =20 +extern bool confusable_symbol_character_p (int ch); + /* Return a translation table of id number ID. */ #define GET_TRANSLATION_TABLE(id) \ (XCDR (XVECTOR (Vtranslation_table_vector)->contents[(id)])) diff --git a/src/lread.c b/src/lread.c index 45d60647be..82731781f0 100644 --- a/src/lread.c +++ b/src/lread.c @@ -3482,20 +3482,9 @@ read1 (Lisp_Object readcharfun, int *pch, bool first= _in_list) if (!quoted && multibyte) { int ch =3D STRING_CHAR ((unsigned char *) read_buffer); - switch (ch) - { - case 0x2018: /* LEFT SINGLE QUOTATION MARK */ - case 0x2019: /* RIGHT SINGLE QUOTATION MARK */ - case 0x201B: /* SINGLE HIGH-REVERSED-9 QUOTATION MARK */ - case 0x201C: /* LEFT DOUBLE QUOTATION MARK */ - case 0x201D: /* RIGHT DOUBLE QUOTATION MARK */ - case 0x201F: /* DOUBLE HIGH-REVERSED-9 QUOTATION MARK */ - case 0x301E: /* DOUBLE PRIME QUOTATION MARK */ - case 0xFF02: /* FULLWIDTH QUOTATION MARK */ - case 0xFF07: /* FULLWIDTH APOSTROPHE */ - xsignal2 (Qinvalid_read_syntax, build_string ("strange quo= te"), - CALLN (Fstring, make_number (ch))); - } + if (confusable_symbol_character_p (ch)) + xsignal2 (Qinvalid_read_syntax, build_string ("strange quote= "), + CALLN (Fstring, make_number (ch))); } { Lisp_Object result; diff --git a/src/print.c b/src/print.c index 47cb33deeb..b0741531f7 100644 --- a/src/print.c +++ b/src/print.c @@ -1971,7 +1971,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharf= un, bool escapeflag) || c =3D=3D ';' || c =3D=3D '#' || c =3D=3D '(' || c =3D=3D ')' || c =3D=3D ',' || c =3D=3D '.' || c =3D=3D '`' || c =3D=3D '[' || c =3D=3D ']' || c =3D=3D '?' || c <=3D 040 - || confusing) + || confusing + || (i =3D=3D 1 && confusable_symbol_character_p (c))) { printchar ('\\', printcharfun); confusing =3D false; diff --git a/test/src/print-tests.el b/test/src/print-tests.el index 46368c69ad..01e65028bc 100644 --- a/test/src/print-tests.el +++ b/test/src/print-tests.el @@ -58,5 +58,9 @@ (buffer-string)) "--------\n")))) =20 +(ert-deftest print-read-roundtrip () + (let ((sym '\=E2=80=99bar)) + (should (eq (read (prin1-to-string sym)) sym)))) + (provide 'print-tests) ;;; print-tests.el ends here --=20 2.11.0 --=-=-=--