summaryrefslogtreecommitdiffstats
path: root/lib.c
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
commit01d5eb034e3c325dfceb0a29caadc0b5e756de47 (patch)
treee99102571a51f6c9f266259cac7fa33b1226370a /lib.c
parentea40c38aefb6a0747b631d48d3d680922c44b836 (diff)
downloadtxr-01d5eb034e3c325dfceb0a29caadc0b5e756de47.tar.gz
txr-01d5eb034e3c325dfceb0a29caadc0b5e756de47.tar.bz2
txr-01d5eb034e3c325dfceb0a29caadc0b5e756de47.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.
Diffstat (limited to 'lib.c')
-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);
}