summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-01-19 19:02:48 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-01-19 19:02:48 -0800
commit611838f27eca5ba48883a1a8219fec180939db7c (patch)
tree5b32031b7243a0f23ef31bd4b579b9bebb08aef1 /lib.c
parent4b8d0452aa601bf65614f22d7f76df633d939ed0 (diff)
downloadtxr-611838f27eca5ba48883a1a8219fec180939db7c.tar.gz
txr-611838f27eca5ba48883a1a8219fec180939db7c.tar.bz2
txr-611838f27eca5ba48883a1a8219fec180939db7c.zip
* 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.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c10
1 files changed, 8 insertions, 2 deletions
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);