From c99e75b3f7458084072743aaa38b8a56197084d6 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 1 Mar 2012 16:19:43 -0800 Subject: * match.c (v_load): Fixed broken functionality. Failing to evaluate directives following the load and consume input properly. --- ChangeLog | 5 +++++ match.c | 25 ++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index dfc2da59..f92b4152 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-03-01 Kaz Kylheku + + * match.c (v_load): Fixed broken functionality. Failing to evaluate + directives following the load and consume input properly. + 2012-03-01 Kaz Kylheku Fixing two instances of unintentional O(n*n) behavior and poor memory use diff --git a/match.c b/match.c index a65d6d00..66325ddd 100644 --- a/match.c +++ b/match.c @@ -3415,7 +3415,30 @@ static val v_load(match_files_ctx *c) gc_state(gc); { val spec = get_spec(); - return match_files(mf_spec(*c, spec)); + val result = match_files(mf_spec(*c, spec)); + + if (!result) { + debuglf(specline, lit("load: ~s failed"), path, nao); + return nil; + } else { + cons_bind (new_bindings, success, result); + + if (consp(success)) { + debuglf(specline, + lit("load: ~s matched; " + "advancing from line ~a to ~a"), + path, c->data_lineno, cdr(success), nao); + c->data = car(success); + c->data_lineno = cdr(success); + c->bindings = new_bindings; + } else { + debuglf(specline, lit("load: ~s consumed entire file"), path, + nao); + c->data = nil; + } + + return next_spec_k; + } } } } -- cgit v1.2.3