From 7809492815eb35df33e52aae72e03ce10349def5 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 12 Mar 2017 11:59:45 -0700 Subject: bugfix: @(next) in function called with match-fun. The match-fun function must augment the input list with the current input source, because @(next) pops the first item from the files list and tries to open the second. We want it so that if we invoke (match-fun 'f arglist input '("abc")) then if the pattern function f invokes @(next), it will open "abc". * match.c (match_fun): Calculate a value for the curfile property of the match context and pass it to mf_all. If the input is a stream, we get its name. We also push this curfile onto the files list, satisfying the expectation that curfile and the first element of files refer to the same thing. --- match.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'match.c') diff --git a/match.c b/match.c index 66c376a6..01ee5c2a 100644 --- a/match.c +++ b/match.c @@ -4562,13 +4562,17 @@ val match_fun(val name, val args, val input_in, val files_in) val call = cons(name, args); val spec = cons(cons(call, nil), nil); val input = default_bool_arg(input_in); - val files = default_bool_arg(files_in); + val in_stream_p = streamp(input); + val curfile = if3(in_stream_p, + stream_get_prop(input, name_k), + lit("list")); + val files = cons(curfile, default_bool_arg(files_in)); val in_bindings = cdr(uw_get_match_context()); val data = if3(streamp(input), lazy_stream_cons(input), input); /* TODO: pass through source location context */ - match_files_ctx c = mf_all(spec, files, in_bindings, data, nil); + match_files_ctx c = mf_all(spec, files, in_bindings, data, curfile); val ret; debug_enter; -- cgit v1.2.3