summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-09-25 21:32:57 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-09-25 21:32:57 -0700
commit843db24e847619b35baeeb7cf88991ad48427bb6 (patch)
treeae855f5583a242ecac2e9eeb94aee787a5279ac2 /lib.c
parente116ae623f8949e9b35b8a02cce2241b7df560a9 (diff)
downloadtxr-843db24e847619b35baeeb7cf88991ad48427bb6.tar.gz
txr-843db24e847619b35baeeb7cf88991ad48427bb6.tar.bz2
txr-843db24e847619b35baeeb7cf88991ad48427bb6.zip
* lib.c (do_and, do_or): Fix broken andf and orf,
lacking the semantics of returning the last value, or the first true value, respectively.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib.c b/lib.c
index c8298468..dfed7700 100644
--- a/lib.c
+++ b/lib.c
@@ -4335,12 +4335,13 @@ val juxtv(val funlist)
static val do_and(val fun1_list, val args)
{
fun1_list = nullify(fun1_list);
+ val ret = nil;
for (; fun1_list; fun1_list = cdr(fun1_list))
- if (nilp(apply(car(fun1_list), args, nil)))
- return nil;
+ if (nilp((ret = apply(car(fun1_list), args, nil))))
+ break;
- return t;
+ return ret;
}
val andf(val first_fun, ...)
@@ -4380,12 +4381,13 @@ val swap_12_21(val fun)
static val do_or(val fun1_list, val args)
{
fun1_list = nullify(fun1_list);
+ val ret = nil;
for (; fun1_list; fun1_list = cdr(fun1_list))
- if (apply(car(fun1_list), args, nil))
- return t;
+ if ((ret = apply(car(fun1_list), args, nil)))
+ break;
- return nil;
+ return ret;
}
val orf(val first_fun, ...)