summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2009-06-01 23:53:05 +0200
committerJunio C Hamano <gitster@pobox.com>2009-06-01 22:30:39 -0700
commit1f5b9cc40e80a8a7902236a26844be138887b1d9 (patch)
tree6c0721315dac35f301dc716cd3a7c53e1b62e06f /grep.c
parentdbb6a4ada6c6c1065b62313127ff032196e9d232 (diff)
downloadgit-1f5b9cc40e80a8a7902236a26844be138887b1d9.tar.gz
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>
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/grep.c b/grep.c
index cc6d5b04c1..7bf4a60ac7 100644
--- a/grep.c
+++ b/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,