Skip to content

Commit 7599730

Browse files
avargitster
authored andcommitted
Remove support for v1 of the PCRE library
Remove support for using version 1 of the PCRE library. Its use has been discouraged by upstream for a long time, and it's in a bugfix-only state. Anyone who was relying on v1 in particular got a nudge to move to v2 in e6c531b (Makefile: make USE_LIBPCRE=YesPlease mean v2, not v1, 2018-03-11), which was first released as part of v2.18.0. With this the LIBPCRE2 test prerequisites is redundant to PCRE. But I'm keeping it for self-documentation purposes, and to avoid conflict with other in-flight PCRE patches. I'm also not changing all of our own "pcre2" names to "pcre", i.e. the inverse of 6d4b574 (grep: change internal *pcre* variable & function names to be *pcre1*, 2017-05-25). I don't see the point, and it makes the history/blame harder to read. Maybe if there's ever a PCRE v3... Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0205bb1 commit 7599730

File tree

7 files changed

+18
-217
lines changed

7 files changed

+18
-217
lines changed

Makefile

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,11 @@ all::
2929
# Perl-compatible regular expressions instead of standard or extended
3030
# POSIX regular expressions.
3131
#
32-
# USE_LIBPCRE is a synonym for USE_LIBPCRE2, define USE_LIBPCRE1
33-
# instead if you'd like to use the legacy version 1 of the PCRE
34-
# library. Support for version 1 will likely be removed in some future
35-
# release of Git, as upstream has all but abandoned it.
36-
#
37-
# When using USE_LIBPCRE1, define NO_LIBPCRE1_JIT if you want to
38-
# disable JIT even if supported by your library.
32+
# Only libpcre version 2 is supported. USE_LIBPCRE2 is a synonym for
33+
# USE_LIBPCRE, support for the old USE_LIBPCRE1 has been removed.
3934
#
4035
# Define LIBPCREDIR=/foo/bar if your PCRE header and library files are
41-
# in /foo/bar/include and /foo/bar/lib directories. Which version of
42-
# PCRE this points to determined by the USE_LIBPCRE1 and USE_LIBPCRE2
43-
# variables.
36+
# in /foo/bar/include and /foo/bar/lib directories.
4437
#
4538
# Define HAVE_ALLOCA_H if you have working alloca(3) defined in that header.
4639
#
@@ -1359,26 +1352,17 @@ ifdef NO_LIBGEN_H
13591352
COMPAT_OBJS += compat/basename.o
13601353
endif
13611354

1355+
ifdef USE_LIBPCRE1
1356+
$(error The USE_LIBPCRE1 build option has been removed, use version 2 with USE_LIBPCRE)
1357+
endif
1358+
13621359
USE_LIBPCRE2 ?= $(USE_LIBPCRE)
13631360

13641361
ifneq (,$(USE_LIBPCRE2))
1365-
ifdef USE_LIBPCRE1
1366-
$(error Only set USE_LIBPCRE2 (or its alias USE_LIBPCRE) or USE_LIBPCRE1, not both!)
1367-
endif
1368-
13691362
BASIC_CFLAGS += -DUSE_LIBPCRE2
13701363
EXTLIBS += -lpcre2-8
13711364
endif
13721365

1373-
ifdef USE_LIBPCRE1
1374-
BASIC_CFLAGS += -DUSE_LIBPCRE1
1375-
EXTLIBS += -lpcre
1376-
1377-
ifdef NO_LIBPCRE1_JIT
1378-
BASIC_CFLAGS += -DNO_LIBPCRE1_JIT
1379-
endif
1380-
endif
1381-
13821366
ifdef LIBPCREDIR
13831367
BASIC_CFLAGS += -I$(LIBPCREDIR)/include
13841368
EXTLIBS += -L$(LIBPCREDIR)/$(lib) $(CC_LD_DYNPATH)$(LIBPCREDIR)/$(lib)
@@ -2726,9 +2710,7 @@ GIT-BUILD-OPTIONS: FORCE
27262710
@echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@+
27272711
@echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@+
27282712
@echo NO_EXPAT=\''$(subst ','\'',$(subst ','\'',$(NO_EXPAT)))'\' >>$@+
2729-
@echo USE_LIBPCRE1=\''$(subst ','\'',$(subst ','\'',$(USE_LIBPCRE1)))'\' >>$@+
27302713
@echo USE_LIBPCRE2=\''$(subst ','\'',$(subst ','\'',$(USE_LIBPCRE2)))'\' >>$@+
2731-
@echo NO_LIBPCRE1_JIT=\''$(subst ','\'',$(subst ','\'',$(NO_LIBPCRE1_JIT)))'\' >>$@+
27322714
@echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@+
27332715
@echo NO_PTHREADS=\''$(subst ','\'',$(subst ','\'',$(NO_PTHREADS)))'\' >>$@+
27342716
@echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@+

configure.ac

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -252,16 +252,17 @@ GIT_PARSE_WITH([openssl]))
252252
# Define USE_LIBPCRE if you have and want to use libpcre. Various
253253
# commands such as log and grep offer runtime options to use
254254
# Perl-compatible regular expressions instead of standard or extended
255-
# POSIX regular expressions.
256-
#
257-
# USE_LIBPCRE is a synonym for USE_LIBPCRE2, define USE_LIBPCRE1
258-
# instead if you'd like to use the legacy version 1 of the PCRE
259-
# library. Support for version 1 will likely be removed in some future
260-
# release of Git, as upstream has all but abandoned it.
255+
# POSIX regular expressions. Only libpcre version 2 is supported.
261256
#
262257
# Define LIBPCREDIR=/foo/bar if your PCRE header and library files are in
263258
# /foo/bar/include and /foo/bar/lib directories.
264259
#
260+
261+
AC_ARG_WITH(libpcre1,
262+
AS_HELP_STRING([--with-libpcre1],[DEPRECATED]),
263+
AC_MSG_ERROR([support for --with-libpcre1 has been removed. Use --with-libpcre2!])
264+
)
265+
265266
AC_ARG_WITH(libpcre,
266267
AS_HELP_STRING([--with-libpcre],[synonym for --with-libpcre2]),
267268
if test "$withval" = "no"; then
@@ -277,33 +278,13 @@ AS_HELP_STRING([--with-libpcre],[synonym for --with-libpcre2]),
277278
GIT_CONF_SUBST([LIBPCREDIR])
278279
fi)
279280

280-
AC_ARG_WITH(libpcre1,
281-
AS_HELP_STRING([--with-libpcre1],[support Perl-compatible regexes via libpcre1 (default is NO)])
282-
AS_HELP_STRING([], [ARG can be also prefix for libpcre library and headers]),
283-
if test "$withval" = "no"; then
284-
USE_LIBPCRE1=
285-
elif test "$withval" = "yes"; then
286-
USE_LIBPCRE1=YesPlease
287-
else
288-
USE_LIBPCRE1=YesPlease
289-
LIBPCREDIR=$withval
290-
AC_MSG_NOTICE([Setting LIBPCREDIR to $LIBPCREDIR])
291-
dnl USE_LIBPCRE1 can still be modified below, so don't substitute
292-
dnl it yet.
293-
GIT_CONF_SUBST([LIBPCREDIR])
294-
fi)
295-
296281
AC_ARG_WITH(libpcre2,
297282
AS_HELP_STRING([--with-libpcre2],[support Perl-compatible regexes via libpcre2 (default is NO)])
298283
AS_HELP_STRING([], [ARG can be also prefix for libpcre library and headers]),
299284
if test -n "$USE_LIBPCRE2"; then
300285
AC_MSG_ERROR([Only supply one of --with-libpcre or its synonym --with-libpcre2!])
301286
fi
302287

303-
if test -n "$USE_LIBPCRE1"; then
304-
AC_MSG_ERROR([Only supply one of --with-libpcre1 or --with-libpcre2!])
305-
fi
306-
307288
if test "$withval" = "no"; then
308289
USE_LIBPCRE2=
309290
elif test "$withval" = "yes"; then
@@ -554,25 +535,9 @@ GIT_CONF_SUBST([NEEDS_SSL_WITH_CRYPTO])
554535
GIT_CONF_SUBST([NO_OPENSSL])
555536

556537
#
557-
# Handle the USE_LIBPCRE1 and USE_LIBPCRE2 options potentially set
558-
# above.
538+
# Handle the USE_LIBPCRE options potentially set above.
559539
#
560540

561-
if test -n "$USE_LIBPCRE1"; then
562-
563-
GIT_STASH_FLAGS($LIBPCREDIR)
564-
565-
AC_CHECK_LIB([pcre], [pcre_version],
566-
[USE_LIBPCRE1=YesPlease],
567-
[USE_LIBPCRE1=])
568-
569-
GIT_UNSTASH_FLAGS($LIBPCREDIR)
570-
571-
GIT_CONF_SUBST([USE_LIBPCRE1])
572-
573-
fi
574-
575-
576541
if test -n "$USE_LIBPCRE2"; then
577542

578543
GIT_STASH_FLAGS($LIBPCREDIR)

contrib/buildsystems/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -910,9 +910,7 @@ set(PYTHON_PATH /usr/bin/python)
910910
set(TAR tar)
911911
set(NO_CURL )
912912
set(NO_EXPAT )
913-
set(USE_LIBPCRE1 )
914913
set(USE_LIBPCRE2 )
915-
set(NO_LIBPCRE1_JIT )
916914
set(NO_PERL )
917915
set(NO_PTHREADS )
918916
set(NO_PYTHON )
@@ -949,8 +947,6 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\
949947
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
950948
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
951949
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
952-
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "USE_LIBPCRE1='${USE_LIBPCRE1}'\n")
953-
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\n")
954950
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
955951
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
956952
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")

grep.c

Lines changed: 2 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,6 @@ void grep_init(struct grep_opt *opt, struct repository *repo, const char *prefix
166166
pcre2_malloc, pcre2_free, NULL);
167167
#endif
168168

169-
#ifdef USE_LIBPCRE1
170-
pcre_malloc = malloc;
171-
pcre_free = free;
172-
#endif
173-
174169
*opt = grep_defaults;
175170

176171
opt->repo = repo;
@@ -223,17 +218,7 @@ static void grep_set_pattern_type_option(enum grep_pattern_type pattern_type, st
223218
break;
224219

225220
case GREP_PATTERN_TYPE_PCRE:
226-
#ifdef USE_LIBPCRE2
227221
opt->pcre2 = 1;
228-
#else
229-
/*
230-
* It's important that pcre1 always be assigned to
231-
* even when there's no USE_LIBPCRE* defined. We still
232-
* call the PCRE stub function, it just dies with
233-
* "cannot use Perl-compatible regexes[...]".
234-
*/
235-
opt->pcre1 = 1;
236-
#endif
237222
break;
238223
}
239224
}
@@ -377,92 +362,6 @@ static int is_fixed(const char *s, size_t len)
377362
return 1;
378363
}
379364

380-
#ifdef USE_LIBPCRE1
381-
static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)
382-
{
383-
const char *error;
384-
int erroffset;
385-
int options = PCRE_MULTILINE;
386-
int study_options = 0;
387-
388-
if (opt->ignore_case) {
389-
if (!opt->ignore_locale && has_non_ascii(p->pattern))
390-
p->pcre1_tables = pcre_maketables();
391-
options |= PCRE_CASELESS;
392-
}
393-
if (!opt->ignore_locale && is_utf8_locale() && has_non_ascii(p->pattern))
394-
options |= PCRE_UTF8;
395-
396-
p->pcre1_regexp = pcre_compile(p->pattern, options, &error, &erroffset,
397-
p->pcre1_tables);
398-
if (!p->pcre1_regexp)
399-
compile_regexp_failed(p, error);
400-
401-
#if defined(PCRE_CONFIG_JIT) && !defined(NO_LIBPCRE1_JIT)
402-
pcre_config(PCRE_CONFIG_JIT, &p->pcre1_jit_on);
403-
if (opt->debug)
404-
fprintf(stderr, "pcre1_jit_on=%d\n", p->pcre1_jit_on);
405-
406-
if (p->pcre1_jit_on)
407-
study_options = PCRE_STUDY_JIT_COMPILE;
408-
#endif
409-
410-
p->pcre1_extra_info = pcre_study(p->pcre1_regexp, study_options, &error);
411-
if (!p->pcre1_extra_info && error)
412-
die("%s", error);
413-
}
414-
415-
static int pcre1match(struct grep_pat *p, const char *line, const char *eol,
416-
regmatch_t *match, int eflags)
417-
{
418-
int ovector[30], ret, flags = PCRE_NO_UTF8_CHECK;
419-
420-
if (eflags & REG_NOTBOL)
421-
flags |= PCRE_NOTBOL;
422-
423-
ret = pcre_exec(p->pcre1_regexp, p->pcre1_extra_info, line,
424-
eol - line, 0, flags, ovector,
425-
ARRAY_SIZE(ovector));
426-
427-
if (ret < 0 && ret != PCRE_ERROR_NOMATCH)
428-
die("pcre_exec failed with error code %d", ret);
429-
if (ret > 0) {
430-
ret = 0;
431-
match->rm_so = ovector[0];
432-
match->rm_eo = ovector[1];
433-
}
434-
435-
return ret;
436-
}
437-
438-
static void free_pcre1_regexp(struct grep_pat *p)
439-
{
440-
pcre_free(p->pcre1_regexp);
441-
#ifdef PCRE_CONFIG_JIT
442-
if (p->pcre1_jit_on)
443-
pcre_free_study(p->pcre1_extra_info);
444-
else
445-
#endif
446-
pcre_free(p->pcre1_extra_info);
447-
pcre_free((void *)p->pcre1_tables);
448-
}
449-
#else /* !USE_LIBPCRE1 */
450-
static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)
451-
{
452-
die("cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE");
453-
}
454-
455-
static int pcre1match(struct grep_pat *p, const char *line, const char *eol,
456-
regmatch_t *match, int eflags)
457-
{
458-
return 1;
459-
}
460-
461-
static void free_pcre1_regexp(struct grep_pat *p)
462-
{
463-
}
464-
#endif /* !USE_LIBPCRE1 */
465-
466365
#ifdef USE_LIBPCRE2
467366
static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt)
468367
{
@@ -588,11 +487,6 @@ static void free_pcre2_pattern(struct grep_pat *p)
588487
#else /* !USE_LIBPCRE2 */
589488
static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt)
590489
{
591-
/*
592-
* Unreachable until USE_LIBPCRE2 becomes synonymous with
593-
* USE_LIBPCRE. See the sibling comment in
594-
* grep_set_pattern_type_option().
595-
*/
596490
die("cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE");
597491
}
598492

@@ -693,11 +587,6 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
693587
return;
694588
}
695589

696-
if (opt->pcre1) {
697-
compile_pcre1_regexp(p, opt);
698-
return;
699-
}
700-
701590
if (p->ignore_case)
702591
regflags |= REG_ICASE;
703592
if (opt->extended_regexp_option)
@@ -1051,9 +940,7 @@ void free_grep_patterns(struct grep_opt *opt)
1051940
case GREP_PATTERN: /* atom */
1052941
case GREP_PATTERN_HEAD:
1053942
case GREP_PATTERN_BODY:
1054-
if (p->pcre1_regexp)
1055-
free_pcre1_regexp(p);
1056-
else if (p->pcre2_pattern)
943+
if (p->pcre2_pattern)
1057944
free_pcre2_pattern(p);
1058945
else
1059946
regfree(&p->regexp);
@@ -1116,9 +1003,7 @@ static int patmatch(struct grep_pat *p, char *line, char *eol,
11161003
{
11171004
int hit;
11181005

1119-
if (p->pcre1_regexp)
1120-
hit = !pcre1match(p, line, eol, match, eflags);
1121-
else if (p->pcre2_pattern)
1006+
if (p->pcre2_pattern)
11221007
hit = !pcre2match(p, line, eol, match, eflags);
11231008
else
11241009
hit = !regexec_buf(&p->regexp, line, eol - line, 1, match,

grep.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
#ifndef GREP_H
22
#define GREP_H
33
#include "color.h"
4-
#ifdef USE_LIBPCRE1
5-
#include <pcre.h>
6-
#ifndef PCRE_NO_UTF8_CHECK
7-
#define PCRE_NO_UTF8_CHECK 0
8-
#endif
9-
#else
10-
typedef int pcre;
11-
typedef int pcre_extra;
12-
#endif
134
#ifdef USE_LIBPCRE2
145
#define PCRE2_CODE_UNIT_WIDTH 8
156
#include <pcre2.h>
@@ -71,10 +62,6 @@ struct grep_pat {
7162
size_t patternlen;
7263
enum grep_header_field field;
7364
regex_t regexp;
74-
pcre *pcre1_regexp;
75-
pcre_extra *pcre1_extra_info;
76-
const unsigned char *pcre1_tables;
77-
int pcre1_jit_on;
7865
pcre2_code *pcre2_pattern;
7966
pcre2_match_data *pcre2_match_data;
8067
pcre2_compile_context *pcre2_compile_context;
@@ -144,7 +131,6 @@ struct grep_opt {
144131
int allow_textconv;
145132
int extended;
146133
int use_reflog_filter;
147-
int pcre1;
148134
int pcre2;
149135
int relative;
150136
int pathname;

t/README

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,18 +1104,6 @@ use these, and "test_set_prereq" for how to define your own.
11041104
Git was compiled with support for PCRE. Wrap any tests
11051105
that use git-grep --perl-regexp or git-grep -P in these.
11061106

1107-
- LIBPCRE1
1108-
1109-
Git was compiled with PCRE v1 support via
1110-
USE_LIBPCRE1=YesPlease. Wrap any PCRE using tests that for some
1111-
reason need v1 of the PCRE library instead of v2 in these.
1112-
1113-
- LIBPCRE2
1114-
1115-
Git was compiled with PCRE v2 support via
1116-
USE_LIBPCRE2=YesPlease. Wrap any PCRE using tests that for some
1117-
reason need v2 of the PCRE library instead of v1 in these.
1118-
11191107
- CASE_INSENSITIVE_FS
11201108

11211109
Test is run on a case insensitive file system.

t/test-lib.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,8 +1524,7 @@ esac
15241524
test -z "$NO_PERL" && test_set_prereq PERL
15251525
test -z "$NO_PTHREADS" && test_set_prereq PTHREADS
15261526
test -z "$NO_PYTHON" && test_set_prereq PYTHON
1527-
test -n "$USE_LIBPCRE1$USE_LIBPCRE2" && test_set_prereq PCRE
1528-
test -n "$USE_LIBPCRE1" && test_set_prereq LIBPCRE1
1527+
test -n "$USE_LIBPCRE2" && test_set_prereq PCRE
15291528
test -n "$USE_LIBPCRE2" && test_set_prereq LIBPCRE2
15301529
test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
15311530

0 commit comments

Comments
 (0)