replace pcre with pcre2
PATCH 1/1 replace pcre with pcre2
Since pcre is unmaintained, I was asked to remove usage of ocaml-pcre.
This is the minimal change to use ocaml-pcre2. The question is what kind of change the maintainers want to see here. There are 5 possible variantes to support regular expressions: Str.regex, Pcre, Pcre2, Re and Re2.
This patch just exchanges one with another. Would there be some benefit to support all five in a single binary, for correctness and/or performance comparison?
Please let me know how to proceed.
--- Makefile | 6 +++--- Makefile.config.in | 18 +++++++++--------- Makefile.libs | 18 +++++++++--------- configure.ac | 14 +++++++------- globals/regexp_pcre.ml | 10 +++++----- 5 files changed, 33 insertions(+), 33 deletions(-)
Makefile +3 -3
@@ -101,7 +101,7 @@ PREFIX_spgen := tools/spgen/source/ CORE_LIBS := unix str ocamlcommon \ $(STDCOMPATDIR)/stdcompat \ $(patsubst %,bytes,$(BYTESDIR)) \ - $(patsubst %,pcre,$(filter %/pcre.cma,$(LNKLIBS))) + $(patsubst %,pcre2,$(filter %/pcre2.cma,$(LNKLIBS))) ifeq ($(OCAMLATLEAST50),no) CORE_LIBS += bigarray
@@ -121,7 +121,7 @@ LIBRARIES_spatch := $(LIBRARIES) LIBRARIES_spgen := $(CORE_LIBRARIES) -CORE_BUNDLES=stdcompat menhirLib pcre +CORE_BUNDLES=stdcompat menhirLib pcre2 ALL_BUNDLES=$(CORE_BUNDLES) parmap pyml
@@ -214,7 +214,7 @@ MENHIR_LIB := \ $(addsuffix /menhirLib$(LIBSUFFIX),$(filter %/menhirLib,$(MAKELIBS))) PARMAP_LIB := $(addsuffix /parmap$(LIBSUFFIX),$(filter %/parmap,$(MAKELIBS))) PYML_LIB := $(addsuffix /pyml$(LIBSUFFIX),$(filter %/pyml,$(MAKELIBS))) -PCRE_LIB := $(addsuffix /pcre$(LIBSUFFIX),$(filter %/pcre,$(MAKELIBS))) +PCRE_LIB := $(addsuffix /pcre2$(LIBSUFFIX),$(filter %/pcre2,$(MAKELIBS))) STDCOMPAT_LIB := $(STDCOMPATDIR)/stdcompat$(LIBSUFFIX) STDCOMPAT_USERS := parsing_c/type_annoter_c cocci parsing_cocci/check_meta \
Makefile.config.in +9 -9
@@ -5,18 +5,18 @@ VERSION=@PACKAGE_VERSION@ # * for each library $1, add another entry in the same manner -MAKELIBS=@MAKE_dynlink@ @MAKE_menhirLib@ @MAKE_pyml@ @MAKE_pcre@ \ +MAKELIBS=@MAKE_dynlink@ @MAKE_menhirLib@ @MAKE_pyml@ @MAKE_pcre2@ \ @MAKE_parmap@ -LNKLIBS=@MODULES_dynlink@ @MODULES_menhirLib@ @MODULES_pcre@ @MODULES_pyml@ \ +LNKLIBS=@MODULES_dynlink@ @MODULES_menhirLib@ @MODULES_pcre2@ @MODULES_pyml@ \ @MODULES_parmap@ OPTLNKLIBS=@MODULESOPT_dynlink@ @MODULESOPT_menhirLib@ @MODULESOPT_pyml@ \ - @MODULESOPT_pcre@ @MODULESOPT_parmap@ -INCLIBS=@PATH_dynlink@ @PATH_menhirLib@ @PATH_pyml@ @PATH_pcre@ \ + @MODULESOPT_pcre2@ @MODULESOPT_parmap@ +INCLIBS=@PATH_dynlink@ @PATH_menhirLib@ @PATH_pyml@ @PATH_pcre2@ \ @PATH_parmap@ -FLAGSLIBS=@FLAGS_dynlink@ @FLAGS_menhirLib@ @FLAGS_pyml@ @FLAGS_pcre@ \ +FLAGSLIBS=@FLAGS_dynlink@ @FLAGS_menhirLib@ @FLAGS_pyml@ @FLAGS_pcre2@ \ @FLAGS_parmap@ OPTFLAGSLIBS=@OPTFLAGS_dynlink@ @OPTFLAGS_menhirLib@ @OPTFLAGS_pyml@ \ - @OPTFLAGS_pcre@ @OPTFLAGS_parmap@ + @OPTFLAGS_pcre2@ @OPTFLAGS_parmap@ # * end of library variables # system packages inc libs
@@ -106,7 +106,7 @@ METAINFO_DIR=@METAINFO_DIR@ # selected libraries FEATURE_menhirLib=@FEATURE_menhirLib@ -FEATURE_pcre=@FEATURE_pcre@ +FEATURE_pcre=@FEATURE_pcre2@ # Features FEATURE_PYTHON=@FEATURE_PYTHON@
@@ -114,7 +114,7 @@ FEATURE_OCAML=@FEATURE_OCAML@ NO_OCAMLFIND=@SUBSTITUTED_OCAMLFIND@ # Include paths -PCREDIR=@PATH_pcre@ +PCREDIR=@PATH_pcre2@ PARMAPDIR=@PATH_parmap@ PYMLDIR=@PATH_pyml@ MENHIRDIR=@PATH_menhirLib@
@@ -129,4 +129,4 @@ REGEXP_FILE=@REGEXP_FILE@ MENHIR_FLAGS=@DEFAULT_MENHIR_FLAGS@ -OCAMLATLEAST50=@OCAMLATLEAST50@ +OCAMLATLEAST50=@OCAMLATLEAST50@
Makefile.libs +9 -9
@@ -36,15 +36,15 @@ OPTFLAGS_pyml = $(CFLAGS_pyml:%=-ccopt %) -cclib -lpyml_stubs # pcre library # Note: see the comment of the pycaml library about the double appearance of the stubs library. -LOCAL_pcre = $(BYTESDIR:=/bytes.cma) $(PCREDIR)/pcre.cma -LOCALOPT_pcre = $(BYTESDIR:=/bytes.cmxa) $(PCREDIR)/pcre.cmxa -GLOBAL_pcre = $(BYTESDIR:=/bytes.cma) $(PCREDIR)/pcre.cma -GLOBALOPT_pcre = $(BYTESDIR:=/bytes.cmxa) $(PCREDIR)/pcre.cmxa -FLAGS_pcre = \ - $(PCRE_LIBS:%=-ccopt %) -cclib -L$(PCREDIR) -dllib -lpcre_stubs \ - -cclib -lpcre_stubs -OPTFLAGS_pcre = \ - $(PCRE_LIBS:%=-ccopt %) -cclib -L$(PCREDIR) -cclib -lpcre_stubs +LOCAL_pcre2 = $(BYTESDIR:=/bytes.cma) $(PCREDIR)/pcre2.cma +LOCALOPT_pcre2 = $(BYTESDIR:=/bytes.cmxa) $(PCREDIR)/pcre2.cmxa +GLOBAL_pcre2 = $(BYTESDIR:=/bytes.cma) $(PCREDIR)/pcre2.cma +GLOBALOPT_pcre2 = $(BYTESDIR:=/bytes.cmxa) $(PCREDIR)/pcre2.cmxa +FLAGS_pcre2 = \ + $(PCRE_LIBS:%=-ccopt %) -cclib -L$(PCREDIR) -dllib -lpcre2_stubs \ + -cclib -lpcre2_stubs +OPTFLAGS_pcre2 = \ + $(PCRE_LIBS:%=-ccopt %) -cclib -L$(PCREDIR) -cclib -lpcre2_stubs # dynlink library LOCAL_dynlink =
configure.ac +7 -7
@@ -145,7 +145,7 @@ dnl add a line for each package that is dnl configured via AC_CHECK_COCCI_EXTPKG dnl or AC_REQ_COCCI_EXTPKG AC_COCCI_INIT_PKG_EMPTY([dynlink]) -AC_COCCI_INIT_PKG_EMPTY([pcre]) +AC_COCCI_INIT_PKG_EMPTY([pcre2]) AC_COCCI_INIT_PKG_EMPTY([bytes]) dnl for recent versions of pcre on old OCaml AC_COCCI_INIT_PKG_EMPTY([pyml]) AC_COCCI_INIT_PKG_EMPTY([stdcompat])
@@ -369,18 +369,18 @@ dnl OCAML_PKG_pcre: if "local" use str package AC_ARG_ENABLE([pcre-syntax], AS_HELP_STRING([--enable-pcre-syntax], [enable pcre regular expression syntax (default: auto)])) AS_IF([test "x$enable_pcre_syntax" != "xno"], [dnl - PKG_CHECK_MODULES([PCRE], [libpcre],[AC_SUBST([HAVE_PCRE],[yes])],[AC_SUBST([HAVE_PCRE],[no])]) + PKG_CHECK_MODULES([PCRE], [libpcre2-8],[AC_SUBST([HAVE_PCRE],[yes])],[AC_SUBST([HAVE_PCRE],[no])]) AS_IF([test -z "$enable_pcre_syntax" -a "x$HAVE_PCRE" != xyes], [dnl AC_SUBST([enable_pcre_syntax], [no]) ], [dnl AS_IF([test "x$enable_pcre" = "xno"], [AC_SUBST([enable_pcre], [local])]) - AC_CHECK_COCCI_EXTPKG([pcre]) dnl will set $enable_pcre to 'yes', 'no', or 'local' + AC_CHECK_COCCI_EXTPKG([pcre2]) dnl will set $enable_pcre to 'yes', 'no', or 'local' AS_IF([test "x$enable_pcre" = "xyes"], [dnl AC_MSG_CHECKING([if pcre depends on bytes]) - AS_IF([test "x`$OCAMLFIND query -r -format '%p' pcre 2>/dev/null | grep bytes`" = "xbytes"], + AS_IF([test "x`$OCAMLFIND query -r -format '%p' pcre2 2>/dev/null | grep bytes`" = "xbytes"], [dnl AC_MSG_RESULT([yes]) AC_MSG_CHECKING([if bytes is an actual module])
@@ -407,14 +407,14 @@ AS_IF([test "x$enable_pcre_syntax" != xno], AC_MSG_NOTICE([support for pcre syntax is enabled]) ], [dnl - AC_MSG_ERROR([the pcre feature is enabled but the pkg-config libpcre library is not found]) + AC_MSG_ERROR([the pcre feature is enabled but the pkg-config libpcre2-8 library is not found]) ]) AC_SUBST([REGEXP_MODULE], [Regexp_pcre]) AC_SUBST([REGEXP_FILE], [regexp_pcre.ml]) ], [dnl - AC_COCCI_INIT_PKG_EMPTY([pcre]) + AC_COCCI_INIT_PKG_EMPTY([pcre2]) AC_SUBST([REGEXP_MODULE], [Regexp_str]) AC_SUBST([REGEXP_FILE], [regexp_str.ml]) ])
@@ -571,7 +571,7 @@ AS_IF([test "$MAKE_stdcompat"], AS_IF([test "$MAKE_parmap"], AC_CONFIG_SUBDIRS(bundles/parmap)) -AS_IF([test "$MAKE_pcre"], +AS_IF([test "$MAKE_pcre2"], [AS_IF([test "x$OCAMLATLEAST4030" = xno ], [AC_SUBST([CAMLnoreturn_start], []) AC_SUBST([CAMLnoreturn_end], [])],
globals/regexp_pcre.ml +5 -5
@@ -5,7 +5,7 @@ *) type regexp = - Pcre of int (* Pcre.regexp *) + Pcre2 of int (* Pcre2.regexp *) | Str of Str.regexp (* A table is used because PCRE regular expressions are not comparable.
@@ -26,16 +26,16 @@ let regexp string = begin let c = !pcre_ctr in pcre_ctr := !pcre_ctr + 1; - Hashtbl.add pcre_table c (Pcre.regexp string); - Pcre c + Hashtbl.add pcre_table c (Pcre2.regexp string); + Pcre2 c end else Str (Str.regexp string) let string_match regexp string = match regexp with - Pcre regexp -> + Pcre2 regexp -> let regexp = Hashtbl.find pcre_table regexp in - Pcre.pmatch ~rex:regexp string + Pcre2.pmatch ~rex:regexp string | Str regexp -> try ignore(Str.search_forward regexp string 0);
base-commit: cca22217d1b4316224e80a18d0b08dd351234497
Quoted 3 lines
… Would there be some benefit to
support all five in a single binary, for correctness and/or performance comparison?
I guess that this question can be reconsidered any more for a better change description. We usually hope that maintained software versions provide more desirable functionality (and corresponding run time characteristics).
Regards,
Markus
Quoted 3 lines
Since pcre is unmaintained, I was asked to remove usage of ocaml-pcre.
This is the minimal change to use ocaml-pcre2.
I suggest to reconsider this view a bit more.
Quoted 2 lines
The question is what kind
of change the maintainers want to see here.
I became also curious on corresponding collateral evolution.
Configuration possibilities for evaluation of regular expressions in SmPL constraints 2018-11-20
https://github.com/coccinelle/coccinelle/issues/149
…
Quoted 1 line
configure.ac | 14 +++++++-------
…
Quoted 1 line
+++ b/Makefile
I doubt that the adjustment of a make script is appropriate because such files should be regenerated by the software build system.
Regards,
Markus
Mon, 17 Mar 2025 18:26:32 +0100 Markus Elfring <[email protected]>:
Quoted 2 lines
I doubt that the adjustment of a make script is appropriate because such files should be regenerated by the software build system.
I'm all for removing generated files from a SCM, like it was done in 2ff738c7c63d9f2ac271d5864110efa99e6f10f4 for example.
Olaf
Mon, 17 Mar 2025 18:26:32 +0100 Markus Elfring <[email protected]>:
Quoted 1 line
This was closed as completed. Was this closed prematurely, where is pcre2 used?
Olaf
Quoted 3 lines
Quoted 1 line
This was closed as completed. Was this closed prematurely,
Change interests and available development resources might not fit together so far.
Quoted 1 line
where is pcre2 used?
Regards,
Markus