summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--match.c25
2 files changed, 29 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index dfc2da59..f92b4152 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2012-03-01 Kaz Kylheku <kaz@kylheku.com>
+ * match.c (v_load): Fixed broken functionality. Failing to evaluate
+ directives following the load and consume input properly.
+
+2012-03-01 Kaz Kylheku <kaz@kylheku.com>
+
Fixing two instances of unintentional O(n*n) behavior and poor memory use
that occur in horizontal matching of basic text patterns.
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;
+ }
}
}
}