THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

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
tags/v2.24.0-rc0
Junio C Hamano 1 month ago
parent
commit
93424f1f7d
3 changed files with 12 additions and 24 deletions
  1. +2
    -7
      Makefile
  2. +10
    -6
      grep.c
  3. +0
    -11
      grep.h

+ 2
- 7
Makefile View File

@@ -34,13 +34,8 @@ all::
# library. Support for version 1 will likely be removed in some future
# release of Git, as upstream has all but abandoned it.
#
# When using USE_LIBPCRE1, define NO_LIBPCRE1_JIT if the PCRE v1
# library is compiled without --enable-jit. We will auto-detect
# whether the version of the PCRE v1 library in use has JIT support at
# all, but we unfortunately can't auto-detect whether JIT support
# hasn't been compiled in in an otherwise JIT-supporting version. If
# you have link-time errors about a missing `pcre_jit_exec` define
# this, or recompile PCRE v1 with --enable-jit.
# When using USE_LIBPCRE1, define NO_LIBPCRE1_JIT if you want to
# disable JIT even if supported by your library.
#
# Define LIBPCREDIR=/foo/bar if your PCRE header and library files are
# in /foo/bar/include and /foo/bar/lib directories. Which version of


+ 10
- 6
grep.c View File

@@ -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


+ 0
- 11
grep.h View File

@@ -6,17 +6,6 @@
#ifndef PCRE_NO_UTF8_CHECK
#define PCRE_NO_UTF8_CHECK 0
#endif
#ifdef PCRE_CONFIG_JIT
#if PCRE_MAJOR >= 8 && PCRE_MINOR >= 32
#ifndef NO_LIBPCRE1_JIT
#define GIT_PCRE1_USE_JIT
#define GIT_PCRE_STUDY_JIT_COMPILE PCRE_STUDY_JIT_COMPILE
#endif
#endif
#endif
#ifndef GIT_PCRE_STUDY_JIT_COMPILE
#define GIT_PCRE_STUDY_JIT_COMPILE 0
#endif
#else
typedef int pcre;
typedef int pcre_extra;


Loading…
Cancel
Save