regex: Fix unicode othercasing

Reorder the toupper/tolower calls when othercaseing, so this
function is bug-for-bug compatible with the pcre internal tables.

https://bugzilla.gnome.org/show_bug.cgi?id=678273
This commit is contained in:
Christian Persch 2012-06-17 22:51:44 +02:00
parent a2f54a3408
commit 7483315f83
2 changed files with 8 additions and 2 deletions

View File

@ -589,10 +589,10 @@ _pcre_ucp_othercase(const unsigned int c)
{
unsigned int oc;
if ((oc = g_unichar_tolower(c)) != c)
return oc;
if ((oc = g_unichar_toupper(c)) != c)
return oc;
if ((oc = g_unichar_tolower(c)) != c)
return oc;
return c;
}

View File

@ -2332,6 +2332,12 @@ main (int argc, char *argv[])
/* This failed with PCRE 7.2 (gnome bug #455640) */
TEST_MATCH(".*$", 0, 0, "\xe1\xbb\x85", -1, 0, 0, TRUE);
/* 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);
/* TEST_MATCH_NEXT#(pattern, string, string_len, start_position, ...) */
TEST_MATCH_NEXT0("a", "x", -1, 0);
TEST_MATCH_NEXT0("a", "ax", -1, 1);