[glib/wip/pcre-update: 7/17] regex: Fix newline definition for system PCRE



commit 8508f571100bbd068b82b1374efd836285ef3b39
Author: Christian Persch <chpe gnome org>
Date:   Thu Jun 7 16:42:50 2012 +0200

    regex: Fix newline definition for system PCRE
    
    While we PCRE_BSR_UNICODE is the default in the internal PCRE, that may
    not be true for the system one. Force the PCRE_BSR_UNICODE flag on it.

 glib/gregex.c      |    6 ++++++
 glib/tests/regex.c |    3 ++-
 2 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/glib/gregex.c b/glib/gregex.c
index efb2d57..44fc049 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -1320,6 +1320,12 @@ g_regex_new (const gchar         *pattern,
 
   compile_options |= PCRE_UCP;
 
+  /* PCRE_BSR_UNICODE is the default for the internal PCRE but
+   * possibly not for the system one.
+   */
+  if (~compile_options & G_REGEX_BSR_ANYCRLF)
+    compile_options |= PCRE_BSR_UNICODE;
+
   /* compile the pattern */
   re = pcre_compile2 (pattern, compile_options, &errcode,
                       &errmsg, &erroffset, NULL);
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
index ab94055..b0362cd 100644
--- a/glib/tests/regex.c
+++ b/glib/tests/regex.c
@@ -1366,6 +1366,7 @@ test_match_all (gconstpointer d)
 #define PCRE_NO_UTF8_CHECK      0x00002000
 #define PCRE_NEWLINE_ANY        0x00400000
 #define PCRE_UCP                0x20000000
+#define PCRE_BSR_UNICODE        0x01000000
 
 static void
 test_basic (void)
@@ -1377,7 +1378,7 @@ test_basic (void)
   regex = g_regex_new ("[A-Z]+", cflags, mflags, NULL);
 
   g_assert (regex != NULL);
-  g_assert_cmpint (g_regex_get_compile_flags (regex), ==, cflags|PCRE_UTF8|PCRE_NO_UTF8_CHECK|PCRE_NEWLINE_ANY|PCRE_UCP );
+  g_assert_cmpint (g_regex_get_compile_flags (regex), ==, cflags|PCRE_UTF8|PCRE_NO_UTF8_CHECK|PCRE_NEWLINE_ANY|PCRE_UCP|PCRE_BSR_UNICODE);
   g_assert_cmpint (g_regex_get_match_flags (regex), ==, mflags|PCRE_NO_UTF8_CHECK);
 
   g_regex_unref (regex);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]