diff --git a/icu4c/source/i18n/dcfmtsym.cpp b/icu4c/source/i18n/dcfmtsym.cpp index 8f709252ec1..f274cde02fc 100644 --- a/icu4c/source/i18n/dcfmtsym.cpp +++ b/icu4c/source/i18n/dcfmtsym.cpp @@ -146,7 +146,7 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status, } // If the array size is too small, something is wrong with the resource // bundle, returns the failure error code. - if (numberElementsLength < 11 || U_FAILURE(status)) { + if (numberElementsLength != 12 || U_FAILURE(status)) { status = U_INVALID_FORMAT_ERROR; } else { @@ -205,16 +205,8 @@ DecimalFormatSymbols::initialize(const UnicodeString* numberElements, int32_t nu fSymbols[kPadEscapeSymbol] = (UChar)0x002a; // TODO: '*' Hard coded for now; get from resource later fSymbols[kInfinitySymbol].fastCopyFrom(numberElements[9]); fSymbols[kNaNSymbol].fastCopyFrom(numberElements[10]); - - // If there is a currency decimal, use it. - fSymbols[kMonetarySeparatorSymbol].fastCopyFrom(numberElements[numberElementsLength >= 12 ? 11 : 0]); - if (numberElementsLength >= 13) { - fSymbols[kPlusSignSymbol].fastCopyFrom(numberElements[12]); - } - else { - /* This locale really needs to be updated. This locale is out of date. */ - fSymbols[kPlusSignSymbol] = (UChar)0x002B; /* + */ - } + fSymbols[kPlusSignSymbol].fastCopyFrom(numberElements[11]); + fSymbols[kMonetarySeparatorSymbol].fastCopyFrom(numberElements[0]); // Default values until it's set later on. fSymbols[kCurrencySymbol] = (UChar)0xa4; // 'OX' currency symbol diff --git a/icu4c/source/i18n/ucol.cpp b/icu4c/source/i18n/ucol.cpp index 0cda32022e9..74ff1f43417 100644 --- a/icu4c/source/i18n/ucol.cpp +++ b/icu4c/source/i18n/ucol.cpp @@ -7472,6 +7472,13 @@ ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int3 /* take the UCA rules and append real rules at the end */ /* UCA rules will be probably coming from the root RB */ ucaRules = ures_getStringByKey(coll->rb,"%%UCARULES",&UCAlen,&status); + /* + UResourceBundle* cresb = ures_getByKeyWithFallback(coll->rb, "collations", NULL, &status); + UResourceBundle* uca = ures_getByKeyWithFallback(cresb, "UCA", NULL, &status); + ucaRules = ures_getStringByKey(uca,"Sequence",&UCAlen,&status); + ures_close(uca); + ures_close(cresb); + */ } if(U_FAILURE(status)) { return 0; diff --git a/icu4c/source/i18n/ucurr.cpp b/icu4c/source/i18n/ucurr.cpp index 83fd500f9a4..8167ce1a915 100644 --- a/icu4c/source/i18n/ucurr.cpp +++ b/icu4c/source/i18n/ucurr.cpp @@ -41,7 +41,9 @@ static const int32_t MAX_POW10 = (sizeof(POW10)/sizeof(POW10[0])) - 1; //------------------------------------------------------------ // Resource tags +// +static const char CURRENCY_DATA[] = "CurrencyData"; // Tag for meta-data, in root. static const char CURRENCY_META[] = "CurrencyMeta"; @@ -109,10 +111,11 @@ _findMetaData(const UChar* currency, UErrorCode& ec) { // Get CurrencyMeta resource out of root locale file. [This may // move out of the root locale file later; if it does, update this // code.] - ResourceBundle currencyMeta = - ResourceBundle((char*)0, Locale(""), ec).get(CURRENCY_META, ec); + UResourceBundle* currencyData = ures_openDirect(NULL, CURRENCY_DATA, &ec); + UResourceBundle* currencyMeta = ures_getByKey(currencyData, CURRENCY_META, currencyData, &ec); if (U_FAILURE(ec)) { + ures_close(currencyMeta); // Config/build error; return hard-coded defaults return LAST_RESORT_DATA; } @@ -120,25 +123,32 @@ _findMetaData(const UChar* currency, UErrorCode& ec) { // Look up our currency, or if that's not available, then DEFAULT char buf[ISO_COUNTRY_CODE_LENGTH+1]; UErrorCode ec2 = U_ZERO_ERROR; // local error code: soft failure - ResourceBundle rb = currencyMeta.get(myUCharsToChars(buf, currency), ec2); - if (U_FAILURE(ec2)) { - rb = currencyMeta.get(DEFAULT_META, ec); + UResourceBundle* rb = ures_getByKey(currencyMeta, myUCharsToChars(buf, currency), NULL, &ec2); + if (U_FAILURE(ec2)) { + ures_close(rb); + rb = ures_getByKey(currencyMeta,DEFAULT_META, NULL, &ec); if (U_FAILURE(ec)) { + ures_close(currencyMeta); + ures_close(rb); // Config/build error; return hard-coded defaults return LAST_RESORT_DATA; } } int32_t len; - const int32_t *data = rb.getIntVector(len, ec); + const int32_t *data = ures_getIntVector(rb, &len, &ec); if (U_FAILURE(ec) || len != 2) { // Config/build error; return hard-coded defaults if (U_SUCCESS(ec)) { ec = U_INVALID_FORMAT_ERROR; } + ures_close(currencyMeta); + ures_close(rb); return LAST_RESORT_DATA; } + ures_close(currencyMeta); + ures_close(rb); return data; } @@ -334,7 +344,7 @@ ucurr_forLocale(const char* locale, #endif // Look up the CurrencyMap element in the root bundle. - UResourceBundle *rb = ures_open(NULL, "", &localStatus); + UResourceBundle *rb = ures_openDirect(NULL, CURRENCY_DATA, &localStatus); UResourceBundle *cm = ures_getByKey(rb, CURRENCY_MAP, rb, &localStatus); s = ures_getStringByKey(cm, id, &resLen, &localStatus); diff --git a/icu4c/source/test/cintltst/capitst.c b/icu4c/source/test/cintltst/capitst.c index 16b7ded5f01..c12f341b146 100644 --- a/icu4c/source/test/cintltst/capitst.c +++ b/icu4c/source/test/cintltst/capitst.c @@ -278,7 +278,7 @@ void TestProperty() ICU 2.4 currVersionArray = {0x21, 0x40, 0x04, 0x04}; ICU 2.6 currVersionArray = {0x21, 0x40, 0x03, 0x03}; */ - UVersionInfo currVersionArray = {0x29, 0x80, 0x01, 0x04}; + UVersionInfo currVersionArray = {0x29, 0x80, 0x00, 0x04}; UVersionInfo currUCAVersionArray = {4, 0, 0, 0}; UVersionInfo versionArray = {0, 0, 0, 0}; UVersionInfo versionUCAArray = {0, 0, 0, 0}; @@ -380,7 +380,7 @@ void TestProperty() buffer[0] = '\0'; log_verbose("ucol_getRulesEx() testing ...\n"); tempLength = ucol_getRulesEx(col,UCOL_TAILORING_ONLY,buffer,bufLen ); - doAssert( tempLength == 0x0f, "getRulesEx() result incorrect" ); + doAssert( tempLength == 0x0e, "getRulesEx() result incorrect" ); log_verbose("getRules tests end.\n"); log_verbose("ucol_getRulesEx() testing ...\n"); diff --git a/icu4c/source/test/cintltst/cloctst.c b/icu4c/source/test/cintltst/cloctst.c index 0d8b708b10b..1fa1c742bfd 100644 --- a/icu4c/source/test/cintltst/cloctst.c +++ b/icu4c/source/test/cintltst/cloctst.c @@ -1482,6 +1482,15 @@ TestKeyInRootRecursive(UResourceBundle *root, const char *rootName, ures_getSize(subRootBundle), ures_getSize(subBundle)); } + /* + if(isCurrencyPreEuro(subBundleKey) && ures_getSize(subBundle)!=3){ + log_err("Different size array with key \"%s\" in \"%s\" for locale \"%s\" the expected size is 3 got size=%d\n", + subBundleKey, + ures_getKey(currentBundle), + locale, + ures_getSize(subBundle)); + } + */ for (idx = 0; idx < minSize; idx++) { int32_t rootStrLen, localeStrLen; const UChar *rootStr = ures_getStringByIndex(subRootBundle,idx,&rootStrLen,&errorCode); diff --git a/icu4c/source/test/cintltst/cnumtst.c b/icu4c/source/test/cintltst/cnumtst.c index f1a0e4ddba0..28c0e663a24 100644 --- a/icu4c/source/test/cintltst/cnumtst.c +++ b/icu4c/source/test/cintltst/cnumtst.c @@ -290,7 +290,7 @@ free(result); if (U_FAILURE(status)) { log_err("Error in formatting using unum_formatDouble(.....): %s\n", myErrorName(status)); } - if (u_strcmp(result, temp1)==0) { + if (result && u_strcmp(result, temp1)==0) { log_verbose("Pass: Number Formatting using unum_formatDouble() Successful\n"); } else { log_err("FAIL: Error in number formatting using unum_formatDouble()\n"); diff --git a/icu4c/source/test/cintltst/crestst.c b/icu4c/source/test/cintltst/crestst.c index 57af1ecfa54..3a78d900252 100644 --- a/icu4c/source/test/cintltst/crestst.c +++ b/icu4c/source/test/cintltst/crestst.c @@ -437,7 +437,7 @@ static void TestFallback() status = U_ZERO_ERROR; /* OK first one. This should be a Default value. */ - subResource = ures_getByKey(fr_FR, "CurrencyMap", NULL, &status); + subResource = ures_getByKey(fr_FR, "MeasurementSystem", NULL, &status); if(status != U_USING_DEFAULT_WARNING) { log_data_err("Expected U_USING_DEFAULT_ERROR when trying to get CurrencyMap from fr_FR, got %s\n", diff --git a/icu4c/source/test/cintltst/creststn.c b/icu4c/source/test/cintltst/creststn.c index f91e5552c21..db3ddcef8ea 100644 --- a/icu4c/source/test/cintltst/creststn.c +++ b/icu4c/source/test/cintltst/creststn.c @@ -1340,7 +1340,7 @@ static void TestGetVersion(){ static void TestGetVersionColl(){ - UVersionInfo minVersionArray = {0x01, 0x00, 0x00, 0x00}; + UVersionInfo minVersionArray = {0x00, 0x00, 0x00, 0x00}; UVersionInfo maxVersionArray = {0x50, 0x80, 0xcf, 0xcf}; UVersionInfo versionArray; UErrorCode status= U_ZERO_ERROR; @@ -1367,7 +1367,7 @@ static void TestGetVersionColl(){ ures_close(resB); return; } - /* test NUL termination of UCARules */ + /* test NUL termination of UCARules rules = ures_getStringByKey(resB,"%%UCARULES",&len, &status); if(!rules || U_FAILURE(status)) { log_data_err("Could not load %%UCARULES for locale %s\n", locName); @@ -1376,6 +1376,7 @@ static void TestGetVersionColl(){ if(u_strlen(rules) != len){ log_err("UCARules string not nul terminated! \n"); } + */ ures_getVersion(resB, versionArray); for (i=0; i<4; ++i) { if (versionArray[i] < minVersionArray[i] || @@ -1961,7 +1962,7 @@ static void TestFallback() status = U_ZERO_ERROR; /* OK first one. This should be a Default value. */ - subResource = ures_getByKey(fr_FR, "CurrencyMap", NULL, &status); + subResource = ures_getByKey(fr_FR, "MeasurementSystem", NULL, &status); if(status != U_USING_DEFAULT_WARNING) { log_data_err("Expected U_USING_DEFAULT_ERROR when trying to get CurrencyMap from fr_FR, got %s\n", diff --git a/icu4c/source/test/intltest/apicoll.cpp b/icu4c/source/test/intltest/apicoll.cpp index d82a32d7c24..51daa3f3d8b 100644 --- a/icu4c/source/test/intltest/apicoll.cpp +++ b/icu4c/source/test/intltest/apicoll.cpp @@ -100,7 +100,7 @@ CollationAPITest::TestProperty(/* char* par */) ICU 2.4 currVersionArray = {0x21, 0x40, 0x04, 0x04}; ICU 2.6 currVersionArray = {0x21, 0x40, 0x03, 0x03}; */ - UVersionInfo currVersionArray = {0x29, 0x80, 0x01, 0x04}; + UVersionInfo currVersionArray = {0x29, 0x80, 0x00, 0x04}; UVersionInfo versionArray; int i = 0; @@ -355,7 +355,7 @@ CollationAPITest::TestRules() } coll->getRules(UCOL_TAILORING_ONLY, rules); - if (rules.length() != 0x0f) { + if (rules.length() != 0x0e) { errln("English tailored rules failed"); } diff --git a/icu4c/source/tools/genrb/parse.c b/icu4c/source/tools/genrb/parse.c index 033ae727c74..f0894e7c99a 100644 --- a/icu4c/source/tools/genrb/parse.c +++ b/icu4c/source/tools/genrb/parse.c @@ -591,6 +591,8 @@ addCollation(struct SResource *result, uint32_t startline, UErrorCode *status) UBool override = FALSE; uint32_t line; /* '{' . (name resource)* '}' */ + version[0]=0; version[1]=0; version[2]=0; version[3]=0; + for (;;) { ustr_init(&comment);