From 107242691ea0317095bcb42378128de0eb4bbe57 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 8 Jul 2020 08:09:48 -0700 Subject: uref/qref: read-print consistency issue. The printer for uref/qref doesn't check for symbols that contain digits in the name, and so for instance (qref a3 3a) comes out as a3.3a, which does not read back, due to looking like a cramped floating-point constant. It looks like the weakest rule we can make is that all symbols that can be preceded by a dot must not have a name starting with a digit. Thus (qref 3a b c) can render as 3a.b.c. But (qref a 3b c) must not render as a.3b.c; it must be (qref a 3b c). * lib.c (simple_qref_args_p): Enact the above rule. In all positions preceded by a dot, if the symbol starts with a digit, then return nil to indicate that the syntax must be rendered in the list form. --- lib.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index b9e510f3..28c29285 100644 --- a/lib.c +++ b/lib.c @@ -12042,10 +12042,18 @@ static val simple_qref_args_p(val args, val pos) return nil; } else { val arg = car(args); - if (symbolp(arg) || (consp(arg) && - car(arg) != qref_s && - car(arg) != uref_s)) - { + + if (symbolp(arg)) { + val name = symbol_name(arg); + if (length(name) == zero) + return nil; + if (!zerop(pos) && chr_isdigit(chr_str(name, zero))) + { + return nil; + } + return simple_qref_args_p(cdr(args), succ(pos)); + } + if (consp(arg) && car(arg) != qref_s && car(arg) != uref_s) { return simple_qref_args_p(cdr(args), succ(pos)); } return nil; -- cgit v1.2.3