summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2009-11-02 15:57:40 -0800
committerKaz Kylheku <kaz@kylheku.com>2009-11-02 15:57:40 -0800
commitf6c4f253681b576f39d939e602e9de7bc1b8892b (patch)
treeb0cde10be55dfb779106fc6e2fb387d0741fd3e8 /match.c
parent69a1cbeccd0834937a46c95da08948d684868c17 (diff)
downloadtxr-f6c4f253681b576f39d939e602e9de7bc1b8892b.tar.gz
txr-f6c4f253681b576f39d939e602e9de7bc1b8892b.tar.bz2
txr-f6c4f253681b576f39d939e602e9de7bc1b8892b.zip
Implement custom separator and limit in freeform.
Diffstat (limited to 'match.c')
-rw-r--r--match.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/match.c b/match.c
index e90d3d6f..675e3d0f 100644
--- a/match.c
+++ b/match.c
@@ -984,12 +984,21 @@ repeat_spec_same_data:
return nil;
}
} else if (sym == freeform) {
+ obj_t *args = rest(rest(first_spec));
+ obj_t *vals = mapcar(func_n1(cdr),
+ mapcar(bind2other(func_n2(eval_form),
+ bindings), args));
+
if ((spec = rest(spec)) == nil) {
sem_error(spec_linenum,
"freeform must be followed by a query line", nao);
} else {
+ obj_t *limit = or2(if2(nump(first(vals)), first(vals)),
+ if2(nump(second(vals)), second(vals)));
+ obj_t *sep = or2(if2(stringp(first(vals)), first(vals)),
+ if2(stringp(second(vals)), second(vals)));
obj_t *ff_specline = rest(first(spec));
- obj_t *ff_dataline = lazy_str(data);
+ obj_t *ff_dataline = lazy_str(data, sep, limit);
cons_bind (new_bindings, success,
match_line(bindings, ff_specline, ff_dataline, zero,