From ad7636e62e32d60a320145f8a727a2f2ffc9f6b4 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 4 Mar 2012 23:45:14 -0800 Subject: 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. --- ChangeLog | 14 ++++++++++++++ eval.c | 15 ++++++++++++++- regex.c | 2 +- regex.h | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a26863dd..b50f786f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2012-03-04 Kaz Kylheku + + 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 * eval.c (eval_init): New intrinsic function, regsub. 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); -- cgit v1.2.3