summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-11-22 06:47:32 -0800
committerKaz Kylheku <kaz@kylheku.com>2017-11-22 06:47:32 -0800
commit66b7424d8d57bcfb5b5f2b2cfae5fc1462278ef7 (patch)
treee99102571a51f6c9f266259cac7fa33b1226370a
parentf0e54fa9f5a78b01325c508c8341eddbc5b3e6c2 (diff)
downloadtxr-66b7424d8d57bcfb5b5f2b2cfae5fc1462278ef7.tar.gz
txr-66b7424d8d57bcfb5b5f2b2cfae5fc1462278ef7.tar.bz2
txr-66b7424d8d57bcfb5b5f2b2cfae5fc1462278ef7.zip
bugfix: tail handles improper list.
* lib.c (tail): This low-level function is used by the list accumulation routines. Because it doesn't handle improper lists, looking for a null terminator, certain things don't work, like the associativity of append. For instance (append '(1 2) #(3) 4) works but not (append (append '(1 2) #(3)) 4). Fixing tail so that it terminates on any atom, rather than failing trying to cdr through it.
-rw-r--r--lib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 97d0eece..08deb233 100644
--- a/lib.c
+++ b/lib.c
@@ -615,7 +615,7 @@ loc listref_l(val list, val ind)
loc tail(val cons)
{
- while (cdr(cons))
+ while (consp(cdr(cons)))
cons = cdr(cons);
return cdr_l(cons);
}