summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-02-29 06:05:51 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-02-29 06:05:51 -0800
commit144cabede201ace9507473a9c9a9200f475eec1a (patch)
tree0f1f3eb5a7cb25a74c1b436a783480d25834f299 /match.c
parentffdf3fc55d40f64030b6c0037e80dbca404a69e0 (diff)
downloadtxr-144cabede201ace9507473a9c9a9200f475eec1a.tar.gz
txr-144cabede201ace9507473a9c9a9200f475eec1a.tar.bz2
txr-144cabede201ace9507473a9c9a9200f475eec1a.zip
Implement @(next nil).
* match.c (v_next): If argument to @(next) is nil, then evaluate remaining query in context with no list of files, and no data. * txr.1: Documented @(next nil).
Diffstat (limited to 'match.c')
-rw-r--r--match.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/match.c b/match.c
index 187f7ec9..b3684180 100644
--- a/match.c
+++ b/match.c
@@ -2310,9 +2310,7 @@ static val v_next(match_files_ctx *c)
if3(c->data, cons(c->data, c->data_lineno), t));
return nil;
}
- }
-
- if (source == env_k) {
+ } else if (source == env_k) {
if (rest(args)) {
sem_error(specline, lit("(next :env) takes no additional arguments"), nao);
} else {
@@ -2324,12 +2322,18 @@ static val v_next(match_files_ctx *c)
if3(c->data, cons(c->data, c->data_lineno), t));
return nil;
}
- }
-
- if (consp(source)) {
+ } else if (consp(source)) {
val sym = car(source);
if (sym == var_s || sym == expr_s)
meta = t;
+ } else if (!source) {
+ cons_bind (new_bindings, success,
+ match_files(mf_all(c->spec, nil, c->bindings, nil, lit("empty"))));
+
+ if (success)
+ return cons(new_bindings,
+ if3(c->data, cons(c->data, c->data_lineno), t));
+ return nil;
}
if (opt_compat && opt_compat <= 124)