summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-12-18 22:31:30 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-12-18 22:31:30 -0800
commitb81a5285f8b9b583c6933e7aa576f3ef0a3a8e82 (patch)
tree368b00af32d36f31702c19f123014cc4fcb75016 /lib.c
parenta188de0260fbe4f4c940963d0acc7210de4017c3 (diff)
downloadtxr-b81a5285f8b9b583c6933e7aa576f3ef0a3a8e82.tar.gz
txr-b81a5285f8b9b583c6933e7aa576f3ef0a3a8e82.tar.bz2
txr-b81a5285f8b9b583c6933e7aa576f3ef0a3a8e82.zip
Print some instances of qref as dot notation.
We must preserve ambiguity-free read-print consistency. * lib.c (simple_qref_args_p): New static function. (obj_print_impl): Check for qref and print as dot notation if its argument list satisfies simple_qref_args_p.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 7b5df796..05ccb45a 100644
--- a/lib.c
+++ b/lib.c
@@ -8124,6 +8124,21 @@ static void obj_init(void)
prog_string = string(progname);
}
+static val simple_qref_args_p(val args, val pos)
+{
+ if (nilp(args)) {
+ return if2(ge(pos, two), t);
+ } else if (!consp(args)) {
+ return nil;
+ } else {
+ val arg = car(args);
+ if (symbolp(arg) || (consp(arg) && car(arg) != qref_s)) {
+ return simple_qref_args_p(cdr(args), succ(pos));
+ }
+ return nil;
+ }
+}
+
val obj_print_impl(val obj, val out, val pretty)
{
val ret = obj;
@@ -8174,6 +8189,15 @@ val obj_print_impl(val obj, val out, val pretty)
obj_print_impl(second(obj), out, pretty);
put_string(lit(".."), out);
obj_print_impl(third(obj), out, pretty);
+ } else if (sym == qref_s && simple_qref_args_p(cdr(obj), zero)) {
+ val iter, next;
+ for (iter = cdr(obj); iter; iter = next) {
+ next = cdr(iter);
+ obj_print_impl(car(iter), out, pretty);
+ if (next)
+ put_string(lit("."), out);
+ iter = next;
+ }
} else {
val iter;
val closepar = chr(')');