From: Markus Scherer Date: Wed, 28 May 2014 23:03:52 +0000 (+0000) Subject: ICU-8260 bug fixes X-Git-Tag: milestone-59-0-1~1894 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b3cb5dcc863261f8b5aa52731bd043c713894ea9;p=icu ICU-8260 bug fixes X-SVN-Rev: 35766 --- diff --git a/icu4c/source/i18n/coll.cpp b/icu4c/source/i18n/coll.cpp index 49a4860e08d..42a1638e32b 100644 --- a/icu4c/source/i18n/coll.cpp +++ b/icu4c/source/i18n/coll.cpp @@ -369,7 +369,7 @@ void setAttributesFromKeywords(const Locale &loc, Collator &coll, UErrorCode &er return; } if (length != 0) { - int32_t codes[ + UCOL_REORDER_CODE_LIMIT - UCOL_REORDER_CODE_FIRST]; + int32_t codes[USCRIPT_CODE_LIMIT + UCOL_REORDER_CODE_LIMIT - UCOL_REORDER_CODE_FIRST]; int32_t codesLength = 0; char *scriptName = value; for (;;) { diff --git a/icu4c/source/i18n/ucol_res.cpp b/icu4c/source/i18n/ucol_res.cpp index 13295fb68a7..3b37db015fb 100644 --- a/icu4c/source/i18n/ucol_res.cpp +++ b/icu4c/source/i18n/ucol_res.cpp @@ -104,12 +104,21 @@ UnicodeString * CollationLoader::loadRules(const char *localeID, const char *collationType, UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return NULL; } U_ASSERT(collationType != NULL && *collationType != 0); + // Copy the type for lowercasing. + char type[16]; + int32_t typeLength = uprv_strlen(collationType); + if(typeLength >= LENGTHOF(type)) { + errorCode = U_ILLEGAL_ARGUMENT_ERROR; + return NULL; + } + uprv_memcpy(type, collationType, typeLength + 1); + T_CString_toLowerCase(type); LocalUResourceBundlePointer bundle(ures_open(U_ICUDATA_COLL, localeID, &errorCode)); LocalUResourceBundlePointer collations( ures_getByKey(bundle.getAlias(), "collations", NULL, &errorCode)); LocalUResourceBundlePointer data( - ures_getByKeyWithFallback(collations.getAlias(), collationType, NULL, &errorCode)); + ures_getByKeyWithFallback(collations.getAlias(), type, NULL, &errorCode)); int32_t length; const UChar *s = ures_getStringByKey(data.getAlias(), "Sequence", &length, &errorCode); if(U_FAILURE(errorCode)) { return NULL; } diff --git a/icu4c/source/test/testdata/collationtest.txt b/icu4c/source/test/testdata/collationtest.txt index 777ed15234e..74c46cbc419 100644 --- a/icu4c/source/test/testdata/collationtest.txt +++ b/icu4c/source/test/testdata/collationtest.txt @@ -2389,13 +2389,20 @@ <2 alà # backwards secondary level ** test: locale -u- with script reordering, ICU ticket 8260 -@ locale el-u-kr-kana-SYMBOL-Grek +@ locale el-u-kr-kana-SYMBOL-Grek-hani-cyrl-latn-digit-armn-deva-ethi-thai * compare <1 \u0020 <1 あ <1 ☂ <1 Ω +<1 丂 +<1 ж <1 L +<1 4 +<1 Ձ +<1 अ +<1 ሄ +<1 ฉ ** test: locale @collation=type should be case-insensitive @ locale de@coLLation=PhoneBook