All of lore.kernel.org
 help / color / mirror / Atom feed
* [cocci] [PATCH v1] replace pcre with pcre2
@ 2025-03-17 15:08 Olaf Hering
  2025-03-17 16:17 ` [cocci] [PATCH] " Markus Elfring
  2025-03-17 17:26 ` Markus Elfring
  0 siblings, 2 replies; 6+ messages in thread
From: Olaf Hering @ 2025-03-17 15:08 UTC (permalink / raw)
  To: cocci

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.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 Makefile               |  6 +++---
 Makefile.config.in     | 18 +++++++++---------
 Makefile.libs          | 18 +++++++++---------
 configure.ac           | 14 +++++++-------
 globals/regexp_pcre.ml | 10 +++++-----
 5 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/Makefile b/Makefile
index 55dbe849a..0c45127bd 100644
--- 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
@@ -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 \
diff --git a/Makefile.config.in b/Makefile.config.in
index dbafa35a5..6bad1a7a6 100644
--- 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
index 96e05d26f..ed6ce302f 100644
--- 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/configure.ac b/configure.ac
index f0c585329..234d46fb4 100644
--- 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], [])],
diff --git a/globals/regexp_pcre.ml b/globals/regexp_pcre.ml
index d09f8528f..4fa1b61b5 100644
--- a/globals/regexp_pcre.ml
+++ b/globals/regexp_pcre.ml
@@ -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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [cocci] [PATCH] replace pcre with pcre2
  2025-03-17 15:08 [cocci] [PATCH v1] replace pcre with pcre2 Olaf Hering
@ 2025-03-17 16:17 ` Markus Elfring
  2025-03-17 17:26 ` Markus Elfring
  1 sibling, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2025-03-17 16:17 UTC (permalink / raw)
  To: Olaf Hering, cocci

>                                           … 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cocci] [PATCH] replace pcre with pcre2
  2025-03-17 15:08 [cocci] [PATCH v1] replace pcre with pcre2 Olaf Hering
  2025-03-17 16:17 ` [cocci] [PATCH] " Markus Elfring
@ 2025-03-17 17:26 ` Markus Elfring
  2025-03-17 17:44   ` Olaf Hering
  2025-03-17 22:24   ` Olaf Hering
  1 sibling, 2 replies; 6+ messages in thread
From: Markus Elfring @ 2025-03-17 17:26 UTC (permalink / raw)
  To: Olaf Hering, cocci

> 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.


>                                                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>  configure.ac           | 14 +++++++-------
> +++ 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cocci] [PATCH] replace pcre with pcre2
  2025-03-17 17:26 ` Markus Elfring
@ 2025-03-17 17:44   ` Olaf Hering
  2025-03-17 22:24   ` Olaf Hering
  1 sibling, 0 replies; 6+ messages in thread
From: Olaf Hering @ 2025-03-17 17:44 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci

[-- Attachment #1: Type: text/plain, Size: 349 bytes --]

Mon, 17 Mar 2025 18:26:32 +0100 Markus Elfring <Markus.Elfring@web.de>:

> 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

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cocci] [PATCH] replace pcre with pcre2
  2025-03-17 17:26 ` Markus Elfring
  2025-03-17 17:44   ` Olaf Hering
@ 2025-03-17 22:24   ` Olaf Hering
  2025-03-18 10:55     ` [cocci] " Markus Elfring
  1 sibling, 1 reply; 6+ messages in thread
From: Olaf Hering @ 2025-03-17 22:24 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci

[-- Attachment #1: Type: text/plain, Size: 223 bytes --]

Mon, 17 Mar 2025 18:26:32 +0100 Markus Elfring <Markus.Elfring@web.de>:

> https://github.com/coccinelle/coccinelle/issues/149

This was closed as completed. Was this closed prematurely, where is pcre2 used?


Olaf

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cocci] replace pcre with pcre2
  2025-03-17 22:24   ` Olaf Hering
@ 2025-03-18 10:55     ` Markus Elfring
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2025-03-18 10:55 UTC (permalink / raw)
  To: Olaf Hering, cocci

>> https://github.com/coccinelle/coccinelle/issues/149
>
> This was closed as completed. Was this closed prematurely,

Change interests and available development resources might not fit together so far.


> where is pcre2 used?
See also:
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/4093aad2da23ea5c86916de0a71f43032fc2bb2f/docs/manual/cocci_syntax.tex#L543-545

Regards,
Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-03-18 10:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-17 15:08 [cocci] [PATCH v1] replace pcre with pcre2 Olaf Hering
2025-03-17 16:17 ` [cocci] [PATCH] " Markus Elfring
2025-03-17 17:26 ` Markus Elfring
2025-03-17 17:44   ` Olaf Hering
2025-03-17 22:24   ` Olaf Hering
2025-03-18 10:55     ` [cocci] " Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.