summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
Diffstat (limited to 'match.c')
-rw-r--r--match.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/match.c b/match.c
index 1dece256..25e8561d 100644
--- a/match.c
+++ b/match.c
@@ -1203,7 +1203,7 @@ static val match_line(match_line_ctx c)
return cons(c.bindings, c.pos);
}
-val format_field(val string_or_list, val modifier, val filter)
+val format_field(val string_or_list, val modifier, val filter, val eval_fun)
{
val n = zero;
val plist = nil;
@@ -1213,14 +1213,21 @@ val format_field(val string_or_list, val modifier, val filter)
for (; modifier; pop(&modifier)) {
val item = first(modifier);
- if (fixnump(item))
- n = item;
if (regexp(item))
uw_throw(query_error_s, lit("format_field: regex modifier in output"));
if (keywordp(item)) {
plist = modifier;
break;
}
+
+ {
+ val v = funcall1(eval_fun, item);
+ if (fixnump(v))
+ n = v;
+ else
+ uw_throwf(query_error_s, lit("format_field: bad modifier object: ~s"),
+ item, nao);
+ }
}
{
@@ -1277,10 +1284,6 @@ static val subst_vars(val spec, val bindings, val filter)
val modifiers = fourth(elem);
val pair = assoc(sym, bindings);
- if (modifiers)
- modifiers = mapcar(curry_123_2(func_n3(txeval), spec, bindings),
- modifiers);
-
if (pair) {
val str = cdr(pair);
@@ -1290,7 +1293,9 @@ static val subst_vars(val spec, val bindings, val filter)
if (pat)
spec = cons(filter_string(filter, str), cons(pat, rest(spec)));
else if (modifiers)
- spec = cons(format_field(str, modifiers, filter), rest(spec));
+ spec = cons(format_field(str, modifiers, filter,
+ curry_123_2(func_n3(txeval), spec, bindings)),
+ rest(spec));
else
spec = cons(filter_string(filter, str), rest(spec));
continue;