On Mon, 21 Jul 2014 at 10:17:09 +0100, Simon McVittie wrote:
> The remaining failures seem to be an intentional behaviour change in PCRE.

The attached was enough for GLib git master when I tried it yesterday.
However, I'm getting an additional test failure now, building against
my planned pcre3 NMU (which it looks as though the maintainer might
upload now):

# random seed: R02S8c9eb61b4add98149bfeeb19d0c7c029
# Start of regex tests
ok 1 /regex/properties
PASS: regex 1 /regex/properties
ok 2 /regex/class
PASS: regex 2 /regex/class
ok 3 /regex/lookahead
PASS: regex 3 /regex/lookahead
ok 4 /regex/lookbehind
PASS: regex 4 /regex/lookbehind
# ERROR:/«PKGBUILDDIR»/./glib/tests/regex.c:1693:test_subpattern: assertion 
failed: (res)
ERROR: regex - missing test plan
ERROR: regex - exited with status 134 (terminated by signal 6?)

    S
Index: debian/changelog
===================================================================
--- debian/changelog	(revision 42085)
+++ debian/changelog	(working copy)
@@ -13,6 +13,17 @@
   * Use the default compiler on sparc, since it's already >> 4.7.
     Closes: #751313.
 
+  [ Simon McVittie ]
+  * Adapt for system pcre3/1:8.35 (Closes: #755439):
+    - a PCRE 8.31 bug in case-insensitivity has been fixed, so do not assert
+      bug-for-bug compatibility with 8.31
+    - named match groups' names cannot start with a digit any more, so
+      (?P<1>.) is no longer allowed; do not assert that it is
+    - turn off a new optimization that would reduce the result set when called
+      from g_match_all(_full), to preserve existing functionality
+  * Build-depend on pcre3/1:8.35 so that the new optimization is
+    known to be turned off in the built binaries
+
  -- Emilio Pozuelo Monfort <po...@debian.org>  Mon, 05 May 2014 11:50:10 +0200
 
 glib2.0 (2.40.0-3) unstable; urgency=medium
Index: debian/control.in
===================================================================
--- debian/control.in	(revision 42085)
+++ debian/control.in	(working copy)
@@ -12,7 +12,7 @@
                gnome-pkg-tools (>= 0.11),
                dpkg-dev (>= 1.16.0),
                libelfg0-dev (>= 0.8.12),
-               libpcre3-dev (>= 1:8.31),
+               libpcre3-dev (>= 1:8.35),
                desktop-file-utils,
                gtk-doc-tools (>= 1.20),
                libselinux1-dev [linux-any],
Index: debian/patches/0001-regex-test-do-not-assert-that-system-PCRE-still-has-.patch
===================================================================
--- debian/patches/0001-regex-test-do-not-assert-that-system-PCRE-still-has-.patch	(revision 0)
+++ debian/patches/0001-regex-test-do-not-assert-that-system-PCRE-still-has-.patch	(working copy)
@@ -0,0 +1,36 @@
+From 8f0620d6304f5f2c386285f645b10409aa17e86e Mon Sep 17 00:00:00 2001
+From: Simon McVittie <simon.mcvit...@collabora.co.uk>
+Date: Sun, 20 Jul 2014 19:33:59 +0100
+Subject: [PATCH 1/3] regex test: do not assert that system PCRE still has an
+ 8.31 bug
+
+This was fixed in 8.32.
+
+Bug: https://bugzilla.gnome.org/show_bug.cgi?id=733325
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=755439
+Forwarded: yes
+---
+ glib/tests/regex.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/glib/tests/regex.c b/glib/tests/regex.c
+index 833e585..95b2360 100644
+--- a/glib/tests/regex.c
++++ b/glib/tests/regex.c
+@@ -2446,8 +2446,12 @@ main (int argc, char *argv[])
+   /* Test that othercasing in our pcre/glib integration is bug-for-bug compatible
+    * with pcre's internal tables. Bug #678273 */
+   TEST_MATCH("[DŽ]", G_REGEX_CASELESS, 0, "DŽ", -1, 0, 0, TRUE);
+-  TEST_MATCH("[DŽ]", G_REGEX_CASELESS, 0, "Dž", -1, 0, 0, FALSE);
+   TEST_MATCH("[DŽ]", G_REGEX_CASELESS, 0, "dž", -1, 0, 0, TRUE);
++#ifndef USE_SYSTEM_PCRE
++  /* This is a bug, which was fixed in 8.32. A system pcre might
++   * be that version or newer, so we cannot assert that it has this bug. */
++  TEST_MATCH("[DŽ]", G_REGEX_CASELESS, 0, "Dž", -1, 0, 0, FALSE);
++#endif
+ 
+   /* TEST_MATCH_NEXT#(pattern, string, string_len, start_position, ...) */
+   TEST_MATCH_NEXT0("a", "x", -1, 0);
+-- 
+2.0.1
+
Index: debian/patches/0002-regex-test-do-not-assert-that-system-PCRE-allows-P-1.patch
===================================================================
--- debian/patches/0002-regex-test-do-not-assert-that-system-PCRE-allows-P-1.patch	(revision 0)
+++ debian/patches/0002-regex-test-do-not-assert-that-system-PCRE-allows-P-1.patch	(working copy)
@@ -0,0 +1,34 @@
+From 666aeffde7809927741fdf42bab611e4e73117af Mon Sep 17 00:00:00 2001
+From: Simon McVittie <simon.mcvit...@collabora.co.uk>
+Date: Sun, 20 Jul 2014 19:34:54 +0100
+Subject: [PATCH 2/3] regex test: do not assert that system PCRE allows
+ "(?P<1>)"
+
+Perl >= 5.18, and PCRE >= 8.34, disallow this.
+
+Bug: https://bugzilla.gnome.org/show_bug.cgi?id=733325
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=755439
+Forwarded: yes
+---
+ glib/tests/regex.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/glib/tests/regex.c b/glib/tests/regex.c
+index 95b2360..b317501 100644
+--- a/glib/tests/regex.c
++++ b/glib/tests/regex.c
+@@ -2632,8 +2632,11 @@ main (int argc, char *argv[])
+   TEST_EXPAND("a", "a", "\\0130", FALSE, "X");
+   TEST_EXPAND("a", "a", "\\\\\\0", FALSE, "\\a");
+   TEST_EXPAND("a(?P<G>.)c", "xabcy", "X\\g<G>X", FALSE, "XbX");
++#ifndef USE_SYSTEM_PCRE
++  /* PCRE >= 8.34 no longer allows this usage. */
+   TEST_EXPAND("(.)(?P<1>.)", "ab", "\\1", FALSE, "a");
+   TEST_EXPAND("(.)(?P<1>.)", "ab", "\\g<1>", FALSE, "a");
++#endif
+   TEST_EXPAND(".", EURO, "\\0", FALSE, EURO);
+   TEST_EXPAND("(.)", EURO, "\\1", FALSE, EURO);
+   TEST_EXPAND("(?P<G>.)", EURO, "\\g<G>", FALSE, EURO);
+-- 
+2.0.1
+
Index: debian/patches/0003-regex-if-PCRE-is-8.34-or-later-go-back-to-older-DFA-.patch
===================================================================
--- debian/patches/0003-regex-if-PCRE-is-8.34-or-later-go-back-to-older-DFA-.patch	(revision 0)
+++ debian/patches/0003-regex-if-PCRE-is-8.34-or-later-go-back-to-older-DFA-.patch	(working copy)
@@ -0,0 +1,37 @@
+From 21d9f6db5613da81f4192672100a2b1446aaabd2 Mon Sep 17 00:00:00 2001
+From: Simon McVittie <simon.mcvit...@collabora.co.uk>
+Date: Mon, 21 Jul 2014 10:03:33 +0100
+Subject: [PATCH 3/3] regex: if PCRE is 8.34 or later, go back to older
+ DFA-matching behaviour
+
+This currently only affects a system PCRE, but would also work fine for
+an internal PCRE 8.34 or later if the embedded copy is updated.
+
+Bug: https://bugzilla.gnome.org/show_bug.cgi?id=733325
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=755439
+Forwarded: yes
+---
+ glib/gregex.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/glib/gregex.c b/glib/gregex.c
+index 41bf67e..e693a7a 100644
+--- a/glib/gregex.c
++++ b/glib/gregex.c
+@@ -1883,6 +1883,13 @@ g_regex_match_all_full (const GRegex      *regex,
+   info = match_info_new (regex, string, string_len, start_position,
+                          match_options, TRUE);
+ 
++#ifdef PCRE_NO_AUTO_POSSESS
++  /* PCRE 8.34 introduced an optimization which changes the behaviour
++   * of DFA matching. Alter the match options passed to PCRE (but not
++   * those in the match info) to go back to how it used to work. */
++  match_options |= PCRE_NO_AUTO_POSSESS;
++#endif
++
+   done = FALSE;
+   while (!done)
+     {
+-- 
+2.0.1
+
Index: debian/patches/series
===================================================================
--- debian/patches/series	(revision 42085)
+++ debian/patches/series	(working copy)
@@ -18,3 +18,6 @@
 81-skip-monitor-test-on-non-linux.patch
 0001-timer-test-use-volatile-for-locals.patch
 skip-broken-timer-test.patch
+0001-regex-test-do-not-assert-that-system-PCRE-still-has-.patch
+0002-regex-test-do-not-assert-that-system-PCRE-allows-P-1.patch
+0003-regex-if-PCRE-is-8.34-or-later-go-back-to-older-DFA-.patch

Reply via email to