summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-01-28 19:35:09 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-01-28 19:35:09 -0800
commitacaf29fafaa867ecbf023c96f7783ca4d48c8672 (patch)
treece3f47438b8be1c814d36fed9de337fd73b9a2c5
parent186d0cf7ea3105a6c43cd1e1e0b2b082a839a659 (diff)
downloadtxr-acaf29fafaa867ecbf023c96f7783ca4d48c8672.tar.gz
txr-acaf29fafaa867ecbf023c96f7783ca4d48c8672.tar.bz2
txr-acaf29fafaa867ecbf023c96f7783ca4d48c8672.zip
@(next): bugfix: nothrow not causing failed match.
* match.c (v_next_impl): Contrary to the documentation and to "classic" TXR behavior exhibited in compatibility mode, when @(next "file" :nothrow) fails to open "file", it treats the situation as a cue to read from standard input, rather than to treat the situation as a failed match. This is because complex_open returns nil, and when that is passed to lazy_stream_cons, that function defaults to standard input.
-rw-r--r--match.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/match.c b/match.c
index 8e8716c2..5fce1696 100644
--- a/match.c
+++ b/match.c
@@ -2788,13 +2788,21 @@ static val v_next_impl(match_files_ctx *c)
}
} else {
val stream = complex_open(str, nil, nil, nothrow, nil);
- cons_bind (new_bindings, success,
- match_files(mf_file_data(*c, str,
- lazy_stream_cons(stream), one)));
- if (success)
- return cons(new_bindings,
- if3(c->data, cons(c->data, c->data_lineno), t));
+ if (stream) {
+ cons_bind (new_bindings, success,
+ match_files(mf_file_data(*c, str,
+ lazy_stream_cons(stream), one)));
+
+ if (success)
+ return cons(new_bindings,
+ if3(c->data, cons(c->data, c->data_lineno), t));
+ } else {
+ debuglf(first_spec, lit("could not open ~a: "
+ "treating as failed match due to nothrow"),
+ str, nao);
+ }
+
return nil;
}
}