summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-08-05 21:46:08 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-08-05 21:46:08 -0700
commit2e0acd6057bd65b0b872356c51c1b7b1a06c89b9 (patch)
treea4483a81092a80fda41c624165586371d32a4dce /lib.h
parent2844bb73b485450660d70de2de489590d0995d9e (diff)
downloadtxr-2e0acd6057bd65b0b872356c51c1b7b1a06c89b9.tar.gz
txr-2e0acd6057bd65b0b872356c51c1b7b1a06c89b9.tar.bz2
txr-2e0acd6057bd65b0b872356c51c1b7b1a06c89b9.zip
bugfix: n-ary arith functions must check single arg.
We are allowing calls like (* "a") and (+ "a") without diagnosing that the argument isn't of a valid type. Note that (max "a") is fine beacause min and max use the less function; they are not strictly numeric. * lib.c (nary_op): Beef up function with additional argument for type checking the unary case. (unary_num, unary_arith, unary_int): New static functions. (plusv, mulv, logandv, logiorv): Use new nary_op interface. (gtv, ltv, gev, lev, numeqv, numneq): Check the first number. * lib.c (nary_op): Declaration updated.
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib.h b/lib.h
index 6df5a914..39ac5175 100644
--- a/lib.h
+++ b/lib.h
@@ -654,7 +654,9 @@ val bignump(val num);
val floatp(val num);
val integerp(val num);
val numberp(val num);
-val nary_op(val (*cfunc)(val, val), struct args *args, val emptyval);
+val nary_op(val self, val (*bfun)(val, val),
+ val (*ufun)(val self, val),
+ struct args *args, val emptyval);
val plus(val anum, val bnum);
val plusv(struct args *);
val minus(val anum, val bnum);