summaryrefslogtreecommitdiffstats
path: root/match.c
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
commit5f23e30b998a7d2e42981c02ed6339c1e3659aa4 (patch)
treece3f47438b8be1c814d36fed9de337fd73b9a2c5 /match.c
parentfe6ef8b5e2810495d9ef4620be30806857351202 (diff)
downloadtxr-5f23e30b998a7d2e42981c02ed6339c1e3659aa4.tar.gz
txr-5f23e30b998a7d2e42981c02ed6339c1e3659aa4.tar.bz2
txr-5f23e30b998a7d2e42981c02ed6339c1e3659aa4.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.
Diffstat (limited to 'match.c')
-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;
}
}