ICU-5270 don't crash on no data

X-SVN-Rev: 19859
This commit is contained in:
Steven R. Loomis 2006-07-19 20:24:02 +00:00
parent cd14374897
commit 464a6d6a0c

View File

@ -685,20 +685,24 @@ Calendar::createInstance(TimeZone* zone, const Locale& aLocale, UErrorCode& succ
else
#endif
{
UErrorCode feErr;
char calLocaleType[ULOC_FULLNAME_CAPACITY];
calLocaleType[0] = 0; // NULL terminate
int32_t keywordCapacity = aLocale.getKeywordValue("calendar", calLocaleType, sizeof(calLocaleType)-1, success);
if (keywordCapacity == 0) {
char funcEquiv[ULOC_FULLNAME_CAPACITY];
feErr = success;
// fetch default calendar id
ures_getFunctionalEquivalent(funcEquiv, sizeof(funcEquiv)-1,
NULL, "calendar", "calendar",
aLocale.getName(),
NULL, FALSE, &success);
NULL, FALSE, &feErr);
keywordCapacity = uloc_getKeywordValue(funcEquiv, "calendar", calLocaleType,
sizeof(calLocaleType)-1, &success);
if (keywordCapacity == 0 || U_FAILURE(success)) {
sizeof(calLocaleType)-1, &feErr); // This can fail if there is no data.
// Don't want to stop calendar construction just because we couldn't get this type.
if (keywordCapacity == 0 || U_FAILURE(feErr)) {
// no calendar type. Default to nothing.
calLocaleType[0] = 0;
}