summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-02-10 22:48:33 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-02-10 22:48:33 (GMT)
commit0199c68d010b613bde2575cd54d8c3597431fc81 (patch)
treebface5b67ae70075c2e303bd947b54dbbb5f2aad /grep.c
parent938ecaa42f1be47b9bcaa947ecd6b04f9c1dc3db (diff)
parent7599730b7e2be694142bfb2e95187afa78a5404a (diff)
downloadgit-0199c68d010b613bde2575cd54d8c3597431fc81.zip
git-0199c68d010b613bde2575cd54d8c3597431fc81.tar.gz
git-0199c68d010b613bde2575cd54d8c3597431fc81.tar.bz2
Merge branch 'ab/retire-pcre1'
The support for deprecated PCRE1 library has been dropped. * ab/retire-pcre1: Remove support for v1 of the PCRE library config.mak.uname: remove redundant NO_LIBPCRE1_JIT flag
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c117
1 files changed, 2 insertions, 115 deletions
diff --git a/grep.c b/grep.c
index 21f0ee0..1acc23d 100644
--- a/grep.c
+++ b/grep.c
@@ -166,11 +166,6 @@ void grep_init(struct grep_opt *opt, struct repository *repo, const char *prefix
pcre2_malloc, pcre2_free, NULL);
#endif
-#ifdef USE_LIBPCRE1
- pcre_malloc = malloc;
- pcre_free = free;
-#endif
-
*opt = grep_defaults;
opt->repo = repo;
@@ -223,17 +218,7 @@ static void grep_set_pattern_type_option(enum grep_pattern_type pattern_type, st
break;
case GREP_PATTERN_TYPE_PCRE:
-#ifdef USE_LIBPCRE2
opt->pcre2 = 1;
-#else
- /*
- * It's important that pcre1 always be assigned to
- * even when there's no USE_LIBPCRE* defined. We still
- * call the PCRE stub function, it just dies with
- * "cannot use Perl-compatible regexes[...]".
- */
- opt->pcre1 = 1;
-#endif
break;
}
}
@@ -377,90 +362,6 @@ static int is_fixed(const char *s, size_t len)
return 1;
}
-#ifdef USE_LIBPCRE1
-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))
- p->pcre1_tables = pcre_maketables();
- options |= PCRE_CASELESS;
- }
- if (!opt->ignore_locale && is_utf8_locale() && has_non_ascii(p->pattern))
- options |= PCRE_UTF8;
-
- p->pcre1_regexp = pcre_compile(p->pattern, options, &error, &erroffset,
- p->pcre1_tables);
- if (!p->pcre1_regexp)
- compile_regexp_failed(p, error);
-
-#if defined(PCRE_CONFIG_JIT) && !defined(NO_LIBPCRE1_JIT)
- pcre_config(PCRE_CONFIG_JIT, &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,
- regmatch_t *match, int eflags)
-{
- int ovector[30], ret, flags = PCRE_NO_UTF8_CHECK;
-
- if (eflags & REG_NOTBOL)
- flags |= PCRE_NOTBOL;
-
- ret = pcre_exec(p->pcre1_regexp, p->pcre1_extra_info, line,
- eol - line, 0, flags, ovector,
- ARRAY_SIZE(ovector));
-
- if (ret < 0 && ret != PCRE_ERROR_NOMATCH)
- die("pcre_exec failed with error code %d", ret);
- if (ret > 0) {
- ret = 0;
- match->rm_so = ovector[0];
- match->rm_eo = ovector[1];
- }
-
- return ret;
-}
-
-static void free_pcre1_regexp(struct grep_pat *p)
-{
- pcre_free(p->pcre1_regexp);
-#ifdef PCRE_CONFIG_JIT
- if (p->pcre1_jit_on)
- pcre_free_study(p->pcre1_extra_info);
- else
-#endif
- pcre_free(p->pcre1_extra_info);
- pcre_free((void *)p->pcre1_tables);
-}
-#else /* !USE_LIBPCRE1 */
-static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)
-{
- die("cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE");
-}
-
-static int pcre1match(struct grep_pat *p, const char *line, const char *eol,
- regmatch_t *match, int eflags)
-{
- return 1;
-}
-
-static void free_pcre1_regexp(struct grep_pat *p)
-{
-}
-#endif /* !USE_LIBPCRE1 */
-
#ifdef USE_LIBPCRE2
static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt)
{
@@ -581,11 +482,6 @@ static void free_pcre2_pattern(struct grep_pat *p)
#else /* !USE_LIBPCRE2 */
static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt)
{
- /*
- * Unreachable until USE_LIBPCRE2 becomes synonymous with
- * USE_LIBPCRE. See the sibling comment in
- * grep_set_pattern_type_option().
- */
die("cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE");
}
@@ -684,11 +580,6 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
return;
}
- if (opt->pcre1) {
- compile_pcre1_regexp(p, opt);
- return;
- }
-
if (p->ignore_case)
regflags |= REG_ICASE;
if (opt->extended_regexp_option)
@@ -954,9 +845,7 @@ void free_grep_patterns(struct grep_opt *opt)
case GREP_PATTERN: /* atom */
case GREP_PATTERN_HEAD:
case GREP_PATTERN_BODY:
- if (p->pcre1_regexp)
- free_pcre1_regexp(p);
- else if (p->pcre2_pattern)
+ if (p->pcre2_pattern)
free_pcre2_pattern(p);
else
regfree(&p->regexp);
@@ -1019,9 +908,7 @@ static int patmatch(struct grep_pat *p, char *line, char *eol,
{
int hit;
- if (p->pcre1_regexp)
- hit = !pcre1match(p, line, eol, match, eflags);
- else if (p->pcre2_pattern)
+ if (p->pcre2_pattern)
hit = !pcre2match(p, line, eol, match, eflags);
else
hit = !regexec_buf(&p->regexp, line, eol - line, 1, match,