summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-03-12 11:59:45 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-03-12 11:59:45 -0700
commit7809492815eb35df33e52aae72e03ce10349def5 (patch)
tree836bc37ca81c54b2ebc516341dc4e8505d898f64
parentf233d4776a8b71f2f0ea714c139bb1f871f80f73 (diff)
downloadtxr-7809492815eb35df33e52aae72e03ce10349def5.tar.gz
txr-7809492815eb35df33e52aae72e03ce10349def5.tar.bz2
txr-7809492815eb35df33e52aae72e03ce10349def5.zip
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.
-rw-r--r--match.c8
1 files changed, 6 insertions, 2 deletions
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;