summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--ChangeLog14
-rw-r--r--eval.c15
-rw-r--r--regex.c2
-rw-r--r--regex.h2
4 files changed, 30 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index a26863dd..b50f786f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2012-03-04 Kaz Kylheku <kaz@kylheku.com>
+ 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.
+
+2012-03-04 Kaz Kylheku <kaz@kylheku.com>
+
* eval.c (eval_init): New intrinsic function, regsub.
* regex.c (regsub): New function.
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);
diff --git a/regex.c b/regex.c
index 6c2a914d..60f5cd2d 100644
--- a/regex.c
+++ b/regex.c
@@ -1724,7 +1724,7 @@ val match_regex(val str, val reg, val pos)
return nil;
}
-val regsub(val str, val regex, val repl)
+val regsub(val regex, val repl, val str)
{
list_collect_decl (out, ptail);
val pos = zero;
diff --git a/regex.h b/regex.h
index a5911790..7c589798 100644
--- a/regex.h
+++ b/regex.h
@@ -28,4 +28,4 @@ val regex_compile(val regex_sexp);
val regexp(val);
val search_regex(val haystack, val needle_regex, val start_num, val from_end);
val match_regex(val str, val regex, val pos);
-val regsub(val str, val regex, val repl);
+val regsub(val regex, val repl, val str);