summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--RELNOTES9
-rw-r--r--match.c4
-rw-r--r--txr.117
4 files changed, 39 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8049ea09..1bc94dcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/RELNOTES b/RELNOTES
index c8fe01bc..c214d239 100644
--- a/RELNOTES
+++ b/RELNOTES
@@ -1,3 +1,12 @@
+ (future release)
+ TXR 043
+ 201?-??-??
+
+ Bugs
+
+ - Buggy @(eol) directive fixed.
+
+ (current release)
TXR 042
2011-11-20
diff --git a/match.c b/match.c
index 05b542bd..52f79624 100644
--- a/match.c
+++ b/match.c
@@ -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;
diff --git a/txr.1 b/txr.1
index a6dcfc1b..04d34f60 100644
--- a/txr.1
+++ b/txr.1
@@ -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,