summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-03-04 23:45:14 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-03-04 23:45:14 -0800
commitad7636e62e32d60a320145f8a727a2f2ffc9f6b4 (patch)
tree8c4ce63a3527e86e92e7a20c2a5e399a4249cf72 /eval.c
parentfb96a3ee7732129d0ee475d7d8438aeffe39d80e (diff)
downloadtxr-ad7636e62e32d60a320145f8a727a2f2ffc9f6b4.tar.gz
txr-ad7636e62e32d60a320145f8a727a2f2ffc9f6b4.tar.bz2
txr-ad7636e62e32d60a320145f8a727a2f2ffc9f6b4.zip
Bug #35718. Workaround good enough to get some code working.
* eval.c (cons_find): New function. (expand_op): Use cons_find rather than tree_find to look for rest_gensym. * regex.c (regsub): Rearranged arguments so that the string is last. This is better for partial evaluaton via the op operator. * regex.h (regsub): Updated declaration.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index 0a9f9765..c527d9de 100644
--- a/eval.c
+++ b/eval.c
@@ -1512,6 +1512,19 @@ static val transform_op(val forms, val syms, val rg)
}
}
+static val cons_find(val obj, val structure, val test)
+{
+ uses_or2;
+
+ if (funcall2(test, obj, structure))
+ return structure;
+ if (atom(structure))
+ return nil;
+ return or2(cons_find(obj, car(structure), test),
+ cons_find(obj, cdr(structure), test));
+}
+
+
static val expand_op(val body)
{
val body_ex = expand_forms(body);
@@ -1521,7 +1534,7 @@ static val expand_op(val body)
val nums = mapcar(car_f, ssyms);
val max = if3(nums, maxv(car(nums), cdr(nums)), zero);
val min = if3(nums, minv(car(nums), cdr(nums)), zero);
- val has_rest = tree_find(rest_gensym, body_trans, eq_f);
+ val has_rest = cons_find(rest_gensym, body_trans, eq_f);
if (!eql(max, length(nums)) && !zerop(min))
eval_error(body, lit("op: missing numeric arguments"), nao);