summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-01-26 14:15:53 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-01-26 14:15:53 -0800
commita2b16d316cf9201fa27d35766f5f245c2c9a6b26 (patch)
treeca0187364399db8811ab2a595f82b13dd55ed08a /match.c
parentb58791b726228b97297cc4512476f6016b9346a2 (diff)
downloadtxr-a2b16d316cf9201fa27d35766f5f245c2c9a6b26.tar.gz
txr-a2b16d316cf9201fa27d35766f5f245c2c9a6b26.tar.bz2
txr-a2b16d316cf9201fa27d35766f5f245c2c9a6b26.zip
* match.c (format_field): Removed useless use of cat_str (no longer
needed because str is already a string). The purpose was to reduce character to strings. (subst_vars): Some of the new logic in format_field must be replicated in the case when format_field is not called because the variable has no modifiers. Lists must be converted to a space-separated string. Bugfix here: occurence of pat and modifiers is not mutually exclusive.
Diffstat (limited to 'match.c')
-rw-r--r--match.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/match.c b/match.c
index eb6e347e..c4ccfd8c 100644
--- a/match.c
+++ b/match.c
@@ -1273,8 +1273,7 @@ val format_field(val obj, val modifier, val filter, val eval_fun)
}
if (filter)
- str = filter_string(filter, cat_str(list(str, nao),
- nil));
+ str = filter_string(filter, str);
}
{
@@ -1321,13 +1320,21 @@ static val subst_vars(val spec, val bindings, val filter)
str = format(nil, lit("~a"), str, nao);
if (pat)
- spec = cons(filter_string(filter, str), cons(pat, rest(spec)));
- else if (modifiers)
+ spec = cons(pat, rest(spec));
+
+ if (modifiers) {
spec = cons(format_field(str, modifiers, filter,
curry_123_2(func_n3(txeval), spec, bindings)),
rest(spec));
- else
+ } else {
+ if (listp(str))
+ str = cat_str(mapcar(func_n1(tostringp), str), lit(" "));
+ else
+ str = if3(stringp(str), str, tostringp(str));
+
spec = cons(filter_string(filter, str), rest(spec));
+ }
+
continue;
}
uw_throwf(query_error_s, lit("unbound variable ~a"),