aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoam Postavsky2018-03-10 18:20:45 -0500
committerNoam Postavsky2019-11-28 18:03:42 -0500
commit85f586f3ce5c6d9598d345440fd57e0fc9b8d98b (patch)
tree10723ac9f3d20dc4a4bb045b1e58c02234a9c9e5
parent98f8c5fb07dcb4e20b8ba6648bdabf5c0d3b5145 (diff)
downloademacs-85f586f3ce5c6d9598d345440fd57e0fc9b8d98b.tar.gz
emacs-85f586f3ce5c6d9598d345440fd57e0fc9b8d98b.zip
Stop signaling an error when reading "smart quotes" in symbols
Revert commits from 2018-01-28 "Fix round tripping of read->print for symbols with strange quotes", and 2017-07-22 "Signal error for symbol names with strange quotes (Bug#2967)". * etc/NEWS: Remove corresponding entries. * src/character.c (confusable_symbol_character_p): * test/src/lread-tests.el (lread-tests--old-style-backquotes): Remove. * src/lread.c (read1): Don't signal error on confusable character. * src/print.c (print_object): Don't escape confusable characters.
-rw-r--r--etc/NEWS9
-rw-r--r--src/character.c26
-rw-r--r--src/character.h2
-rw-r--r--src/lread.c7
-rw-r--r--src/print.c3
-rw-r--r--test/src/lread-tests.el17
6 files changed, 1 insertions, 63 deletions
diff --git a/etc/NEWS b/etc/NEWS
index cb73e46358a..3a2efcfc2e0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2972,15 +2972,6 @@ and if the new behavior breaks your code please email
2972<32252@debbugs.gnu.org>. Because '%o' and '%x' can now format signed 2972<32252@debbugs.gnu.org>. Because '%o' and '%x' can now format signed
2973integers, they now support the '+' and space flags. 2973integers, they now support the '+' and space flags.
2974 2974
2975** To avoid confusion caused by "smart quotes", the reader signals an
2976error when reading Lisp symbols which begin with one of the following
2977quotation characters: ‘’‛“”‟〞"'. A symbol beginning with such a
2978character can be written by escaping the quotation character with a
2979backslash. For example:
2980
2981 (read "‘smart") => (invalid-read-syntax "strange quote" "‘")
2982 (read "\\‘smart") == (intern "‘smart")
2983
2984+++ 2975+++
2985** Omitting variables after '&optional' and '&rest' is now allowed. 2976** Omitting variables after '&optional' and '&rest' is now allowed.
2986For example '(defun foo (&optional))' is no longer an error. This is 2977For example '(defun foo (&optional))' is no longer an error. This is
diff --git a/src/character.c b/src/character.c
index 708eb2f7024..55ad49005a0 100644
--- a/src/character.c
+++ b/src/character.c
@@ -1056,32 +1056,6 @@ blankp (int c)
1056 return XFIXNUM (category) == UNICODE_CATEGORY_Zs; /* separator, space */ 1056 return XFIXNUM (category) == UNICODE_CATEGORY_Zs; /* separator, space */
1057} 1057}
1058 1058
1059
1060/* Return true for characters that would read as symbol characters,
1061 but graphically may be confused with some kind of punctuation. We
1062 require an escaping backslash, when such characters begin a
1063 symbol. */
1064bool
1065confusable_symbol_character_p (int ch)
1066{
1067 switch (ch)
1068 {
1069 case 0x2018: /* LEFT SINGLE QUOTATION MARK */
1070 case 0x2019: /* RIGHT SINGLE QUOTATION MARK */
1071 case 0x201B: /* SINGLE HIGH-REVERSED-9 QUOTATION MARK */
1072 case 0x201C: /* LEFT DOUBLE QUOTATION MARK */
1073 case 0x201D: /* RIGHT DOUBLE QUOTATION MARK */
1074 case 0x201F: /* DOUBLE HIGH-REVERSED-9 QUOTATION MARK */
1075 case 0x301E: /* DOUBLE PRIME QUOTATION MARK */
1076 case 0xFF02: /* FULLWIDTH QUOTATION MARK */
1077 case 0xFF07: /* FULLWIDTH APOSTROPHE */
1078 return true;
1079
1080 default:
1081 return false;
1082 }
1083}
1084
1085/* hexdigit[C] is one greater than C's numeric value if C is a 1059/* hexdigit[C] is one greater than C's numeric value if C is a
1086 hexadecimal digit, zero otherwise. */ 1060 hexadecimal digit, zero otherwise. */
1087signed char const hexdigit[UCHAR_MAX + 1] = 1061signed char const hexdigit[UCHAR_MAX + 1] =
diff --git a/src/character.h b/src/character.h
index 230fc6eab59..3642a540448 100644
--- a/src/character.h
+++ b/src/character.h
@@ -684,8 +684,6 @@ extern bool graphicp (int);
684extern bool printablep (int); 684extern bool printablep (int);
685extern bool blankp (int); 685extern bool blankp (int);
686 686
687extern bool confusable_symbol_character_p (int ch);
688
689/* Return a translation table of id number ID. */ 687/* Return a translation table of id number ID. */
690#define GET_TRANSLATION_TABLE(id) \ 688#define GET_TRANSLATION_TABLE(id) \
691 (XCDR (XVECTOR (Vtranslation_table_vector)->contents[(id)])) 689 (XCDR (XVECTOR (Vtranslation_table_vector)->contents[(id)]))
diff --git a/src/lread.c b/src/lread.c
index 4ea62029727..e5a9c93c55e 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3571,13 +3571,6 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
3571 if (! NILP (result) && len == nbytes) 3571 if (! NILP (result) && len == nbytes)
3572 return unbind_to (count, result); 3572 return unbind_to (count, result);
3573 } 3573 }
3574 if (!quoted && multibyte)
3575 {
3576 int ch = STRING_CHAR ((unsigned char *) read_buffer);
3577 if (confusable_symbol_character_p (ch))
3578 xsignal2 (Qinvalid_read_syntax, build_string ("strange quote"),
3579 CALLN (Fstring, make_fixnum (ch)));
3580 }
3581 { 3574 {
3582 Lisp_Object result; 3575 Lisp_Object result;
3583 ptrdiff_t nchars 3576 ptrdiff_t nchars
diff --git a/src/print.c b/src/print.c
index a2c199c14ad..7105c5dbb92 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2035,8 +2035,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2035 || c == ',' || c == '.' || c == '`' 2035 || c == ',' || c == '.' || c == '`'
2036 || c == '[' || c == ']' || c == '?' || c <= 040 2036 || c == '[' || c == ']' || c == '?' || c <= 040
2037 || c == NO_BREAK_SPACE 2037 || c == NO_BREAK_SPACE
2038 || confusing 2038 || confusing)
2039 || (i == 1 && confusable_symbol_character_p (c)))
2040 { 2039 {
2041 printchar ('\\', printcharfun); 2040 printchar ('\\', printcharfun);
2042 confusing = false; 2041 confusing = false;
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el
index 3a2212ef770..0c14a1afdaa 100644
--- a/test/src/lread-tests.el
+++ b/test/src/lread-tests.el
@@ -144,23 +144,6 @@ literals (Bug#20852)."
144 "`?\\\"', `?\\(', `?\\)', `?\\;', `?\\[', `?\\]' " 144 "`?\\\"', `?\\(', `?\\)', `?\\;', `?\\[', `?\\]' "
145 "expected!"))))) 145 "expected!")))))
146 146
147(ert-deftest lread-tests--funny-quote-symbols ()
148 "Check that `smart quotes' or similar trigger errors in symbol names."
149 (dolist (quote-char
150 '(#x2018 ;; LEFT SINGLE QUOTATION MARK
151 #x2019 ;; RIGHT SINGLE QUOTATION MARK
152 #x201B ;; SINGLE HIGH-REVERSED-9 QUOTATION MARK
153 #x201C ;; LEFT DOUBLE QUOTATION MARK
154 #x201D ;; RIGHT DOUBLE QUOTATION MARK
155 #x201F ;; DOUBLE HIGH-REVERSED-9 QUOTATION MARK
156 #x301E ;; DOUBLE PRIME QUOTATION MARK
157 #xFF02 ;; FULLWIDTH QUOTATION MARK
158 #xFF07 ;; FULLWIDTH APOSTROPHE
159 ))
160 (let ((str (format "%cfoo" quote-char)))
161 (should-error (read str) :type 'invalid-read-syntax)
162 (should (eq (read (concat "\\" str)) (intern str))))))
163
164(ert-deftest lread-test-bug26837 () 147(ert-deftest lread-test-bug26837 ()
165 "Test for https://debbugs.gnu.org/26837 ." 148 "Test for https://debbugs.gnu.org/26837 ."
166 (let ((load-path (cons 149 (let ((load-path (cons