ICU-9965 Don't skip availableFormats items from non-root locales if conflict only due to basePattern (C)
X-SVN-Rev: 33360
This commit is contained in:
parent
3451781673
commit
bc29c28e46
@ -610,6 +610,7 @@ DateTimePatternGenerator::addCLDRData(const Locale& locale, UErrorCode& err) {
|
||||
UBool firstTimeThrough = TRUE;
|
||||
err = U_ZERO_ERROR;
|
||||
initHashtable(err);
|
||||
UBool override = TRUE;
|
||||
while (TRUE) {
|
||||
// At the start of the loop:
|
||||
// - rb is the open resource bundle for the current locale being processed,
|
||||
@ -640,7 +641,7 @@ DateTimePatternGenerator::addCLDRData(const Locale& locale, UErrorCode& err) {
|
||||
setAvailableFormat(retKey, err);
|
||||
// Add pattern with its associated skeleton. Override any duplicate derived from std patterns,
|
||||
// but not a previous availableFormats entry:
|
||||
addPatternWithSkeleton(format, &retKey, TRUE, conflictingPattern, err);
|
||||
addPatternWithSkeleton(format, &retKey, override, conflictingPattern, err);
|
||||
}
|
||||
}
|
||||
#if defined(U_USE_ASCII_BUNDLE_ITERATOR)
|
||||
@ -690,6 +691,9 @@ DateTimePatternGenerator::addCLDRData(const Locale& locale, UErrorCode& err) {
|
||||
curLocaleName = parentLocale;
|
||||
err = U_ZERO_ERROR;
|
||||
}
|
||||
if (uprv_strcmp(curLocaleName,"root")==0 || uprv_strlen(curLocaleName)==0) {
|
||||
override = FALSE;
|
||||
}
|
||||
// Open calBundle and calTypeBundle
|
||||
calBundle = ures_getByKeyWithFallback(rb, DT_DateTimeCalendarTag, NULL, &err);
|
||||
if (U_SUCCESS(err)) {
|
||||
@ -920,15 +924,26 @@ DateTimePatternGenerator::addPatternWithSkeleton(
|
||||
matcher.set(*skeletonToUse, fp, skeleton); // no longer trims skeleton fields to max len 3, per #7930
|
||||
matcher.getBasePattern(basePattern); // or perhaps instead: basePattern = *skeletonToUse;
|
||||
}
|
||||
// We only care about base conflicts - and replacing the pattern associated with a base - if:
|
||||
// 1. the conflicting previous base pattern did *not* have an explicit skeleton; in that case the previous
|
||||
// base + pattern combination was derived from either (a) a canonical item, (b) a standard format, or
|
||||
// (c) a pattern specified programmatically with a previous call to addPattern (which would only happen
|
||||
// if we are getting here from a subsequent call to addPattern).
|
||||
// 2. a skeleton is specified for the current pattern, but override=false; in that case we are checking
|
||||
// availableFormats items from root, which should not override any previous entry with the same base.
|
||||
UBool entryHadSpecifiedSkeleton;
|
||||
const UnicodeString *duplicatePattern = patternMap->getPatternFromBasePattern(basePattern, entryHadSpecifiedSkeleton);
|
||||
if (duplicatePattern != NULL ) {
|
||||
if (duplicatePattern != NULL && (!entryHadSpecifiedSkeleton || (skeletonToUse != NULL && !override))) {
|
||||
conflictingStatus = UDATPG_BASE_CONFLICT;
|
||||
conflictingPattern = *duplicatePattern;
|
||||
if (!override || (skeletonToUse != NULL && entryHadSpecifiedSkeleton)) {
|
||||
if (!override) {
|
||||
return conflictingStatus;
|
||||
}
|
||||
}
|
||||
// The only time we get here with override=true and skeletonToUse!=null is when adding availableFormats
|
||||
// items from CLDR data. In that case, we don't want an item from a parent locale to replace an item with
|
||||
// same skeleton from the specified locale, so skip the current item if skeletonWasSpecified is true for
|
||||
// the previously-specified conflicting item.
|
||||
const PtnSkeleton* entrySpecifiedSkeleton = NULL;
|
||||
duplicatePattern = patternMap->getPatternFromSkeleton(skeleton, &entrySpecifiedSkeleton);
|
||||
if (duplicatePattern != NULL ) {
|
||||
@ -1394,6 +1409,9 @@ PatternMap::add(const UnicodeString& basePattern,
|
||||
}
|
||||
// Overwrite the value.
|
||||
curElem->pattern = value;
|
||||
// It was a bug that we were not doing the following previously,
|
||||
// though that bug hid other problems by making things partly work.
|
||||
curElem->skeletonWasSpecified = skeletonWasSpecified;
|
||||
}
|
||||
}
|
||||
} // PatternMap::add
|
||||
|
@ -241,9 +241,9 @@ void IntlTestDateTimePatternGeneratorAPI::testAPI(/*char *par*/)
|
||||
// ru // 9 ru
|
||||
UnicodeString("01.1999"), // 00: yM -> MM.y
|
||||
CharsToUnicodeString("\\u042F\\u043D\\u0432. 1999"), // 01: yMMM -> LLL y
|
||||
UnicodeString("13.01.1999"), // 02: yMd -> d.MM.y
|
||||
UnicodeString("13.01.1999"), // 02: yMd -> dd.MM.y
|
||||
CharsToUnicodeString("13 \\u044F\\u043D\\u0432. 1999 \\u0433."), // 03: yMMMd -> d MMM y
|
||||
UnicodeString("13.1"), // 04: Md -> d.M
|
||||
UnicodeString("13.01"), // 04: Md -> dd.MM
|
||||
CharsToUnicodeString("13 \\u044F\\u043D\\u0432."), // 05: MMMd -> d MMM
|
||||
CharsToUnicodeString("13 \\u044F\\u043D\\u0432\\u0430\\u0440\\u044F"), // 06: MMMMd -> d MMMM
|
||||
CharsToUnicodeString("1-\\u0439 \\u043A\\u0432. 1999 \\u0433."), // 07: yQQQ -> y QQQ
|
||||
|
Loading…
Reference in New Issue
Block a user