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.
This commit is contained in:
parent
98f8c5fb07
commit
85f586f3ce
6 changed files with 1 additions and 63 deletions
9
etc/NEWS
9
etc/NEWS
|
@ -2972,15 +2972,6 @@ and if the new behavior breaks your code please email
|
|||
<32252@debbugs.gnu.org>. Because '%o' and '%x' can now format signed
|
||||
integers, they now support the '+' and space flags.
|
||||
|
||||
** 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: ‘’‛“”‟〞"'. A symbol beginning with such a
|
||||
character can be written by escaping the quotation character with a
|
||||
backslash. For example:
|
||||
|
||||
(read "‘smart") => (invalid-read-syntax "strange quote" "‘")
|
||||
(read "\\‘smart") == (intern "‘smart")
|
||||
|
||||
+++
|
||||
** Omitting variables after '&optional' and '&rest' is now allowed.
|
||||
For example '(defun foo (&optional))' is no longer an error. This is
|
||||
|
|
|
@ -1056,32 +1056,6 @@ blankp (int c)
|
|||
return XFIXNUM (category) == UNICODE_CATEGORY_Zs; /* separator, space */
|
||||
}
|
||||
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/* hexdigit[C] is one greater than C's numeric value if C is a
|
||||
hexadecimal digit, zero otherwise. */
|
||||
signed char const hexdigit[UCHAR_MAX + 1] =
|
||||
|
|
|
@ -684,8 +684,6 @@ extern bool graphicp (int);
|
|||
extern bool printablep (int);
|
||||
extern bool blankp (int);
|
||||
|
||||
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)]))
|
||||
|
|
|
@ -3571,13 +3571,6 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
|
|||
if (! NILP (result) && len == nbytes)
|
||||
return unbind_to (count, result);
|
||||
}
|
||||
if (!quoted && multibyte)
|
||||
{
|
||||
int ch = STRING_CHAR ((unsigned char *) read_buffer);
|
||||
if (confusable_symbol_character_p (ch))
|
||||
xsignal2 (Qinvalid_read_syntax, build_string ("strange quote"),
|
||||
CALLN (Fstring, make_fixnum (ch)));
|
||||
}
|
||||
{
|
||||
Lisp_Object result;
|
||||
ptrdiff_t nchars
|
||||
|
|
|
@ -2035,8 +2035,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
|
|||
|| c == ',' || c == '.' || c == '`'
|
||||
|| c == '[' || c == ']' || c == '?' || c <= 040
|
||||
|| c == NO_BREAK_SPACE
|
||||
|| confusing
|
||||
|| (i == 1 && confusable_symbol_character_p (c)))
|
||||
|| confusing)
|
||||
{
|
||||
printchar ('\\', printcharfun);
|
||||
confusing = false;
|
||||
|
|
|
@ -144,23 +144,6 @@ literals (Bug#20852)."
|
|||
"`?\\\"', `?\\(', `?\\)', `?\\;', `?\\[', `?\\]' "
|
||||
"expected!")))))
|
||||
|
||||
(ert-deftest lread-tests--funny-quote-symbols ()
|
||||
"Check that `smart quotes' or similar trigger errors in symbol names."
|
||||
(dolist (quote-char
|
||||
'(#x2018 ;; LEFT SINGLE QUOTATION MARK
|
||||
#x2019 ;; RIGHT SINGLE QUOTATION MARK
|
||||
#x201B ;; SINGLE HIGH-REVERSED-9 QUOTATION MARK
|
||||
#x201C ;; LEFT DOUBLE QUOTATION MARK
|
||||
#x201D ;; RIGHT DOUBLE QUOTATION MARK
|
||||
#x201F ;; DOUBLE HIGH-REVERSED-9 QUOTATION MARK
|
||||
#x301E ;; DOUBLE PRIME QUOTATION MARK
|
||||
#xFF02 ;; FULLWIDTH QUOTATION MARK
|
||||
#xFF07 ;; FULLWIDTH APOSTROPHE
|
||||
))
|
||||
(let ((str (format "%cfoo" quote-char)))
|
||||
(should-error (read str) :type 'invalid-read-syntax)
|
||||
(should (eq (read (concat "\\" str)) (intern str))))))
|
||||
|
||||
(ert-deftest lread-test-bug26837 ()
|
||||
"Test for https://debbugs.gnu.org/26837 ."
|
||||
(let ((load-path (cons
|
||||
|
|
Loading…
Add table
Reference in a new issue