Code

autocrlf: Make it work also for un-normalized repositories
[git.git] / grep.c
diff --git a/grep.c b/grep.c
index d281a020e8452939d7dad0ab53876a8476a5cc89..a0864f1cbbe5fcc6f28eb57a08ebfd9a76c87da6 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -57,11 +57,8 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
 
        p->word_regexp = opt->word_regexp;
        p->ignore_case = opt->ignore_case;
+       p->fixed = opt->fixed;
 
-       if (opt->fixed)
-               p->fixed = 1;
-       if (opt->regflags & REG_ICASE)
-               p->fixed = 0;
        if (p->fixed)
                return;
 
@@ -675,8 +672,15 @@ static int look_ahead(struct grep_opt *opt,
 
                if (p->fixed)
                        hit = !fixmatch(p->pattern, bol, p->ignore_case, &m);
-               else
+               else {
+#ifdef REG_STARTEND
+                       m.rm_so = 0;
+                       m.rm_eo = *left_p;
+                       hit = !regexec(&p->regexp, bol, 1, &m, REG_STARTEND);
+#else
                        hit = !regexec(&p->regexp, bol, 1, &m, 0);
+#endif
+               }
                if (!hit || m.rm_so < 0 || m.rm_eo < 0)
                        continue;
                if (earliest < 0 || m.rm_so < earliest)