summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-07-08 08:09:48 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-07-08 08:09:48 -0700
commit92d6dc44e8aff8421161baf4765844dc43c06c45 (patch)
treed05f3bc35c6138ded07db4d3854126d0b573cf03
parent467ddd7b2b69fb87bb550cf30f9fa34af44f9927 (diff)
downloadtxr-92d6dc44e8aff8421161baf4765844dc43c06c45.tar.gz
txr-92d6dc44e8aff8421161baf4765844dc43c06c45.tar.bz2
txr-92d6dc44e8aff8421161baf4765844dc43c06c45.zip
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.
-rw-r--r--lib.c16
1 files changed, 12 insertions, 4 deletions
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;