ICU-9139 UCONFIG_NO_CONVERSION=1 bug fix

X-SVN-Rev: 31561
This commit is contained in:
Markus Scherer 2012-03-01 23:50:07 +00:00
parent 66325c9f16
commit 1c360497c7
2 changed files with 15 additions and 15 deletions

View File

@ -221,7 +221,6 @@ DateIntervalInfo::initializeData(const Locale& locale, UErrorCode& err)
} }
const char *locName = locale.getName(); const char *locName = locale.getName();
char parentLocale[ULOC_FULLNAME_CAPACITY]; char parentLocale[ULOC_FULLNAME_CAPACITY];
int32_t locNameLen;
uprv_strcpy(parentLocale, locName); uprv_strcpy(parentLocale, locName);
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
Hashtable skeletonSet(FALSE, status); Hashtable skeletonSet(FALSE, status);
@ -335,19 +334,20 @@ DateIntervalInfo::initializeData(const Locale& locale, UErrorCode& err)
// Find the name of the appropriate parent locale (from %%Parent if present, else // Find the name of the appropriate parent locale (from %%Parent if present, else
// uloc_getParent on the actual locale name) // uloc_getParent on the actual locale name)
// (It would be nice to have a ures function that did this...) // (It would be nice to have a ures function that did this...)
int32_t locNameLen;
const UChar * parentUName = ures_getStringByKey(rb, "%%Parent", &locNameLen, &status); const UChar * parentUName = ures_getStringByKey(rb, "%%Parent", &locNameLen, &status);
if (U_SUCCESS(status) && status != U_USING_FALLBACK_WARNING) { if (U_SUCCESS(status) && status != U_USING_FALLBACK_WARNING && locNameLen < ULOC_FULLNAME_CAPACITY) {
u_austrncpy(parentLocale, parentUName, ULOC_FULLNAME_CAPACITY); // Should work on EBCDIC too? u_UCharsToChars(parentUName, parentLocale, locNameLen + 1);
} else { } else {
status = U_ZERO_ERROR; status = U_ZERO_ERROR;
// Get the actual name of the current locale being used // Get the actual name of the current locale being used
const char *curLocaleName=ures_getLocaleByType(rb, ULOC_ACTUAL_LOCALE, &status); const char *curLocaleName=ures_getLocaleByType(rb, ULOC_ACTUAL_LOCALE, &status);
if ( U_FAILURE(status) ) {
curLocaleName = parentLocale;
status = U_ZERO_ERROR;
}
locNameLen = uloc_getParent(curLocaleName, parentLocale, ULOC_FULLNAME_CAPACITY, &status);
if ( U_FAILURE(status) ) { if ( U_FAILURE(status) ) {
curLocaleName = parentLocale;
status = U_ZERO_ERROR;
}
uloc_getParent(curLocaleName, parentLocale, ULOC_FULLNAME_CAPACITY, &status);
if (U_FAILURE(err) || err == U_STRING_NOT_TERMINATED_WARNING) {
parentLocale[0] = 0; // just fallback to root, will cause us to stop parentLocale[0] = 0; // just fallback to root, will cause us to stop
status = U_ZERO_ERROR; status = U_ZERO_ERROR;
} }

View File

@ -608,7 +608,6 @@ DateTimePatternGenerator::addCLDRData(const Locale& locale, UErrorCode& err) {
// add available formats // add available formats
UBool firstTimeThrough = TRUE; UBool firstTimeThrough = TRUE;
char parentLocale[ULOC_FULLNAME_CAPACITY];
err = U_ZERO_ERROR; err = U_ZERO_ERROR;
initHashtable(err); initHashtable(err);
while (TRUE) { while (TRUE) {
@ -663,14 +662,15 @@ DateTimePatternGenerator::addCLDRData(const Locale& locale, UErrorCode& err) {
// uloc_getParent on the actual locale name) // uloc_getParent on the actual locale name)
// (It would be nice to have a ures function that did this...) // (It would be nice to have a ures function that did this...)
err = U_ZERO_ERROR; err = U_ZERO_ERROR;
char parentLocale[ULOC_FULLNAME_CAPACITY];
int32_t locNameLen; int32_t locNameLen;
const UChar * parentUName = ures_getStringByKey(rb, "%%Parent", &locNameLen, &err); const UChar * parentUName = ures_getStringByKey(rb, "%%Parent", &locNameLen, &err);
if (U_SUCCESS(err) && err != U_USING_FALLBACK_WARNING) { if (U_SUCCESS(err) && err != U_USING_FALLBACK_WARNING && locNameLen < ULOC_FULLNAME_CAPACITY) {
u_austrncpy(parentLocale, parentUName, ULOC_FULLNAME_CAPACITY); // Should work on EBCDIC too? u_UCharsToChars(parentUName, parentLocale, locNameLen + 1);
} else { } else {
err = U_ZERO_ERROR; err = U_ZERO_ERROR;
locNameLen = uloc_getParent(curLocaleName, parentLocale, ULOC_FULLNAME_CAPACITY, &err); uloc_getParent(curLocaleName, parentLocale, ULOC_FULLNAME_CAPACITY, &err);
if ( U_FAILURE(err) ) { if (U_FAILURE(err) || err == U_STRING_NOT_TERMINATED_WARNING) {
// just fallback to root, since we are not already there // just fallback to root, since we are not already there
parentLocale[0] = 0; parentLocale[0] = 0;
err = U_ZERO_ERROR; err = U_ZERO_ERROR;