grep: create a "is_fixed" member in "grep_pat"

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>

Ævar Arnfjörð Bjarmason committed Jul 26, 2019 at 17:08 UTC 09872f6418f6b6fc1b823d3b324907c02e9bc75b
2 files changed +4 -4
grep.c
+3 -4
@@ -606,7 +606,6 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
606 {
607 int err;
608 int regflags = REG_NEWLINE;
609 - int pat_is_fixed;
609
610 p->word_regexp = opt->word_regexp;
611 p->ignore_case = opt->ignore_case;
@@ -615,11 +614,11 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
614 if (memchr(p->pattern, 0, p->patternlen) && !opt->pcre2)
615 die(_("given pattern contains NULL byte (via -f <file>). This is only supported with -P under PCRE v2"));
616
618 - pat_is_fixed = is_fixed(p->pattern, p->patternlen);
619 - if (p->fixed || pat_is_fixed) {
617 + p->is_fixed = is_fixed(p->pattern, p->patternlen);
618 + if (p->fixed || p->is_fixed) {
619 #ifdef USE_LIBPCRE2
620 opt->pcre2 = 1;
622 - if (pat_is_fixed) {
621 + if (p->is_fixed) {
622 compile_pcre2_pattern(p, opt);
623 } else {
624 /*
grep.h
+1
@@ -88,6 +88,7 @@ struct grep_pat {
88 pcre2_compile_context *pcre2_compile_context;
89 uint32_t pcre2_jit_on;
90 unsigned fixed:1;
91 + unsigned is_fixed:1;
92 unsigned ignore_case:1;
93 unsigned word_regexp:1;
94 };