From 5f23e30b998a7d2e42981c02ed6339c1e3659aa4 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 28 Jan 2019 19:35:09 -0800 Subject: @(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. --- match.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'match.c') 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; } } -- cgit v1.2.3