ICU-12576 Fixing test failures under --disable-release mode.

X-SVN-Rev: 38864
This commit is contained in:
Shane Carr 2016-06-18 01:37:37 +00:00
parent 8a19894b81
commit ae61a779f5
2 changed files with 9 additions and 8 deletions

View file

@ -678,10 +678,9 @@ DateTimePatternGenerator::hackTimes(const UnicodeString& hackPattern, UErrorCode
static const UChar hourFormatChars[] = { CAP_H, LOW_H, CAP_K, LOW_K, 0 }; // HhKk, the hour format characters
const char*
DateTimePatternGenerator::getCalendarTypeToUse(const Locale& locale, UErrorCode& err) {
const char* calendarTypeToUse = DT_DateTimeGregorianTag; // initial default
char calendarType[ULOC_KEYWORDS_CAPACITY]; // to be filled in with the type to use, if all goes well
void
DateTimePatternGenerator::getCalendarTypeToUse(const Locale& locale, CharString& destination, UErrorCode& err) {
destination.clear().append(DT_DateTimeGregorianTag, -1, err); // initial default
if ( U_SUCCESS(err) ) {
char localeWithCalendarKey[ULOC_LOCALE_IDENTIFIER_CAPACITY];
// obtain a locale that always has the calendar key value that should be used
@ -697,6 +696,7 @@ DateTimePatternGenerator::getCalendarTypeToUse(const Locale& locale, UErrorCode&
&err);
localeWithCalendarKey[ULOC_LOCALE_IDENTIFIER_CAPACITY-1] = 0; // ensure null termination
// now get the calendar key value from that locale
char calendarType[ULOC_KEYWORDS_CAPACITY];
int32_t calendarTypeLen = uloc_getKeywordValue(
localeWithCalendarKey,
"calendar",
@ -704,11 +704,11 @@ DateTimePatternGenerator::getCalendarTypeToUse(const Locale& locale, UErrorCode&
ULOC_KEYWORDS_CAPACITY,
&err);
if (U_SUCCESS(err) && calendarTypeLen < ULOC_KEYWORDS_CAPACITY) {
calendarTypeToUse = calendarType;
destination.clear().append(calendarType, -1, err);
if (U_FAILURE(err)) { return; }
}
err = U_ZERO_ERROR;
}
return calendarTypeToUse;
}
void
@ -858,7 +858,8 @@ DateTimePatternGenerator::addCLDRData(const Locale& locale, UErrorCode& errorCod
LocalUResourceBundlePointer rb(ures_open(NULL, locale.getName(), &errorCode));
if (U_FAILURE(errorCode)) { return; }
const char* calendarTypeToUse = getCalendarTypeToUse(locale, errorCode);
CharString calendarTypeToUse; // to be filled in with the type to use, if all goes well
getCalendarTypeToUse(locale, calendarTypeToUse, errorCode);
if (U_FAILURE(errorCode)) { return; }
// Local err to ignore resource not found exceptions

View file

@ -538,7 +538,7 @@ private:
void addCanonicalItems(UErrorCode &status);
void addICUPatterns(const Locale& locale, UErrorCode& status);
void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);
const char* getCalendarTypeToUse(const Locale& locale, UErrorCode& status);
void getCalendarTypeToUse(const Locale& locale, CharString& destination, UErrorCode& err);
void consumeShortTimePattern(const UnicodeString& shortTimePattern, UErrorCode& status);
void addCLDRData(const Locale& locale, UErrorCode& status);
UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status);