From 611838f27eca5ba48883a1a8219fec180939db7c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 19 Jan 2012 19:02:48 -0800 Subject: * lib.c (car_l, cdr_l): Bugfix: do not call the lazy cons force function if it is already nil, and set it to nil afterward. --- ChangeLog | 5 +++++ lib.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 82eae34c..e2f0f93b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-01-19 Kaz Kylheku + + * lib.c (car_l, cdr_l): Bugfix: do not call the lazy cons + force function if it is already nil, and set it to nil afterward. + 2012-01-12 Kaz Kylheku * eval.c (eval_init): Make lazy_appendv function diff --git a/lib.c b/lib.c index 70324341..a05ead7e 100644 --- a/lib.c +++ b/lib.c @@ -246,7 +246,10 @@ val *car_l(val cons) case CONS: return &cons->c.car; case LCONS: - funcall1(cons->lc.func, cons); + if (cons->lc.func) { + funcall1(cons->lc.func, cons); + cons->lc.func = nil; + } return &cons->lc.car; default: type_mismatch(lit("~s is not a cons"), cons, nao); @@ -259,7 +262,10 @@ val *cdr_l(val cons) case CONS: return &cons->c.cdr; case LCONS: - funcall1(cons->lc.func, cons); + if (cons->lc.func) { + funcall1(cons->lc.func, cons); + cons->lc.func = nil; + } return &cons->lc.cdr; default: type_mismatch(lit("~s is not a cons"), cons, nao); -- cgit v1.2.3