summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grep.c12
-rwxr-xr-xt/t7008-grep-binary.sh4
2 files changed, 13 insertions, 3 deletions
diff --git a/grep.c b/grep.c
index c3affb6..b95803b 100644
--- a/grep.c
+++ b/grep.c
@@ -334,9 +334,15 @@ static int fixmatch(const char *pattern, char *line, char *eol,
{
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 9adc9ed..9660842 100755
--- a/t/t7008-grep-binary.sh
+++ b/t/t7008-grep-binary.sh
@@ -55,4 +55,8 @@ test_expect_success 'git grep -F ile a' '
git grep -F ile a
'
+test_expect_success 'git grep -Fi iLE a' '
+ git grep -Fi iLE a
+'
+
test_done