mirror of
https://github.com/git/git.git
synced 2024-11-18 19:13:58 +01:00
grep: fix colouring of matches with zero length
If a zero-length match is encountered, break out of loop and show the rest of the line uncoloured. Otherwise we'd be looping forever, trying to make progress by advancing the pointer by zero characters. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
dbb6a4ada6
commit
1f5b9cc40e
2
grep.c
2
grep.c
@ -500,6 +500,8 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
|
||||
|
||||
*eol = '\0';
|
||||
while (next_match(opt, bol, eol, ctx, &match, eflags)) {
|
||||
if (match.rm_so == match.rm_eo)
|
||||
break;
|
||||
printf("%.*s%s%.*s%s",
|
||||
(int)match.rm_so, bol,
|
||||
opt->color_match,
|
||||
|
Loading…
Reference in New Issue
Block a user