Bug#999931: virtuoso-opensource: depends on obsolete pcre3 library

2024-03-04 Thread Yavor Doganov
Hi Andreas,

On Wed, 28 Feb 2024 18:36:04 +0200,
Andreas Beckmann wrote:
> On Wed, 20 Dec 2023 21:18:20 +0200 Yavor Doganov  wrote:
> > Please find attached a patch;
> 
> Thanks for the patch, I uploaded it to Debian and so far noone
> complained ;-)

Thanks!  Complaints usually come a bit later...
 
> But the patch doesn't apply cleanly on newer virtuoso-opensource
> versions, there are actually changes in pcre usage in
> libsrc/Wi/sqlbif.h that require adjustments.

Right; there's a new function.

> Could you take a look again and update the patch?

Attached is a patch (commit made to the try-7.2.12 branch) that
updates pcre2.patch so that it applies cleanly and restores the
build-dependency on libpcre2-dev.

> I've never worked with (any version of) pcre (from the programmer
> persepective,

Likewise, I'm a complete novice here.  It would be nice to finish this
transition, though.
>From 82b97264413540aa72d96297a93a6fd24f56adc2 Mon Sep 17 00:00:00 2001
From: Yavor Doganov 
Date: Mon, 4 Mar 2024 16:29:34 +0200
Subject: [PATCH] pcre2.patch: Update for the new upstream release

---
 debian/changelog   |   4 +
 debian/control |   2 +-
 debian/patches/pcre2.patch | 152 -
 debian/patches/series  |   2 +-
 4 files changed, 107 insertions(+), 53 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 907e89fc6..a566f67f2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,12 @@
 virtuoso-opensource (7.2.12+dfsg-0.1) UNRELEASED; urgency=medium
 
+  [ Andreas Beckmann ]
   * Non-maintainer upload.
   * New upstream release.
 
+  [ Yavor Doganov ]
+  * debian/patches/pcre2.patch: Update for the new upstream release.
+
  -- Andreas Beckmann   Wed, 28 Feb 2024 15:19:59 +0100
 
 virtuoso-opensource (7.2.5.1+dfsg1-0.6) unstable; urgency=medium
diff --git a/debian/control b/debian/control
index 5fd05fab9..db9b573c4 100644
--- a/debian/control
+++ b/debian/control
@@ -14,7 +14,7 @@ Build-Depends: debhelper-compat (= 13),
gperf,
libldap2-dev,
libmagickwand-dev,
-   libpcre3-dev,
+   libpcre2-dev,
libreadline-dev,
libssl-dev,
libtirpc-dev,
diff --git a/debian/patches/pcre2.patch b/debian/patches/pcre2.patch
index 98c06be51..104c1abc9 100644
--- a/debian/patches/pcre2.patch
+++ b/debian/patches/pcre2.patch
@@ -2,12 +2,12 @@ Description: Port to PCRE2.
 Bug-Debian: https://bugs.debian.org/31
 Author: Yavor Doganov 
 Forwarded: no
-Last-Update: 2023-12-20
+Last-Update: 2024-03-04
 ---
 
 --- virtuoso-opensource.orig/libsrc/Wi/Makefile.am
 +++ virtuoso-opensource/libsrc/Wi/Makefile.am
-@@ -559,7 +559,7 @@
+@@ -563,7 +563,7 @@
$(libwi_base_la_sources)
  
  libwi_la_CFLAGS  = $(libwi_base_la_cflags)
@@ -18,7 +18,7 @@ Last-Update: 2023-12-20
  libwi_odbc_la_SOURCES += \
 --- virtuoso-opensource.orig/libsrc/Wi/bif_regexp.c
 +++ virtuoso-opensource/libsrc/Wi/bif_regexp.c
-@@ -30,7 +30,8 @@
+@@ -31,7 +31,8 @@
  
  // Debian maintainer: replaced by external PCRE
  // #include "util/pcrelib/pcre.h"
@@ -28,7 +28,7 @@ Last-Update: 2023-12-20
  
  /*
 typedef struct rx_query_s {
-@@ -66,15 +67,16 @@
+@@ -65,16 +66,17 @@
  typedef struct compiled_regexp_s
  {
int refctr;
@@ -42,14 +42,16 @@ Last-Update: 2023-12-20
  
 -int32 c_pcre_match_limit_recursion = 500;
 -int32 c_pcre_match_limit = 10;
+-int32 pcre_max_cache_sz = 2;
 +static pcre2_match_context *match_ctxt = NULL;
 +
 +uint32 c_pcre_match_limit_recursion = 500;
 +uint32 c_pcre_match_limit = 10;
- int32 pcre_max_cache_sz = 2;
++uint32 pcre_max_cache_sz = 2;
  int32 pcre_rnd_seed;
  
-@@ -97,6 +99,23 @@
+ id_hashed_key_t
+@@ -96,6 +98,23 @@
  }
  
  void
@@ -73,7 +75,7 @@ Last-Update: 2023-12-20
  release_compiled_regexp (id_hash_t *c_r, compiled_regexp_t *data)
  {
int delete_data;
-@@ -112,9 +131,7 @@
+@@ -111,9 +130,7 @@
if (!delete_data)
  return;
if (NULL != data->code)
@@ -84,7 +86,7 @@ Last-Update: 2023-12-20
dk_free (data, sizeof (compiled_regexp_t));
  }
  
-@@ -137,10 +154,11 @@
+@@ -136,10 +153,11 @@
  }
  
  static compiled_regexp_t *
@@ -99,9 +101,9 @@ Last-Update: 2023-12-20
regexp_key_t key;
compiled_regexp_t **val = NULL;
compiled_regexp_t tmp, *new_val;
-@@ -156,46 +174,18 @@
+@@ -155,46 +173,18 @@
  }
-   HT_LEAVE (c_r);
+   HT_UNLOCK (c_r);
dbg_printf (("regex compiling (%s) with options %x ...\n", pattern, 
options));
 -  tmp.code = pcre_compile (pattern, options, , , 0);
 +  tmp.code = pcre2_compile ((PCRE2_SPTR) pattern, strlen (pattern),
@@ -149,9 +151,9 @@ Last-Update: 2023-12-20
new_val->code = tmp.code;
 -  new_val->code_x = tmp.code_x;
new_val->refctr = 1;
-   HT_ENTER (c_r);
+   HT_WRLOCK (c_r);
pcre_cache_check (c_r);
-@@ -302,18 +292,18 @@
+@@ -301,18 +291,18 @@
  }
  
  
@@ -175,7 +177,7 @@ Last-Update: 2023-12-20
  /*
  #define PCRE_EXTENDED   0x0008
  

Bug#999931: virtuoso-opensource: depends on obsolete pcre3 library

2024-02-28 Thread Andreas Beckmann

Hi Yavor,

On Wed, 20 Dec 2023 21:18:20 +0200 Yavor Doganov  wrote:

Please find attached a patch; build-tested only (although the
package's own testsuite has some checks which test this
functionality).


Thanks for the patch, I uploaded it to Debian and so far noone 
complained ;-)


But the patch doesn't apply cleanly on newer virtuoso-opensource 
versions, there are actually changes in pcre usage in libsrc/Wi/sqlbif.h 
that require adjustments. Could you take a look again and update the 
patch? I've never worked with (any version of) pcre (from the programmer 
persepective, I'm probably using it frequently as a user everywhere :-)).


I've updated the Debian packaging in
https://salsa.debian.org/science-team/virtuoso-opensource.git
and created a try-7.2.12 branch (which has your patch (and some more) 
disabled and switched back to pcre3). This builds, but probably needs 
more updates before it is ready. But it should serve as a starting point 
for updating pcre2.patch.


Thanks

Andreas



Bug#999931: virtuoso-opensource: depends on obsolete pcre3 library

2023-12-20 Thread Yavor Doganov
Control: tags -1 + patch

Please find attached a patch; build-tested only (although the
package's own testsuite has some checks which test this
functionality).
Description: Port to PCRE2.
Bug-Debian: https://bugs.debian.org/31
Author: Yavor Doganov 
Forwarded: no
Last-Update: 2023-12-20
---

--- virtuoso-opensource.orig/libsrc/Wi/Makefile.am
+++ virtuoso-opensource/libsrc/Wi/Makefile.am
@@ -559,7 +559,7 @@
$(libwi_base_la_sources)
 
 libwi_la_CFLAGS  = $(libwi_base_la_cflags)
-libwi_la_LDLAGS  = -static -lminizip -lpcre
+libwi_la_LDLAGS  = -static -lminizip -lpcre2-8
 
 #KUBL_UNIV_FILES_ODBC
 libwi_odbc_la_SOURCES += \
--- virtuoso-opensource.orig/libsrc/Wi/bif_regexp.c
+++ virtuoso-opensource/libsrc/Wi/bif_regexp.c
@@ -30,7 +30,8 @@
 
 // Debian maintainer: replaced by external PCRE
 // #include "util/pcrelib/pcre.h"
-#include "pcre.h"
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include 
 
 /*
typedef struct rx_query_s {
@@ -66,15 +67,16 @@
 typedef struct compiled_regexp_s
 {
   int refctr;
-  pcre *code;
-  pcre_extra *code_x;
+  pcre2_code *code;
 }
 compiled_regexp_t;
 
 id_hash_t *compiled_regexps;
 
-int32 c_pcre_match_limit_recursion = 500;
-int32 c_pcre_match_limit = 10;
+static pcre2_match_context *match_ctxt = NULL;
+
+uint32 c_pcre_match_limit_recursion = 500;
+uint32 c_pcre_match_limit = 10;
 int32 pcre_max_cache_sz = 2;
 int32 pcre_rnd_seed;
 
@@ -97,6 +99,23 @@
 }
 
 void
+create_match_context (void)
+{
+  if (NULL != match_ctxt)
+return;
+
+  match_ctxt = pcre2_match_context_create (NULL);
+  if (c_pcre_match_limit > 0)
+{
+  pcre2_set_match_limit (match_ctxt, c_pcre_match_limit);
+}
+  if (c_pcre_match_limit_recursion > 0)
+{
+  pcre2_set_depth_limit (match_ctxt, c_pcre_match_limit_recursion);
+}
+}
+
+void
 release_compiled_regexp (id_hash_t *c_r, compiled_regexp_t *data)
 {
   int delete_data;
@@ -112,9 +131,7 @@
   if (!delete_data)
 return;
   if (NULL != data->code)
-pcre_free (data->code);
-  if (NULL != data->code_x)
-pcre_free (data->code_x);
+pcre2_code_free (data->code);
   dk_free (data, sizeof (compiled_regexp_t));
 }
 
@@ -137,10 +154,11 @@
 }
 
 static compiled_regexp_t *
-get_compiled_regexp (id_hash_t *c_r, const char *pattern, int options, caddr_t 
*err_ret)
+get_compiled_regexp (id_hash_t *c_r, const char *pattern, uint32_t options, 
caddr_t *err_ret)
 {
-  const char *error = NULL;
-  int erroff;
+  int err;
+  PCRE2_UCHAR error[120];
+  PCRE2_SIZE erroff;
   regexp_key_t key;
   compiled_regexp_t **val = NULL;
   compiled_regexp_t tmp, *new_val;
@@ -156,46 +174,18 @@
 }
   HT_LEAVE (c_r);
   dbg_printf (("regex compiling (%s) with options %x ...\n", pattern, 
options));
-  tmp.code = pcre_compile (pattern, options, , , 0);
+  tmp.code = pcre2_compile ((PCRE2_SPTR) pattern, strlen (pattern),
+options, , , NULL);
   if (NULL == tmp.code)
 {
-  if (error)
-err_ret[0] = srv_make_new_error ("2201B",
-"SR098", "regexp error at \'%s\' column %d (%s)", pattern, erroff, 
error);
-  else
-err_ret[0] = srv_make_new_error ("2201B",
-"SR098", "regexp error at \'%s\' column %d", pattern, erroff);
+  pcre2_get_error_message(err, error, sizeof (error));
+  err_ret[0] = srv_make_new_error ("2201B",
+  "SR098", "regexp error at \'%s\' column %zu (%s)", pattern, erroff, 
error);
   return NULL;
 }
-  tmp.code_x = pcre_study (tmp.code, options, );
-#ifdef DEBUG
-  if (!tmp.code_x)
-dbg_printf (("***warning RX100: regexp warning: extra regular expression 
compiling failed\n"));
-#endif
-  if (!tmp.code_x)
- {
-   tmp.code_x = pcre_malloc (sizeof (pcre_extra));
-   if (tmp.code_x)
- memset (tmp.code_x, 0, sizeof (pcre_extra));
- }
-#ifdef PCRE_EXTRA_MATCH_LIMIT
-  if (c_pcre_match_limit > 0)
-{
-  tmp.code_x->flags |= PCRE_EXTRA_MATCH_LIMIT;
-  tmp.code_x->match_limit = c_pcre_match_limit;
-}
-#endif
-#ifdef PCRE_EXTRA_MATCH_LIMIT_RECURSION
-  if (c_pcre_match_limit_recursion > 0)
-{
-  tmp.code_x->flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
-  tmp.code_x->match_limit_recursion = c_pcre_match_limit_recursion;
-}
-#endif
   key.orig_strg = box_dv_short_string (pattern);
   new_val = (compiled_regexp_t *)dk_alloc (sizeof (compiled_regexp_t));
   new_val->code = tmp.code;
-  new_val->code_x = tmp.code_x;
   new_val->refctr = 1;
   HT_ENTER (c_r);
   pcre_cache_check (c_r);
@@ -302,18 +292,18 @@
 }
 
 
-static int
+static uint32_t
 regexp_optchars_to_bits (const char *strg)
 {
-  int res = 0;
+  uint32_t res = 0;
   const char *tail;
   for (tail = strg; '\0' != tail[0]; tail++)
 {
   switch (tail[0])
 {
-case 'i': case 'I': res |= PCRE_CASELESS; break;
-case 'm': case 'M': res |= PCRE_MULTILINE; break;
-case 's': case 'S': res |= PCRE_DOTALL; break;
+case 'i': case 'I': res |= PCRE2_CASELESS; break;
+case 'm': 

Processed: Re: Bug#999931: virtuoso-opensource: depends on obsolete pcre3 library

2023-12-20 Thread Debian Bug Tracking System
Processing control commands:

> tags -1 + patch
Bug #31 [src:virtuoso-opensource] virtuoso-opensource: depends on obsolete 
pcre3 library
Added tag(s) patch.

-- 
31: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=31
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems