summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--match.c11
2 files changed, 24 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 55b06f15..65dcd162 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2014-03-09 Kaz Kylheku <kaz@kylheku.com>
+
+ Fixing broken processing of horizontal matching across
+ long lines produced by @(freeform). Once the matching
+ passes about 4000 characters, the "consume_prefix"
+ function kicks in to save memory. Then any code which is
+ not properly written to handle this displaced situation
+ will break.
+
+ * match.c (h_text, h_var, h_coll, h_parallel, h_fun): Bugfix.
+ The recursive calls to match_line return an absolute position.
+ From this value we must subtract c->base if we are to
+ compare it with c->pos, or update c->pos. If we use the
+ absolute value, we are abruptly jumping ahead in the data.
+
2014-03-08 Kaz Kylheku <kaz@kylheku.com>
Issue: match_regex and search_regex were continuing to feed characters
diff --git a/match.c b/match.c
index 9f11019c..0800ebc1 100644
--- a/match.c
+++ b/match.c
@@ -428,7 +428,7 @@ static val h_text(match_line_ctx *c)
val new_pos = cdr(match_line(ml_specline(*c, texts)));
if (new_pos) {
- c->pos = new_pos;
+ c->pos = minus(new_pos, c->base);
return next_spec_k;
}
@@ -539,6 +539,8 @@ static val h_var(match_line_ctx *c)
return nil;
}
+ new_pos = minus(new_pos, c->base);
+
LOG_MATCH("var spanning form", new_pos);
if (sym)
c->bindings = acons(sym, sub_str(c->dataline, c->pos, new_pos), new_bindings);
@@ -785,6 +787,8 @@ static val h_coll(match_line_ctx *c)
match_line(ml_bindings_specline(*c, new_bindings, spec)));
if (until_pos) {
+ until_pos = minus(until_pos, c->base);
+
LOG_MATCH("until/last", until_pos);
if (sym == last_s) {
last_bindings = set_diff(until_last_bindings,
@@ -802,6 +806,8 @@ static val h_coll(match_line_ctx *c)
val strictly_new_bindings = set_diff(new_bindings,
c->bindings, eq_f, nil);
val have_new = strictly_new_bindings;
+
+ new_pos = minus(new_pos, c->base);
LOG_MATCH("coll", new_pos);
for (iter = vars; iter; iter = cdr(iter)) {
@@ -935,6 +941,7 @@ static val h_parallel(match_line_ctx *c)
if (new_pos) {
some_match = t;
+ new_pos = minus(new_pos, c->base);
if (resolve_ub_vars) {
val uiter;
@@ -1101,7 +1108,7 @@ static val h_fun(match_line_ctx *c)
}
}
- c->pos = success;
+ c->pos = minus(success, c->base);
}
}