diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-07-08 08:09:48 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-07-08 08:09:48 -0700 |
commit | 107242691ea0317095bcb42378128de0eb4bbe57 (patch) | |
tree | d05f3bc35c6138ded07db4d3854126d0b573cf03 /lib.c | |
parent | d60eeab9d2eda8c05ecb27961306468608eb4006 (diff) | |
download | txr-107242691ea0317095bcb42378128de0eb4bbe57.tar.gz txr-107242691ea0317095bcb42378128de0eb4bbe57.tar.bz2 txr-107242691ea0317095bcb42378128de0eb4bbe57.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.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -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; |