diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | RELNOTES | 9 | ||||
-rw-r--r-- | match.c | 4 | ||||
-rw-r--r-- | txr.1 | 17 |
4 files changed, 39 insertions, 2 deletions
@@ -1,3 +1,14 @@ +2011-11-22 Kaz Kylheku <kaz@kylheku.com> + + * match.c (search_form): Bugfix: we must search to one character + position after the end of the line, otherwise we can never match + @(eol). + (h_eol): Bugfix: do not return t, but the line length. + + * txr.1: Warn users about @var@(bind ...) pitfall. + + * RELNOTES: Updated. + 2011-11-20 Kaz Kylheku <kaz@kylheku.com> Version 042 @@ -1,3 +1,12 @@ + (future release) + TXR 043 + 201?-??-?? + + Bugs + + - Buggy @(eol) directive fixed. + + (current release) TXR 042 2011-11-20 @@ -411,7 +411,7 @@ static val search_form(match_line_ctx *c, val needle_form, val from_end) rlcp(spec, needle_form); - for (; (from_end && ge(pos, c->pos)) || length_str_gt(c->dataline, pos); + for (; (from_end && ge(pos, c->pos)) || length_str_ge(c->dataline, pos); pos = plus(pos, step)) { cons_bind (new_bindings, new_pos, @@ -1062,7 +1062,7 @@ static val h_eol(match_line_ctx c, match_line_ctx *cout) if (length_str_le(c.dataline, c.pos)) { LOG_MATCH("eol", c.pos); - return cons(c.bindings, t); + return cons(c.bindings, c.pos); } LOG_MISMATCH("eol"); return nil; @@ -637,6 +637,23 @@ form. The @(skip) will be processed alone, without regard for the trailing text and so consume the input to the end of the line. The right way to express the most probable intent of this is @{var}text. +Another degenerate case is @var@(bind ...), or in general, a variable +followed by some directive not used for matching text. Watch out for +the following pitfall: + + @a @b@(bind have_ab "y") + +The intent here is that the variable b captures everything after the space to +the end of the line, and then the variable have_ab is set to "y". But since +@(bind) always succeeds, b captures an empty string, and then the whole line +fails if there is any material after the space. The right way to do this is: + + @a @b@(eol)@(bind have_ab "y") + +That is to say, match an explicit @(eol) after the variable. This will +search for the end of the lne and capture the spanning text into b, as +intended. The bind then happens afterward. + .SS Consecutive Variables If an unbound variable specified a fixed-width match or a regular expression, |