ICU-3925 various fixes

X-SVN-Rev: 16159
This commit is contained in:
Ram Viswanadha 2004-08-13 20:34:31 +00:00
parent cbe2b49624
commit 15bd863941
10 changed files with 48 additions and 27 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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",

View file

@ -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",

View file

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

View file

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