summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-03-24 00:52:51 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-03-24 00:52:51 -0700
commitdc1ae5cd093466d815c52167a21db78ade601763 (patch)
tree1cea7d836a95cf7c2e2e96b249fddaf200e71551 /match.c
parent7ea334385cb123772e86341148b32ac0a1783741 (diff)
downloadtxr-dc1ae5cd093466d815c52167a21db78ade601763.tar.gz
txr-dc1ae5cd093466d815c52167a21db78ade601763.tar.bz2
txr-dc1ae5cd093466d815c52167a21db78ade601763.zip
Bugfix: code like @(skip)@{var /partial/} where
the regular expression does not match all the way to the end of the line was getting by the check for a complete match. * match.c (do_match_line): Loses the second parameter named completely. The check whether the line was matched completely is done higher up, in match_line_completely. This is needed because do_match_line has some early successful return cases which bypass the check. (match_line): Remove second paramter in call to do_match_line. (match_line_completely): Do the check here that the line was matched completely. Nothing can get by this. (v_freeform): Do notpass second nil argument to do_match_line.
Diffstat (limited to 'match.c')
-rw-r--r--match.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/match.c b/match.c
index cad32714..de32a99f 100644
--- a/match.c
+++ b/match.c
@@ -371,7 +371,7 @@ static match_line_ctx ml_bindings_specline(match_line_ctx c, val bindings,
return nc;
}
-static val do_match_line(match_line_ctx *c, val completely);
+static val do_match_line(match_line_ctx *c);
static val match_line(match_line_ctx c);
typedef val (*h_match_func)(match_line_ctx *c);
@@ -1092,7 +1092,7 @@ static match_files_ctx mf_all(val spec, val files, val bindings,
static val v_fun(match_files_ctx *c);
-static val do_match_line(match_line_ctx *c, val completely)
+static val do_match_line(match_line_ctx *c)
{
debug_enter;
@@ -1204,24 +1204,30 @@ static val do_match_line(match_line_ctx *c, val completely)
c->specline = cdr(c->specline);
}
- if (completely && length_str_gt(c->dataline, c->pos)) {
- debuglf(c->specline, lit("spec only matches line to position ~a: ~a"),
- plus(c->pos, c->base), c->dataline, nao);
- debug_return (nil);
- }
-
debug_return (cons(c->bindings, plus(c->pos, c->base)));
debug_leave;
}
static val match_line(match_line_ctx c)
{
- return do_match_line(&c, nil);
+ return do_match_line(&c);
}
static val match_line_completely(match_line_ctx c)
{
- return do_match_line(&c, t);
+ val result = do_match_line(&c);
+
+ if (result) {
+ val new_pos = cdr(result);
+
+ if (new_pos != t && length_str_gt(c.dataline, minus(new_pos, c.base))) {
+ debuglf(c.specline, lit("spec only matches line to position ~a: ~a"),
+ new_pos, c.dataline, nao);
+ return nil;
+ }
+ }
+
+ return result;
}
@@ -2070,7 +2076,7 @@ static val v_freeform(match_files_ctx *c)
c->data = nil;
{
- cons_bind (new_bindings, success, do_match_line(&mlc, nil));
+ cons_bind (new_bindings, success, do_match_line(&mlc));
if (!success) {
debuglf(specline, lit("freeform match failure"), nao);