summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-10-11 05:24:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-10-11 05:24:47 (GMT)
commit93424f1f7d790944168d46faf5222a388898d031 (patch)
tree08bc467ba4b98aa5dd4beee2f0391714e2c8b779 /grep.c
parenta73f91774cbfb6f31bca328ebf200498fe92d97a (diff)
parentff61681b46760f6a64353018760bccc14c90f8e9 (diff)
downloadgit-93424f1f7d790944168d46faf5222a388898d031.zip
git-93424f1f7d790944168d46faf5222a388898d031.tar.gz
git-93424f1f7d790944168d46faf5222a388898d031.tar.bz2
Merge branch 'cb/pcre1-cleanup'
PCRE fixes. * cb/pcre1-cleanup: grep: refactor and simplify PCRE1 support grep: make sure NO_LIBPCRE1_JIT disable JIT in PCRE1
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/grep.c b/grep.c
index 5d268b1..0bb4cbd 100644
--- a/grep.c
+++ b/grep.c
@@ -374,6 +374,7 @@ static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)
const char *error;
int erroffset;
int options = PCRE_MULTILINE;
+ int study_options = 0;
if (opt->ignore_case) {
if (!opt->ignore_locale && has_non_ascii(p->pattern))
@@ -388,15 +389,18 @@ static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)
if (!p->pcre1_regexp)
compile_regexp_failed(p, error);
- p->pcre1_extra_info = pcre_study(p->pcre1_regexp, GIT_PCRE_STUDY_JIT_COMPILE, &error);
- if (!p->pcre1_extra_info && error)
- die("%s", error);
-
-#ifdef GIT_PCRE1_USE_JIT
+#if defined(PCRE_CONFIG_JIT) && !defined(NO_LIBPCRE1_JIT)
pcre_config(PCRE_CONFIG_JIT, &p->pcre1_jit_on);
if (opt->debug)
fprintf(stderr, "pcre1_jit_on=%d\n", p->pcre1_jit_on);
+
+ if (p->pcre1_jit_on)
+ study_options = PCRE_STUDY_JIT_COMPILE;
#endif
+
+ p->pcre1_extra_info = pcre_study(p->pcre1_regexp, study_options, &error);
+ if (!p->pcre1_extra_info && error)
+ die("%s", error);
}
static int pcre1match(struct grep_pat *p, const char *line, const char *eol,
@@ -425,7 +429,7 @@ static int pcre1match(struct grep_pat *p, const char *line, const char *eol,
static void free_pcre1_regexp(struct grep_pat *p)
{
pcre_free(p->pcre1_regexp);
-#ifdef GIT_PCRE1_USE_JIT
+#ifdef PCRE_CONFIG_JIT
if (p->pcre1_jit_on)
pcre_free_study(p->pcre1_extra_info);
else