summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1baddf4)
raw | patch | inline | side by side (parent: 1baddf4)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sat, 22 May 2010 21:34:06 +0000 (23:34 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 24 May 2010 18:22:07 +0000 (11:22 -0700) |
Functions for C strings, like strcasestr(), can't see beyond NUL
characters. Check if there is such an obstacle on the line and try
again behind it.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
characters. Check if there is such an obstacle on the line and try
again behind it.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.c | patch | blob | history | |
t/t7008-grep-binary.sh | patch | blob | history |
index c3affb6caa45d1fe037a4ddfa0456cdd991e5859..b95803bbb19a9094dae1d84b214ed04005ab9019 100644 (file)
--- a/grep.c
+++ b/grep.c
{
char *hit;
- if (ignore_case)
- hit = strcasestr(line, pattern);
- else
+ if (ignore_case) {
+ char *s = line;
+ do {
+ hit = strcasestr(s, pattern);
+ if (hit)
+ break;
+ s += strlen(s) + 1;
+ } while (s < eol);
+ } else
hit = memmem(line, eol - line, pattern, strlen(pattern));
if (!hit) {
diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh
index 9adc9ed6fea197883442fa191a7dd6d42d1f785e..9660842c446f78b4b35fa9162235753a85eeee9f 100755 (executable)
--- a/t/t7008-grep-binary.sh
+++ b/t/t7008-grep-binary.sh
git grep -F ile a
'
+test_expect_success 'git grep -Fi iLE a' '
+ git grep -Fi iLE a
+'
+
test_done