From 0367ad753c7749c33f57e1e0805e0dbcea115af3 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 27 Jun 2014 07:23:08 -0700 Subject: 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. --- lib.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib.c') 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; -- cgit v1.2.3