diff options
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | match.c | 28 |
2 files changed, 34 insertions, 11 deletions
@@ -1,5 +1,22 @@ 2012-03-24 Kaz Kylheku <kaz@kylheku.com> + 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. + +2012-03-24 Kaz Kylheku <kaz@kylheku.com> + * lib.c (search_str): If start_num is nil, default it to zero. This is needed for this to work right as an optional argument. @@ -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); |