From: Christian Persch Date: Sun, 17 Jun 2012 20:51:44 +0000 (+0200) Subject: regex: Fix unicode othercasing X-Git-Tag: 2.33.4~54 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7483315f83cac1f54fd72c331e6eff0781b8560f;p=platform%2Fupstream%2Fglib.git 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 --- diff --git a/glib/pcre/pcre_tables.c b/glib/pcre/pcre_tables.c index 5bac855..ddbf950 100644 --- a/glib/pcre/pcre_tables.c +++ b/glib/pcre/pcre_tables.c @@ -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; } diff --git a/glib/tests/regex.c b/glib/tests/regex.c index a155e3a..72a0155 100644 --- a/glib/tests/regex.c +++ b/glib/tests/regex.c @@ -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);