Update the included copy of PCRE

Update PCRE to version 8.12.
At the same time, also add Unicode 6.0 script support.
This commit is contained in:
Matthias Clasen 2011-01-21 23:10:01 -05:00
parent 51c87f6809
commit c03dc6bf7d
2 changed files with 18 additions and 3 deletions

View File

@ -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)

View File

@ -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);