summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-10-25 14:28:49 -0400
committerKaz Kylheku <kaz@kylheku.com>2011-10-25 14:28:49 -0400
commit756345ddd407550ee41469667a66e7ce9d8eb49e (patch)
treefa29d7e942a344147329a78c004d1097ca9072cf /match.c
parentbdca604f10ffdbde56c68ca30b4adbee0f10818e (diff)
downloadtxr-756345ddd407550ee41469667a66e7ce9d8eb49e.tar.gz
txr-756345ddd407550ee41469667a66e7ce9d8eb49e.tar.bz2
txr-756345ddd407550ee41469667a66e7ce9d8eb49e.zip
Shorthand for filters which map multiple texts to a common
replacement text. * filter.c (build_filter_from_list): Allow tuples to denote multiple keys mapping to the same value. * lib.c (do_curry_123_2, do_curry_123_1): New static functions. (curry_123_2, curry_123_1): New functions. * lib.h (curry_123_2, curry_123_1): New functions declared. * match.c (v_deffilter): Allow tuples of strings rather than just pairs. * txr.1: Updated.
Diffstat (limited to 'match.c')
-rw-r--r--match.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/match.c b/match.c
index 42f42b90..7bda5f4d 100644
--- a/match.c
+++ b/match.c
@@ -2555,18 +2555,14 @@ static val v_deffilter(match_files_ctx c, match_files_ctx *cout)
if (!all_satisfy(table, andf(func_n1(listp),
chain(func_n1(length),
- curry_12_2(func_n2(eq), two),
- nao),
- chain(func_n1(first),
- func_n1(stringp),
- nao),
- chain(func_n1(second),
- func_n1(stringp),
- nao),
+ curry_12_1(func_n2(ge), two), nao),
+ chain(func_n1(rest),
+ curry_123_1(func_n3(all_satisfy),
+ func_n1(stringp), nil), nao),
nao),
nil))
sem_error(spec_linenum,
- lit("deffilter arguments must be string pairs"),
+ lit("deffilter arguments must be lists of at least two strings"),
nao);
register_filter(sym, table);
/* TODO: warn about replaced filter. */