Skip to content

Commit 0199c68

Browse files
committed
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
2 parents 938ecaa + 7599730 commit 0199c68

File tree

8 files changed

+18
-216
lines changed

8 files changed

+18
-216
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
#
@@ -1360,26 +1353,17 @@ ifdef NO_LIBGEN_H
13601353
COMPAT_OBJS += compat/basename.o
13611354
endif
13621355

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

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

1374-
ifdef USE_LIBPCRE1
1375-
BASIC_CFLAGS += -DUSE_LIBPCRE1
1376-
EXTLIBS += -lpcre
1377-
1378-
ifdef NO_LIBPCRE1_JIT
1379-
BASIC_CFLAGS += -DNO_LIBPCRE1_JIT
1380-
endif
1381-
endif
1382-
13831367
ifdef LIBPCREDIR
13841368
BASIC_CFLAGS += -I$(LIBPCREDIR)/include
13851369
EXTLIBS += -L$(LIBPCREDIR)/$(lib) $(CC_LD_DYNPATH)$(LIBPCREDIR)/$(lib)
@@ -2727,9 +2711,7 @@ GIT-BUILD-OPTIONS: FORCE
27272711
@echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@+
27282712
@echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@+
27292713
@echo NO_EXPAT=\''$(subst ','\'',$(subst ','\'',$(NO_EXPAT)))'\' >>$@+
2730-
@echo USE_LIBPCRE1=\''$(subst ','\'',$(subst ','\'',$(USE_LIBPCRE1)))'\' >>$@+
27312714
@echo USE_LIBPCRE2=\''$(subst ','\'',$(subst ','\'',$(USE_LIBPCRE2)))'\' >>$@+
2732-
@echo NO_LIBPCRE1_JIT=\''$(subst ','\'',$(subst ','\'',$(NO_LIBPCRE1_JIT)))'\' >>$@+
27332715
@echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@+
27342716
@echo NO_PTHREADS=\''$(subst ','\'',$(subst ','\'',$(NO_PTHREADS)))'\' >>$@+
27352717
@echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@+

config.mak.uname

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,6 @@ else
664664
NO_GETTEXT =
665665
USE_GETTEXT_SCHEME = fallthrough
666666
USE_LIBPCRE= YesPlease
667-
NO_LIBPCRE1_JIT = UnfortunatelyYes
668667
NO_CURL =
669668
USE_NED_ALLOCATOR = YesPlease
670669
else

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 & 115 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,90 +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-
404-
if (p->pcre1_jit_on)
405-
study_options = PCRE_STUDY_JIT_COMPILE;
406-
#endif
407-
408-
p->pcre1_extra_info = pcre_study(p->pcre1_regexp, study_options, &error);
409-
if (!p->pcre1_extra_info && error)
410-
die("%s", error);
411-
}
412-
413-
static int pcre1match(struct grep_pat *p, const char *line, const char *eol,
414-
regmatch_t *match, int eflags)
415-
{
416-
int ovector[30], ret, flags = PCRE_NO_UTF8_CHECK;
417-
418-
if (eflags & REG_NOTBOL)
419-
flags |= PCRE_NOTBOL;
420-
421-
ret = pcre_exec(p->pcre1_regexp, p->pcre1_extra_info, line,
422-
eol - line, 0, flags, ovector,
423-
ARRAY_SIZE(ovector));
424-
425-
if (ret < 0 && ret != PCRE_ERROR_NOMATCH)
426-
die("pcre_exec failed with error code %d", ret);
427-
if (ret > 0) {
428-
ret = 0;
429-
match->rm_so = ovector[0];
430-
match->rm_eo = ovector[1];
431-
}
432-
433-
return ret;
434-
}
435-
436-
static void free_pcre1_regexp(struct grep_pat *p)
437-
{
438-
pcre_free(p->pcre1_regexp);
439-
#ifdef PCRE_CONFIG_JIT
440-
if (p->pcre1_jit_on)
441-
pcre_free_study(p->pcre1_extra_info);
442-
else
443-
#endif
444-
pcre_free(p->pcre1_extra_info);
445-
pcre_free((void *)p->pcre1_tables);
446-
}
447-
#else /* !USE_LIBPCRE1 */
448-
static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)
449-
{
450-
die("cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE");
451-
}
452-
453-
static int pcre1match(struct grep_pat *p, const char *line, const char *eol,
454-
regmatch_t *match, int eflags)
455-
{
456-
return 1;
457-
}
458-
459-
static void free_pcre1_regexp(struct grep_pat *p)
460-
{
461-
}
462-
#endif /* !USE_LIBPCRE1 */
463-
464365
#ifdef USE_LIBPCRE2
465366
static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt)
466367
{
@@ -581,11 +482,6 @@ static void free_pcre2_pattern(struct grep_pat *p)
581482
#else /* !USE_LIBPCRE2 */
582483
static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt)
583484
{
584-
/*
585-
* Unreachable until USE_LIBPCRE2 becomes synonymous with
586-
* USE_LIBPCRE. See the sibling comment in
587-
* grep_set_pattern_type_option().
588-
*/
589485
die("cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE");
590486
}
591487

@@ -684,11 +580,6 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
684580
return;
685581
}
686582

687-
if (opt->pcre1) {
688-
compile_pcre1_regexp(p, opt);
689-
return;
690-
}
691-
692583
if (p->ignore_case)
693584
regflags |= REG_ICASE;
694585
if (opt->extended_regexp_option)
@@ -954,9 +845,7 @@ void free_grep_patterns(struct grep_opt *opt)
954845
case GREP_PATTERN: /* atom */
955846
case GREP_PATTERN_HEAD:
956847
case GREP_PATTERN_BODY:
957-
if (p->pcre1_regexp)
958-
free_pcre1_regexp(p);
959-
else if (p->pcre2_pattern)
848+
if (p->pcre2_pattern)
960849
free_pcre2_pattern(p);
961850
else
962851
regfree(&p->regexp);
@@ -1019,9 +908,7 @@ static int patmatch(struct grep_pat *p, char *line, char *eol,
1019908
{
1020909
int hit;
1021910

1022-
if (p->pcre1_regexp)
1023-
hit = !pcre1match(p, line, eol, match, eflags);
1024-
else if (p->pcre2_pattern)
911+
if (p->pcre2_pattern)
1025912
hit = !pcre2match(p, line, eol, match, eflags);
1026913
else
1027914
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;
@@ -143,7 +130,6 @@ struct grep_opt {
143130
int allow_textconv;
144131
int extended;
145132
int use_reflog_filter;
146-
int pcre1;
147133
int pcre2;
148134
int relative;
149135
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.

0 commit comments

Comments
 (0)