aboutsummaryrefslogtreecommitdiff
path: root/sam.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2021-01-25 13:43:07 +0100
committerMarc André Tanner <mat@brain-dump.org>2021-01-25 14:02:31 +0100
commit65e7bcc2cbd62e217f500ea4ee542269a0d4b2f5 (patch)
tree6e2458e8330cbc8843b0013e858eea2e13dc7e45 /sam.c
parent80d0291b2ee9e7aae6683c973c263efbc02259c4 (diff)
downloadvis-65e7bcc2cbd62e217f500ea4ee542269a0d4b2f5.tar.gz
vis-65e7bcc2cbd62e217f500ea4ee542269a0d4b2f5.tar.xz
sam: produce empty match at the end of looped range
In certain cases (e.g. involving negated character classes) the last empty match of an x command would wrongly be skipped. See #925
Diffstat (limited to 'sam.c')
-rw-r--r--sam.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sam.c b/sam.c
index 8e7b51f..24aefcd 100644
--- a/sam.c
+++ b/sam.c
@@ -1417,6 +1417,7 @@ static int extract(Vis *vis, Win *win, Command *cmd, const char *argv[], Selecti
if (match[0].start == match[0].end) {
if (last_start == match[0].start) {
start++;
+ trailing_match = start == end;
continue;
}
/* in Plan 9's regexp library ^ matches the beginning
@@ -1429,8 +1430,7 @@ static int extract(Vis *vis, Win *win, Command *cmd, const char *argv[], Selecti
break;
}
start = match[0].end;
- if (start == end)
- trailing_match = true;
+ trailing_match = start == end;
} else {
if (argv[0][0] == 'y')
r = text_range_new(start, end);