forked from pool/coccinelle
See included changes.txt for details - use coccinelle.patch to link to ocaml-pcre2 - remove unused kill-env.diff - add optional testsuite package OBS-URL: https://build.opensuse.org/package/show/devel:tools/coccinelle?expand=0&rev=97
306 lines
12 KiB
Diff
306 lines
12 KiB
Diff
From: Olaf Hering <olaf@aepfle.de>
|
|
Date: Mon, 17 Mar 2025 15:06:53 +0000
|
|
Subject: replace pcre with pcre2
|
|
|
|
Since pcre is unmaintained, the usage of ocaml-pcre will be replaced
|
|
with ocaml-pcre2. While other regular expession libraries for OCaml
|
|
exists, they are not as feature complete as pcre2 is.
|
|
|
|
This is the minimal change to use the system ocaml-pcre2. To reduce the
|
|
size of this patch, a separate commit might be required to import
|
|
pcre2-ocaml.git into bundles and use it in the build system.
|
|
|
|
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
|
---
|
|
Makefile | 4 ++--
|
|
Makefile.config.in | 18 +++++++++---------
|
|
Makefile.libs | 18 +++++++++---------
|
|
coccinelle.opam | 2 +-
|
|
configure.ac | 16 ++++++++--------
|
|
globals/regexp_pcre.ml | 6 +++---
|
|
install.txt | 16 ++++++++--------
|
|
setup/fake-subst.sh | 6 +++---
|
|
8 files changed, 43 insertions(+), 43 deletions(-)
|
|
|
|
diff --git a/Makefile b/Makefile
|
|
--- a/Makefile
|
|
+++ b/Makefile
|
|
@@ -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
|
|
@@ -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 \
|
|
diff --git a/Makefile.config.in b/Makefile.config.in
|
|
--- a/Makefile.config.in
|
|
+++ b/Makefile.config.in
|
|
@@ -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@
|
|
\ No newline at end of file
|
|
+OCAMLATLEAST50=@OCAMLATLEAST50@
|
|
diff --git a/Makefile.libs b/Makefile.libs
|
|
--- a/Makefile.libs
|
|
+++ b/Makefile.libs
|
|
@@ -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 =
|
|
diff --git a/coccinelle.opam b/coccinelle.opam
|
|
--- a/coccinelle.opam
|
|
+++ b/coccinelle.opam
|
|
@@ -18,7 +18,7 @@ depends: [
|
|
"ocaml"
|
|
"menhir"
|
|
"ocamlfind"
|
|
- "pcre"
|
|
+ "pcre2"
|
|
"stdcompat"
|
|
"pyml" { >= "20171117" }
|
|
"conf-pkg-config"
|
|
diff --git a/configure.ac b/configure.ac
|
|
--- a/configure.ac
|
|
+++ b/configure.ac
|
|
@@ -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], [])],
|
|
@@ -634,7 +634,7 @@ python scripting: $enable_python (overridable with --enable-python)
|
|
|
|
pcre regexes: $enable_pcre_syntax (overridable with --enable-pcre-syntax)
|
|
pcre module: $enable_pcre (for local package use --disable-pcre)
|
|
-pcre library: $HAVE_PCRE (requires the libpcre-ocaml-dev package)
|
|
+pcre library: $HAVE_PCRE (requires the libpcre2-ocaml-dev package)
|
|
|
|
optimized spatch: $enable_opt (overridable with --disable-opt)
|
|
|
|
diff --git a/globals/regexp_pcre.ml b/globals/regexp_pcre.ml
|
|
--- a/globals/regexp_pcre.ml
|
|
+++ b/globals/regexp_pcre.ml
|
|
@@ -5,7 +5,7 @@
|
|
*)
|
|
|
|
type regexp =
|
|
- Pcre of int (* Pcre.regexp *)
|
|
+ Pcre of int (* Pcre2.regexp *)
|
|
| Str of Str.regexp
|
|
|
|
(* A table is used because PCRE regular expressions are not comparable.
|
|
@@ -26,7 +26,7 @@ let regexp string =
|
|
begin
|
|
let c = !pcre_ctr in
|
|
pcre_ctr := !pcre_ctr + 1;
|
|
- Hashtbl.add pcre_table c (Pcre.regexp string);
|
|
+ Hashtbl.add pcre_table c (Pcre2.regexp string);
|
|
Pcre c
|
|
end
|
|
else Str (Str.regexp string)
|
|
@@ -35,7 +35,7 @@ let string_match regexp string =
|
|
match regexp with
|
|
Pcre 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);
|
|
diff --git a/install.txt b/install.txt
|
|
--- a/install.txt
|
|
+++ b/install.txt
|
|
@@ -30,13 +30,13 @@ On Debian/Ubuntu, install the following packages:
|
|
If you do not install libparmap-ocaml-dev, then you will automatically use
|
|
the bundle instead. However, if you used opam to switch to a different
|
|
version of OCaml, you must uninstall libparmap-ocaml-dev.
|
|
- - libpcre-ocaml-dev (optional, for PCRE support, bundled)
|
|
- If you do not install libpcre-ocaml-dev, then you will automatically use the
|
|
+ - libpcre2-ocaml-dev (optional, for PCRE support, bundled)
|
|
+ If you do not install libpcre2-ocaml-dev, then you will automatically use the
|
|
bundle instead. However, in order for the bundle to work, you also need:
|
|
- - libpcre3-dev (optional, not bundled)
|
|
+ - libpcre2-dev (optional, not bundled)
|
|
Additionally, if you used opam to switch to a different version of OCaml and
|
|
- want PCRE support, then make sure you have libpcre-ocaml-dev uninstalled and
|
|
- libpcre3-dev installed, otherwise Coccinelle will not compile.
|
|
+ want PCRE support, then make sure you have libpcre2-ocaml-dev uninstalled and
|
|
+ libpcre2-dev installed, otherwise Coccinelle will not compile.
|
|
|
|
On Fedora, install the following packages:
|
|
- automake
|
|
@@ -47,16 +47,16 @@ On Fedora, install the following packages:
|
|
- ocaml-findlib-devel
|
|
- ocaml-ocamldoc
|
|
- ocaml-menhir (optional, bundled)
|
|
- - ocaml-pcre-devel (optional, bundled)
|
|
+ - ocaml-pcre2-devel (optional, bundled)
|
|
Note: if you used opam to switch to a different version of OCaml, installing
|
|
- ocaml-pcre-devel will make compilation impossible. Additionally, PCRE
|
|
+ ocaml-pcre2-devel will make compilation impossible. Additionally, PCRE
|
|
support and OCaml scripting will be impossible.
|
|
If you want Python scripting: Coccinelle is not compatible with Python 3.13,
|
|
which is the default on Fedora as of 2024-12-19. Consider switching to Python
|
|
3.12, for example.
|
|
|
|
On Arch Linux, install the following packages:
|
|
-$ pacman -Syu pkg-config ocaml ocaml-findlib autoconf automake pcre make
|
|
+$ pacman -Syu pkg-config ocaml ocaml-findlib autoconf automake pcre2 make
|
|
as well as the C compiler of your choice.
|
|
Note: if you used opam to switch to a different version of OCaml, OCaml
|
|
scripting will be impossible.
|
|
diff --git a/setup/fake-subst.sh b/setup/fake-subst.sh
|
|
--- a/setup/fake-subst.sh
|
|
+++ b/setup/fake-subst.sh
|
|
@@ -19,7 +19,7 @@ set -e
|
|
# the next lines in the file.
|
|
|
|
# the replies file assumes that the
|
|
-# libpcre and python libraries are installed, and
|
|
+# libpcre2 and python libraries are installed, and
|
|
# that none of the optional ocaml libraries are
|
|
# installed.
|
|
|
|
@@ -102,9 +102,9 @@ pythonlibs() {
|
|
echo "-L${prefix}/lib -lpython${version}"
|
|
}
|
|
|
|
-# succeeds only if "/usr/include/pcre.h" exists
|
|
+# succeeds only if "/usr/include/pcre2.h" exists
|
|
checkpcre() {
|
|
- test -f /usr/include/pcre.h
|
|
+ test -f /usr/include/pcre2.h
|
|
}
|
|
|
|
# iterate through pattern-response pairs
|
|
|
|
base-commit: d9064ec494fa1572abc4b1e26984246ce902b7aa
|