]> git.ipfire.org Git - thirdparty/git.git/commitdiff
grep: create a "is_fixed" member in "grep_pat"
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 26 Jul 2019 15:08:15 +0000 (17:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 Jul 2019 20:56:40 +0000 (13:56 -0700)
This change paves the way for later using this value the regex compile
functions themselves.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.c
grep.h

diff --git a/grep.c b/grep.c
index b94e998680c3c27c644236910e2dea20b44fc6cb..6d60e2e557055c35fe8748e0454b81458e42fd8d 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -606,7 +606,6 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
 {
        int err;
        int regflags = REG_NEWLINE;
-       int pat_is_fixed;
 
        p->word_regexp = opt->word_regexp;
        p->ignore_case = opt->ignore_case;
@@ -615,11 +614,11 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
        if (memchr(p->pattern, 0, p->patternlen) && !opt->pcre2)
                die(_("given pattern contains NULL byte (via -f <file>). This is only supported with -P under PCRE v2"));
 
-       pat_is_fixed = is_fixed(p->pattern, p->patternlen);
-       if (p->fixed || pat_is_fixed) {
+       p->is_fixed = is_fixed(p->pattern, p->patternlen);
+       if (p->fixed || p->is_fixed) {
 #ifdef USE_LIBPCRE2
                opt->pcre2 = 1;
-               if (pat_is_fixed) {
+               if (p->is_fixed) {
                        compile_pcre2_pattern(p, opt);
                } else {
                        /*
diff --git a/grep.h b/grep.h
index ce2d72571f1c65f8c2044939ff394bcc5f826479..c0c71eb4a9b2552c2648a1bdf37f23d089a4fa9e 100644 (file)
--- a/grep.h
+++ b/grep.h
@@ -88,6 +88,7 @@ struct grep_pat {
        pcre2_compile_context *pcre2_compile_context;
        uint32_t pcre2_jit_on;
        unsigned fixed:1;
+       unsigned is_fixed:1;
        unsigned ignore_case:1;
        unsigned word_regexp:1;
 };