[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
pkg 0976c09890 37/76: Fix printing of confusing symbol names
From: |
Gerd Moellmann |
Subject: |
pkg 0976c09890 37/76: Fix printing of confusing symbol names |
Date: |
Fri, 21 Oct 2022 00:16:12 -0400 (EDT) |
branch: pkg
commit 0976c09890eae7056514b38a370ec26d83cbff0a
Author: Gerd Möllmann <gerd@gnu.org>
Commit: Gerd Möllmann <gerd@gnu.org>
Fix printing of confusing symbol names
---
src/print.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/print.c b/src/print.c
index 8f1f33c4d5..69b82659b3 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2168,7 +2168,7 @@ must_escape_p (int c, int ichar)
{
if (c == '\"' || c == '\\' || c == '\''
|| (ichar == 0
- && (c == '+' || c == '-' || c == '.' || c == '?'))
+ && (c == '+' || c == '-' || c == '?' || c == '.'))
|| c == ';' || c == '#' || c == '(' || c == ')'
|| c == ',' || c == '`' || c == '|'
|| c == '[' || c == ']' || c <= 040
@@ -2177,17 +2177,31 @@ must_escape_p (int c, int ichar)
return false;
}
+/* Return true if NAME looks like a number. */
+
+static bool
+looks_like_number_p (Lisp_Object name)
+{
+ const char *p = (const char *) SDATA (name);
+ const bool signedp = *p == '-' || *p == '+';
+ ptrdiff_t len;
+ return ((c_isdigit (p[signedp]) || p[signedp] == '.')
+ && !NILP (string_to_number (p, 10, &len))
+ && len == SBYTES (name));
+}
+
/* Print string NAME like a symbol name. */
static void
print_symbol_name (Lisp_Object name, Lisp_Object printcharfun,
bool escape)
{
+ const bool like_number_p = looks_like_number_p (name);
for (ptrdiff_t ibyte = 0, ichar = 0; ibyte < SBYTES (name);)
{
const int c = fetch_string_char_advance (name, &ichar, &ibyte);
maybe_quit ();
- if (escape && must_escape_p (c, ichar))
+ if (escape && (like_number_p || must_escape_p (c, ichar)))
printchar ('\\', printcharfun);
printchar (c, printcharfun);
}
- pkg a19917468c 04/76: Don't fix symbols here, (continued)
- pkg a19917468c 04/76: Don't fix symbols here, Gerd Moellmann, 2022/10/21
- pkg 072e89afa1 23/76: Use make-package instead of make-vector, Gerd Moellmann, 2022/10/21
- pkg f6b80ef5a5 25/76: Blabla, Gerd Moellmann, 2022/10/21
- pkg 2ed1ac6639 09/76: Fixing stuff, Gerd Moellmann, 2022/10/21
- pkg 1d02e7a48b 02/76: Add xprint command, Gerd Moellmann, 2022/10/21
- pkg a3f99fde48 22/76: Remove Lisp_Symbol::next pointer, Gerd Moellmann, 2022/10/21
- pkg 2518bc249c 39/76: Fix printing symbols, Gerd Moellmann, 2022/10/21
- pkg bbb2609103 40/76: Recognize vectors as obarrays, Gerd Moellmann, 2022/10/21
- pkg 76d59f8a03 60/76: Fix missing ')', Gerd Moellmann, 2022/10/21
- pkg 73b617eaa9 64/76: Change package symbol table layout, Gerd Moellmann, 2022/10/21
- pkg 0976c09890 37/76: Fix printing of confusing symbol names,
Gerd Moellmann <=
- pkg aaf12c12b6 32/76: Some scribbling, Gerd Moellmann, 2022/10/21
- pkg 963de7cafe 35/76: More scribbling, Gerd Moellmann, 2022/10/21
- pkg 90c070fec6 59/76: Restore obarray.el to return vectors, Gerd Moellmann, 2022/10/21
- pkg 74da61ff09 74/76: Remove a call to pkg_break, Gerd Moellmann, 2022/10/21
- pkg cc6095482b 73/76: Add pkg_set_status and Lisp defun for it, Gerd Moellmann, 2022/10/21
- pkg 7acb6c5ca1 68/76: Intrdduce pkg_find_symbol, Gerd Moellmann, 2022/10/21
- pkg 55cef2c78c 69/76: Some cleanup in pkg.c and lisp.h, Gerd Moellmann, 2022/10/21
- pkg df1e4c1e51 34/76: Allow intern with ":xyz" again, Gerd Moellmann, 2022/10/21
- pkg 513f5a0b90 21/76: Remove obarrays, Gerd Moellmann, 2022/10/21
- pkg 051a17f540 63/76: Fix some warnings, Gerd Moellmann, 2022/10/21