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>
René Scharfe committed
Jun 1, 2009 at 23:53 UTC
1f5b9cc40e80a8a7902236a26844be138887b1d9
1 file changed
+2
grep.c
+2
@@ -500,6 +500,8 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
500
501
*eol = '\0';
502
while (next_match(opt, bol, eol, ctx, &match, eflags)) {
503
+ if (match.rm_so == match.rm_eo)
504
+ break;
505
printf("%.*s%s%.*s%s",
506
(int)match.rm_so, bol,
507
opt->color_match,