aboutsummaryrefslogtreecommitdiffstats
path: root/src/character.c
diff options
context:
space:
mode:
authorNoam Postavsky2018-01-23 18:50:23 -0500
committerNoam Postavsky2018-01-28 10:43:01 -0500
commit36c8128e740ce91af10769bef46a21a72dafc56c (patch)
tree19a2dd3106c0e65b2e12cb4f7e542f6d9e9d2aa1 /src/character.c
parent69a30e8b87fac5888daa26c63663351570e3d533 (diff)
downloademacs-36c8128e740ce91af10769bef46a21a72dafc56c.tar.gz
emacs-36c8128e740ce91af10769bef46a21a72dafc56c.zip
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.26: * etc/NEWS: Clarify the announcement for the earlier reader change (Bug#30217).
Diffstat (limited to 'src/character.c')
-rw-r--r--src/character.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/character.c b/src/character.c
index fa817a50317..4a934c7801c 100644
--- a/src/character.c
+++ b/src/character.c
@@ -1050,6 +1050,32 @@ blankp (int c)
1050 return XINT (category) == UNICODE_CATEGORY_Zs; /* separator, space */ 1050 return XINT (category) == UNICODE_CATEGORY_Zs; /* separator, space */
1051} 1051}
1052 1052
1053
1054/* Return true for characters that would read as symbol characters,
1055 but graphically may be confused with some kind of punctuation. We
1056 require an escaping backslash, when such characters begin a
1057 symbol. */
1058bool
1059confusable_symbol_character_p (int ch)
1060{
1061 switch (ch)
1062 {
1063 case 0x2018: /* LEFT SINGLE QUOTATION MARK */
1064 case 0x2019: /* RIGHT SINGLE QUOTATION MARK */
1065 case 0x201B: /* SINGLE HIGH-REVERSED-9 QUOTATION MARK */
1066 case 0x201C: /* LEFT DOUBLE QUOTATION MARK */
1067 case 0x201D: /* RIGHT DOUBLE QUOTATION MARK */
1068 case 0x201F: /* DOUBLE HIGH-REVERSED-9 QUOTATION MARK */
1069 case 0x301E: /* DOUBLE PRIME QUOTATION MARK */
1070 case 0xFF02: /* FULLWIDTH QUOTATION MARK */
1071 case 0xFF07: /* FULLWIDTH APOSTROPHE */
1072 return true;
1073
1074 default:
1075 return false;
1076 }
1077}
1078
1053signed char HEXDIGIT_CONST hexdigit[UCHAR_MAX + 1] = 1079signed char HEXDIGIT_CONST hexdigit[UCHAR_MAX + 1] =
1054 { 1080 {
1055#if HEXDIGIT_IS_CONST 1081#if HEXDIGIT_IS_CONST