Skip to content

Commit

Permalink
sam: produce empty match at the end of looped range
Browse files Browse the repository at this point in the history
In certain cases (e.g. involving negated character classes) the last
empty match of an x command would wrongly be skipped.

See martanne#925
  • Loading branch information
martanne committed Jan 25, 2021
1 parent 80d0291 commit 65e7bcc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit 65e7bcc

Please sign in to comment.