summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-07-31 17:42:07 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-07-31 17:42:07 -0700
commit0bf28ecd2bf99a65d6284b6bc00dc15ca01b93b2 (patch)
treebcdde754cf051acbc0c67b25fdbbf83409fa549f /match.c
parentb38e34fdec127166ac1e4a3db47c07c53959c677 (diff)
downloadtxr-0bf28ecd2bf99a65d6284b6bc00dc15ca01b93b2.tar.gz
txr-0bf28ecd2bf99a65d6284b6bc00dc15ca01b93b2.tar.bz2
txr-0bf28ecd2bf99a65d6284b6bc00dc15ca01b93b2.zip
txr-017 2009-10-17txr-017
Note: Version 016 ChangeLog message incorrect.
Diffstat (limited to 'match.c')
-rw-r--r--match.c48
1 files changed, 32 insertions, 16 deletions
diff --git a/match.c b/match.c
index babaab18..10ce0c57 100644
--- a/match.c
+++ b/match.c
@@ -882,27 +882,33 @@ obj_t *match_files(obj_t *spec, obj_t *files,
data_lineno = c_num(data_linenum);
first_file_parsed = nil;
} else if (files) {
- obj_t *spec = first(files);
- obj_t *name = consp(spec) ? cdr(spec) : spec;
+ obj_t *source_spec = first(files);
+ obj_t *name = consp(source_spec) ? cdr(source_spec) : source_spec;
fpip_t fp = (errno = 0, complex_open(name, nil));
+ obj_t *first_spec_item = second(first(spec));
- debugf("opening data source ~a", name, nao);
+ if (consp(first_spec_item) && eq(first(first_spec_item), next)) {
+ debugf("not opening source ~a since query starts with next directive",
+ name, nao);
+ } else {
+ debugf("opening data source ~a", name, nao);
- if (complex_open_failed(fp)) {
- if (consp(spec) && car(spec) == nothrow) {
- debugf("could not open ~a: treating as failed match due to nothrow",
- name, nao);
+ if (complex_open_failed(fp)) {
+ if (consp(source_spec) && car(source_spec) == nothrow) {
+ debugf("could not open ~a: treating as failed match due to nothrow",
+ name, nao);
+ return nil;
+ } else if (errno != 0)
+ file_err(nil, "could not open ~a (error ~a/~a)", name,
+ num(errno), string(strdup(strerror(errno))), nao);
+ else
+ file_err(nil, "could not open ~a", name, nao);
return nil;
- } else if (errno != 0)
- file_err(nil, "could not open ~a (error ~a/~a)", name,
- num(errno), string(strdup(strerror(errno))), nao);
- else
- file_err(nil, "could not open ~a", name, nao);
- return nil;
- }
+ }
- if ((data = complex_snarf(fp, name)) != nil)
- data_lineno = 1;
+ if ((data = complex_snarf(fp, name)) != nil)
+ data_lineno = 1;
+ }
}
for (; spec; spec = rest(spec), data = rest(data), data_lineno++)
@@ -1018,6 +1024,16 @@ repeat_spec_same_data:
if (eq(first(source), nothrow))
push(nil, &source);
+ else if (eq(first(source), args)) {
+ obj_t *input_name = string(strdup("args"));
+ cons_bind (new_bindings, success,
+ match_files(spec, cons(input_name, files),
+ bindings, files, one));
+ if (success)
+ return cons(new_bindings,
+ if3(data, cons(data, num(data_lineno)), t));
+ return nil;
+ }
{
obj_t *val = eval_form(first(source), bindings);