Dear maintainer,

I've prepared an NMU for mp4h (versioned as 1.3.1-17.1). The diff
is attached to this message.

Regards.

diff -Nru mp4h-1.3.1/debian/changelog mp4h-1.3.1/debian/changelog
--- mp4h-1.3.1/debian/changelog	2018-06-27 02:04:54.000000000 +0200
+++ mp4h-1.3.1/debian/changelog	2024-06-03 21:06:36.000000000 +0200
@@ -1,3 +1,13 @@
+mp4h (1.3.1-17.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+
+  [ Yavor Doganov ]
+  * debian/patches/pcre2.patch: New; port to PCRE2 (Closes: #1000015).
+  * debian/control (Build-Depends): Replace libpcre3-dev with libpcre2-dev.
+
+ -- Chris Hofstaedtler <z...@debian.org>  Mon, 03 Jun 2024 21:06:36 +0200
+
 mp4h (1.3.1-17) unstable; urgency=medium
 
   [ Axel Beckert ]
diff -Nru mp4h-1.3.1/debian/control mp4h-1.3.1/debian/control
--- mp4h-1.3.1/debian/control	2018-06-27 01:46:42.000000000 +0200
+++ mp4h-1.3.1/debian/control	2024-06-03 21:06:14.000000000 +0200
@@ -9,7 +9,7 @@
                fakeroot,
                gettext,
                libltdl-dev,
-               libpcre3-dev,
+               libpcre2-dev,
                libtool,
                tidy
 Build-Conflicts: autoconf2.13,
diff -Nru mp4h-1.3.1/debian/patches/pcre2.patch mp4h-1.3.1/debian/patches/pcre2.patch
--- mp4h-1.3.1/debian/patches/pcre2.patch	1970-01-01 01:00:00.000000000 +0100
+++ mp4h-1.3.1/debian/patches/pcre2.patch	2024-06-03 21:06:14.000000000 +0200
@@ -0,0 +1,449 @@
+Description: Port to PCRE2.
+Bug-Debian: https://bugs.debian.org/1000015
+Author: Yavor Doganov <ya...@gnu.org>
+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,11 +843,10 @@
+   register char *cp;
+   char *name;
+   int i, j, special_chars;
+-  pcre *re;
+-  pcre_extra *re_extra = NULL;
+-  const char *errptr = NULL;
++  pcre2_code *re;
++  pcre2_match_data *md = NULL;
+   int rc, max_subexps;
+-  int *match_ptr = NULL;
++  size_t *match_ptr = NULL;
+   boolean first = TRUE;
+ 
+   /*  Replace comma-separated list by a regular expression  */
+@@ -839,23 +859,11 @@
+   sprintf (name, "^%s$", list);
+ 
+   /*  Compile this expression once  */
+-  re = xre_compile (name, PCRE_CASELESS);
++  re = xre_compile (name, PCRE2_CASELESS);
+   xfree ((voidstar) name);
+   if (re == NULL)
+     return;
+ 
+-  if (argc>2)
+-    {
+-      re_extra = pcre_study (re, 0, &errptr);
+-      if (errptr != NULL)
+-        {
+-          MP4HERROR ((warning_status, 0,
+-            _("Error:%s:%d: Bad regular expression `%s': %s"),
+-                 CURRENT_FILE_LINE, list, errptr));
+-          return;
+-        }
+-    }
+-
+   for (i=1; i<argc; i++)
+     {
+       special_chars = 0;
+@@ -878,17 +886,18 @@
+       do
+         {
+           max_subexps += 10;
+-          match_ptr = (int *)
+-             xrealloc ((voidstar) match_ptr, sizeof (int) * max_subexps * 3);
+-          rc = pcre_exec (re, re_extra, ARG (i)+special_chars,
++          pcre2_match_data_free (md);
++          md = pcre2_match_data_create (max_subexps * 3, gen_ctxt);
++          rc = pcre2_match (re, (PCRE2_SPTR) ARG (i)+special_chars,
+                   strlen (ARG (i)+special_chars), 0,
+-                  0, match_ptr, max_subexps * 3);
++                  0, md, NULL);
+         }
+-      while (rc == PCRE_ERROR_NOMEMORY);
++      while (rc == PCRE2_ERROR_NOMEMORY);
+       max_subexps -= 10;
+ 
+       if (rc > 0 && match)
+         {
++          match_ptr = pcre2_get_ovector_pointer (md);
+           if (!first)
+             obstack_1grow (obs, ' ');
+           first = FALSE;
+@@ -915,7 +924,7 @@
+             }
+           obstack_1grow (obs, CHAR_EGROUP);
+         }
+-      else if (rc == PCRE_ERROR_NOMATCH && !match)
++      else if (rc == PCRE2_ERROR_NOMATCH && !match)
+         {
+           if (cp)
+             *cp  = '=';
+@@ -927,9 +936,8 @@
+           obstack_1grow (obs, CHAR_EGROUP);
+         }
+     }
+-  pcre_free (re);
+-  pcre_free (re_extra);
+-  xfree ((voidstar) match_ptr);
++  pcre2_match_data_free (md);
++  pcre2_code_free (re);
+ }
+ 
+ 
+@@ -991,13 +999,17 @@
+ void
+ pcre_init (void)
+ {
+-  re_tableptr = pcre_maketables ();
++  gen_ctxt = pcre2_general_context_create (pcre_malloc, pcre_free, NULL);
++  comp_ctxt = pcre2_compile_context_create (gen_ctxt);
++  re_tableptr = pcre2_maketables (gen_ctxt);
+ }
+ 
+ void
+ pcre_deallocate (void)
+ {
+-  pcre_free ((voidstar) re_tableptr);
++  pcre2_maketables_free (gen_ctxt, re_tableptr);
++  pcre2_compile_context_free (comp_ctxt);
++  pcre2_general_context_free (gen_ctxt);
+ }
+ 
+ /*---------------------.
+@@ -1420,10 +1432,9 @@
+   struct dirent *entry;
+   int length;
+   const char *matching;
+-  pcre *re = NULL;
+-  pcre_extra *re_extra = NULL;
+-  const char *errptr = NULL;
+-  int *match_ptr = NULL;
++  pcre2_code *re = NULL;
++  pcre2_match_data *md;
++  size_t *match_ptr = NULL;
+   boolean first = TRUE;
+ 
+   CHECK_SAFETY_LEVEL(1);
+@@ -1443,24 +1454,16 @@
+       re = xre_compile (matching, 0);
+       if (re == NULL)
+         return;
+-      match_ptr = (int *)
+-         xrealloc ((voidstar) match_ptr, sizeof (int) * 3);
+-      re_extra = pcre_study (re, 0, &errptr);
+-      if (errptr != NULL)
+-        {
+-          MP4HERROR ((warning_status, 0,
+-            _("Error:%s:%d: Bad regular expression `%s': %s"),
+-                 CURRENT_FILE_LINE, matching, errptr));
+-          return;
+-        }
++      md = pcre2_match_data_create (3, gen_ctxt);
+     }
+ 
+   while ((entry = readdir (dir)) != (struct dirent *)NULL)
+     {
+       length = strlen (entry->d_name);
+       if (!matching ||
+-          (pcre_exec (re, re_extra, entry->d_name, length, 0,
+-                    0, match_ptr, 3) > 0
++          (pcre2_match (re, (PCRE2_SPTR) entry->d_name, length, 0,
++                    0, md, NULL) > 0
++           && (match_ptr = pcre2_get_ovector_pointer (md))
+            && match_ptr[1] - match_ptr[0] == length))
+         {
+           if (!first)
+@@ -1472,9 +1475,8 @@
+ 
+   if (matching)
+     {
+-      pcre_free (re);
+-      pcre_free (re_extra);
+-      xfree ((voidstar) match_ptr);
++      pcre2_match_data_free (md);
++      pcre2_code_free (re);
+     }
+   closedir (dir);
+ }
+@@ -3528,7 +3530,7 @@
+ 
+ static void
+ substitute (struct obstack *obs, const char *victim, const char *repl,
+-            int *regs)
++            size_t *regs)
+ {
+   register unsigned int ch;
+ 
+@@ -3590,8 +3592,9 @@
+   int startpos = -1;            /* start position of match */
+   int match_length = 0;         /* length of pattern match */
+ 
+-  pcre *re;
+-  int *match_ptr = NULL;
++  pcre2_code *re;
++  pcre2_match_data *md = NULL;
++  size_t *match_ptr = NULL;
+   int max_subexps = 0;
+   int rc;
+ 
+@@ -3610,15 +3613,16 @@
+   do
+     {
+       max_subexps += 10;
+-      match_ptr = (int *)
+-         xrealloc ((voidstar) match_ptr, sizeof (int) * max_subexps * 3);
+-      rc  = pcre_exec (re, NULL, victim, length, 0,
+-                          0, match_ptr, max_subexps * 3);
++      pcre2_match_data_free (md);
++      md = pcre2_match_data_create (max_subexps * 3, gen_ctxt);
++      rc  = pcre2_match (re, (PCRE2_SPTR) victim, length, 0,
++                         0, md, NULL);
+     }
+-  while (rc == PCRE_ERROR_NOMEMORY);
++  while (rc == PCRE2_ERROR_NOMEMORY);
+ 
+   if (rc > 0)
+     {
++      match_ptr = pcre2_get_ovector_pointer (md);
+       match_length = match_ptr[1] - match_ptr[0];
+       startpos = match_ptr[0];
+     }
+@@ -3660,8 +3664,8 @@
+         obstack_grow (obs, "true", 4);
+     }
+ 
+-  pcre_free (re);
+-  xfree ((voidstar) match_ptr);
++  pcre2_match_data_free (md);
++  pcre2_code_free (re);
+ }
+ 
+ /*----------------------------------------------.
+@@ -3675,11 +3679,10 @@
+   char *victim;                 /* first argument */
+   char *regexp;                 /* regular expression */
+ 
+-  pcre *re;
+-  pcre_extra *re_extra = NULL;
+-  const char *errptr;
++  pcre2_code *re;
++  pcre2_match_data *md = NULL;
+ 
+-  int *match_ptr = NULL;
++  size_t *match_ptr = NULL;
+   int max_subexps = 0;
+   int options = 0;
+   int rc;
+@@ -3702,15 +3705,6 @@
+   if (re == NULL)
+     return;
+ 
+-  re_extra = pcre_study (re, 0, &errptr);
+-  if (errptr != NULL)
+-    {
+-      MP4HERROR ((warning_status, 0,
+-        _("Error:%s:%d: Bad regular expression `%s': %s"),
+-             CURRENT_FILE_LINE, regexp, errptr));
+-      return;
+-    }
+-
+   offset = 0;
+   matchpos = 0;
+   while (offset < length)
+@@ -3719,16 +3713,16 @@
+       do
+         {
+           max_subexps += 10;
+-          match_ptr = (int *)
+-            xrealloc ((voidstar) match_ptr, sizeof (int) * max_subexps * 3);
+-          rc = pcre_exec (re, re_extra, victim+offset, length-offset, 0,
+-                          options, match_ptr, max_subexps * 3);
++          pcre2_match_data_free (md);
++          md = pcre2_match_data_create (max_subexps * 3, gen_ctxt);
++          rc = pcre2_match (re, (PCRE2_SPTR) victim+offset, length-offset,
++                            0, options, md, NULL);
+         }
+-      while (rc == PCRE_ERROR_NOMEMORY);
++      while (rc == PCRE2_ERROR_NOMEMORY);
+       max_subexps -= 10;
+ 
+       /*  Subsequent calls to regexec do not match beginning o line */
+-      options |= PCRE_NOTBOL;
++      options |= PCRE2_NOTBOL;
+ 
+       if (rc < 0)
+         {
+@@ -3737,7 +3731,7 @@
+              rest of the string, in which case the rest of the string is
+              copied verbatim.  */
+ 
+-          if (rc != PCRE_ERROR_NOMATCH)
++          if (rc != PCRE2_ERROR_NOMATCH)
+             MP4HERROR ((warning_status, 0,
+               _("Warning:%s:%d: Error matching regular expression `%s'"),
+                    CURRENT_FILE_LINE, regexp));
+@@ -3746,6 +3740,8 @@
+           break;
+         }
+ 
++      match_ptr = pcre2_get_ovector_pointer (md);
++
+       /* Copy the part of the string that was skipped by regex ().  */
+       matchpos = match_ptr[0];
+ 
+@@ -3764,9 +3760,8 @@
+         obstack_1grow (obs, victim[offset++]);
+     }
+ 
+-  pcre_free (re);
+-  pcre_free (re_extra);
+-  xfree ((voidstar) match_ptr);
++  pcre2_match_data_free (md);
++  pcre2_code_free (re);
+ }
+ 
+ /*------------------------------------------------.
+@@ -3783,14 +3778,14 @@
+   if (singleline)
+     {
+       if (strcmp (singleline, "true") == 0)
+-        re_flags |= PCRE_DOTALL;
++        re_flags |= PCRE2_DOTALL;
+       else
+-        re_flags |= PCRE_MULTILINE;
++        re_flags |= PCRE2_MULTILINE;
+     }
+ 
+   caseless = predefined_attribute ("caseless", ptr_argc, argv, TRUE);
+   if (caseless && strcmp (caseless, "true") == 0)
+-    re_flags |= PCRE_CASELESS;
++    re_flags |= PCRE2_CASELESS;
+ 
+   /*  This one overrides previous options  */
+   reflags = predefined_attribute ("reflags", ptr_argc, argv, TRUE);
+@@ -3802,10 +3797,10 @@
+           switch (*cp)
+             {
+               case '-': break;
+-              case 'i': re_flags |= PCRE_CASELESS; break;
+-              case 'm': re_flags |= PCRE_MULTILINE; break;
+-              case 's': re_flags |= PCRE_DOTALL; break;
+-              case 'x': re_flags |= PCRE_EXTENDED; break;
++              case 'i': re_flags |= PCRE2_CASELESS; break;
++              case 'm': re_flags |= PCRE2_MULTILINE; break;
++              case 's': re_flags |= PCRE2_DOTALL; break;
++              case 'x': re_flags |= PCRE2_EXTENDED; break;
+               default:
+                         MP4HERROR ((warning_status, 0, _("\
+ Warning:%s:%d: Unknown modifier `%c' in reflags"),
+--- mp4h.orig/src/builtin.h
++++ mp4h/src/builtin.h
+@@ -41,7 +41,8 @@
+ #undef HAVE_FILE_FUNCS
+ #endif
+ 
+-#include "pcre.h"
++#define PCRE2_CODE_UNIT_WIDTH 8
++#include <pcre2.h>
+ 
+ #ifdef HAVE_FILE_FUNCS
+ #include <dirent.h>
diff -Nru mp4h-1.3.1/debian/patches/series mp4h-1.3.1/debian/patches/series
--- mp4h-1.3.1/debian/patches/series	2018-06-27 01:59:56.000000000 +0200
+++ mp4h-1.3.1/debian/patches/series	2024-06-03 21:06:14.000000000 +0200
@@ -8,3 +8,4 @@
 use-system-pcre.diff
 reproducible-build.diff
 fix-spelling-errors.diff
+pcre2.patch

Reply via email to