[glib] Update the included copy of PCRE
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Update the included copy of PCRE
- Date: Sat, 22 Jan 2011 04:10:48 +0000 (UTC)
commit c03dc6bf7dfc6e326e7249e9e377676db885d99e
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jan 21 23:10:01 2011 -0500
Update the included copy of PCRE
Update PCRE to version 8.12.
At the same time, also add Unicode 6.0 script support.
glib/gregex.c | 16 ++++++++++++++++
glib/tests/regex.c | 5 ++---
2 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/glib/gregex.c b/glib/gregex.c
index b62bda7..a1d2315 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -230,6 +230,10 @@ match_error (gint errcode)
return _("workspace limit for empty substrings reached");
case PCRE_ERROR_BADNEWLINE:
return _("invalid combination of newline flags");
+ case PCRE_ERROR_BADOFFSET:
+ return _("bad offset");
+ case PCRE_ERROR_SHORTUTF8:
+ return _("short utf8");
default:
break;
}
@@ -565,6 +569,14 @@ g_match_info_next (GMatchInfo *match_info,
prev_match_start = match_info->offsets[0];
prev_match_end = match_info->offsets[1];
+ if (match_info->pos > match_info->string_len)
+ {
+ /* we have reached the end of the string */
+ match_info->pos = -1;
+ match_info->matches = PCRE_ERROR_NOMATCH;
+ return FALSE;
+ }
+
match_info->matches = pcre_exec (match_info->regex->pcre_re,
match_info->regex->extra,
match_info->string,
@@ -1197,6 +1209,8 @@ g_regex_new (const gchar *pattern,
compile_options |= PCRE_NEWLINE_ANY;
}
+ compile_options |= PCRE_UCP;
+
/* compile the pattern */
re = pcre_compile2 (pattern, compile_options, &errcode,
&errmsg, &erroffset, NULL);
@@ -1792,6 +1806,7 @@ g_regex_split_simple (const gchar *pattern,
regex = g_regex_new (pattern, compile_options, 0, NULL);
if (!regex)
return NULL;
+
result = g_regex_split_full (regex, string, -1, 0, match_options, 0, NULL);
g_regex_unref (regex);
return result;
@@ -1924,6 +1939,7 @@ g_regex_split_full (const GRegex *regex,
match_ok = g_regex_match_full (regex, string, string_len, start_position,
match_options, &match_info, &tmp_error);
+
while (tmp_error == NULL)
{
if (match_ok)
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
index 6e015e9..ef3ac68 100644
--- a/glib/tests/regex.c
+++ b/glib/tests/regex.c
@@ -1342,6 +1342,7 @@ test_match_all (gconstpointer d)
#define PCRE_UTF8 0x00000800
#define PCRE_NO_UTF8_CHECK 0x00002000
#define PCRE_NEWLINE_ANY 0x00400000
+#define PCRE_UCP 0x20000000
static void
test_basic (void)
@@ -1353,7 +1354,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 );
+ 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_match_flags (regex), ==, mflags|PCRE_NO_UTF8_CHECK);
g_regex_unref (regex);
@@ -2063,8 +2064,6 @@ main (int argc, char *argv[])
{
setlocale (LC_ALL, "");
- g_setenv ("G_DEBUG", "fatal_warnings", TRUE);
-
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/regex/basic", test_basic);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]