summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-06-27 07:23:08 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-06-27 07:23:08 -0700
commit0367ad753c7749c33f57e1e0805e0dbcea115af3 (patch)
treeea27bc337fa8de6eacd48e9084ac0eee1aa23ae6 /lib.c
parentea452c6fdc1b9d900ffe65b1cdeb0b098a4c20f6 (diff)
downloadtxr-0367ad753c7749c33f57e1e0805e0dbcea115af3.tar.gz
txr-0367ad753c7749c33f57e1e0805e0dbcea115af3.tar.bz2
txr-0367ad753c7749c33f57e1e0805e0dbcea115af3.zip
Bugfix: apply_intrinsic and iapply must not destructively
manipulate argument lists. * eval.c (apply_frob_args): Rewrite to non-destructive one-pass version. (iapply): Likewise. * lib.c (term): New function. * lib.h (term): Declared.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index bb0d580f..e84b098f 100644
--- a/lib.c
+++ b/lib.c
@@ -408,6 +408,13 @@ loc tail(val cons)
return cdr_l(cons);
}
+loc term(loc head)
+{
+ while (consp(deref(head)))
+ head = cdr_l(deref(head));
+ return head;
+}
+
loc lastcons(val list)
{
loc ret = nulloc;