Bug#1000015: mp4h: depends on obsolete pcre3 library

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

Please find attached a patch.
>From 4ead19b22c1564097192c50e2ec42c07351ef8de Mon Sep 17 00:00:00 2001
From: Yavor Doganov 
Date: Sun, 10 Dec 2023 17:12:31 +0200
Subject: [PATCH] Port to PCRE2 (#115)

---
 debian/changelog   |   7 +
 debian/control |   2 +-
 debian/patches/pcre2.patch | 449 +
 debian/patches/series  |   1 +
 4 files changed, 458 insertions(+), 1 deletion(-)
 create mode 100644 debian/patches/pcre2.patch

diff --git a/debian/changelog b/debian/changelog
index b8143c6..018 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+mp4h (1.3.1-18) UNRELEASED; urgency=medium
+
+  * debian/patches/pcre2.patch: New; port to PCRE2 (Closes: #115).
+  * debian/control (Build-Depends): Replace libpcre3-dev with libpcre2-dev.
+
+ -- Yavor Doganov   Sun, 10 Dec 2023 17:11:18 +0200
+
 mp4h (1.3.1-17) unstable; urgency=medium
 
   [ Axel Beckert ]
diff --git a/debian/control b/debian/control
index 4ee9a51..4630c13 100644
--- a/debian/control
+++ b/debian/control
@@ -9,7 +9,7 @@ Build-Depends: autoconf (>= 2.57~),
fakeroot,
gettext,
libltdl-dev,
-   libpcre3-dev,
+   libpcre2-dev,
libtool,
tidy
 Build-Conflicts: autoconf2.13,
diff --git a/debian/patches/pcre2.patch b/debian/patches/pcre2.patch
new file mode 100644
index 000..15a5857
--- /dev/null
+++ b/debian/patches/pcre2.patch
@@ -0,0 +1,449 @@
+Description: Port to PCRE2.
+Bug-Debian: https://bugs.debian.org/115
+Author: Yavor Doganov 
+Forwarded: no
+Last-Update: 2023-12-10
+---
+
+--- mp4h.orig/src/Makefile.am
 mp4h/src/Makefile.am
+@@ -17,7 +17,7 @@
+ if LOADABLE_MODULES
+ mp4h_LDFLAGS = -export-dynamic
+ endif
+-mp4h_LDADD   = -lm $(top_builddir)/lib/libmp4h.a -lpcre @LIBINTL@ 
$(MODULE_LDADD)
++mp4h_LDADD   = -lm $(top_builddir)/lib/libmp4h.a -lpcre2-8 @LIBINTL@ 
$(MODULE_LDADD)
+ 
+ include_HEADERS = mp4h.h
+ noinst_HEADERS  = builtin.h
+--- mp4h.orig/src/builtin.c
 mp4h/src/builtin.c
+@@ -373,7 +373,7 @@
+ static char * utf8char_skip __P ((char *, int));
+ static int utf8char_strlen __P ((char *));
+ static int encoding_strlen __P ((char *));
+-static void substitute __P ((struct obstack *, const char *, const char *, 
int *));
++static void substitute __P ((struct obstack *, const char *, const char *, 
size_t *));
+ static void string_regexp __P ((struct obstack *, int, token_data **, int, 
const char *));
+ static void subst_in_string __P ((struct obstack *, int, token_data **, int));
+ static void generic_variable_lookup __P ((MP4H_BUILTIN_PROTO, boolean));
+@@ -382,6 +382,8 @@
+ static int array_member __P ((const char *, symbol *, boolean));
+ static int sort_function __P ((const void *, const void *));
+ static void logical_to_physical_paths __P ((char **));
++static void * pcre_malloc (size_t, void *);
++static void pcre_free (void *, void *);
+ 
+ /*  This symbol controls breakings of flow statements.  */
+ static symbol varbreak;
+@@ -398,7 +400,12 @@
+ struct lconv *my_locale;
+ 
+ /*  Table of characters used by PCRE with non-C locales  */
+-static const unsigned char *re_tableptr = NULL;
++static const uint8_t *re_tableptr = NULL;
++
++/*  PCRE contexts needed for custom memory management and adding
++non-builtin character tables.  */
++static pcre2_general_context *gen_ctxt;
++static pcre2_compile_context *comp_ctxt;
+ 
+ /*  Timer  */
+ static struct tms elapsed_time;
+@@ -662,12 +669,22 @@
+ | Initialise all builtin and predefined macros.  |
+ `---*/
+ 
++static void *
++pcre_malloc (size_t size, void *ptr)
++{
++  return xmalloc (size);
++}
++
++static void
++pcre_free (void *ptr, void *tag)
++{
++  xfree (ptr);
++}
++
+ void
+ builtin_init (void)
+ {
+   install_builtin_table (builtin_tab);
+-  pcre_malloc = xmalloc;
+-  pcre_free   = xfree;
+ }
+ 
+ /*---.
+@@ -688,18 +705,22 @@
+   varstack_check ();
+ }
+ 
+-static pcre *
++static pcre2_code *
+ xre_compile (const char *pattern, int cflags)
+ {
+-  pcre *patcomp;
+-  const char *errbuf;
+-  int erroffset;
++  pcre2_code *patcomp;
++  PCRE2_UCHAR errbuf[120];
++  int errcode;
++  size_t erroffset;
+ 
+   if (document_encoding == ENCODING_UTF8)
+-  cflags |= PCRE_UTF8;
+-  patcomp = pcre_compile (pattern, cflags, &errbuf, &erroffset, re_tableptr);
++  cflags |= PCRE2_UTF;
++  pcre2_set_character_tables (comp_ctxt, re_tableptr);
++  patcomp = pcre2_compile ((PCRE2_SPTR) pattern, PCRE2_ZERO_TERMINATED,
++   cflags, &errcode, &erroffset, comp_ctxt);
+   if (patcomp == 0)
+ {
++  pcre2_get_error_message (errcode, errbuf, sizeof (errbuf));
+   MP4HERROR ((warning_status, 0,
+ _("Warning:%s:%d: Bad regular expression `%s' at position %d: %s"),
+  CURRENT_FILE_LINE, pattern, erroffset, errbuf));
+@@ -822,

Processed: Re: Bug#1000015: mp4h: depends on obsolete pcre3 library

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

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

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



Bug#1000015: mp4h: depends on obsolete pcre3 library

2023-08-22 Thread Bastian Germann

Am 23.08.23 um 01:13 schrieb Bastian Germann:

(which mp4h)

... (which mp4h stems from) ...



Bug#1000015: mp4h: depends on obsolete pcre3 library

2023-08-22 Thread Bastian Germann

Am 18.08.23 um 12:13 schrieb Bastian Germann:

mp4h is a key package and I do not think, we can get it out of that set.
Please consider patching yourself (upstream is dead) or using the 
vendored pcre and possibly updating it (last ressort).


GNU m4 (which mp4h) makes use of GNU Regular Expressions in its 
builtin.c instead of pcre. That might be a candidate for a patch as well.




Bug#1000015: mp4h: depends on obsolete pcre3 library

2023-08-18 Thread Bastian Germann

mp4h is a key package and I do not think, we can get it out of that set.
Please consider patching yourself (upstream is dead) or using the 
vendored pcre and possibly updating it (last ressort).