зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1504656 - Add patch to workaround ICU bug in RelativeDateTimeCacheData::getRelativeDateTimeUnitFormatter. r=jwalden
--HG-- extra : rebase_source : f70c72f9aa04e1adceb88ddfd8764c0de20f43a8
This commit is contained in:
Родитель
2ea3c4dbf3
Коммит
47daacbeee
|
@ -0,0 +1,45 @@
|
|||
Workaround for https://unicode-org.atlassian.net/browse/ICU-20253
|
||||
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1504656
|
||||
|
||||
diff --git a/intl/icu/source/i18n/reldatefmt.cpp b/intl/icu/source/i18n/reldatefmt.cpp
|
||||
--- a/intl/icu/source/i18n/reldatefmt.cpp
|
||||
+++ b/intl/icu/source/i18n/reldatefmt.cpp
|
||||
@@ -157,24 +157,30 @@ const UnicodeString& RelativeDateTimeCac
|
||||
}
|
||||
|
||||
// Use fallback cache for SimpleFormatter relativeUnits.
|
||||
const SimpleFormatter* RelativeDateTimeCacheData::getRelativeDateTimeUnitFormatter(
|
||||
int32_t fStyle,
|
||||
URelativeDateTimeUnit unit,
|
||||
int32_t pastFutureIndex,
|
||||
int32_t pluralUnit) const {
|
||||
- int32_t style = fStyle;
|
||||
- do {
|
||||
- if (relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit] != nullptr) {
|
||||
- return relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit];
|
||||
+ while (true) {
|
||||
+ int32_t style = fStyle;
|
||||
+ do {
|
||||
+ if (relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit] != nullptr) {
|
||||
+ return relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit];
|
||||
+ }
|
||||
+ style = fallBackCache[style];
|
||||
+ } while (style != -1);
|
||||
+
|
||||
+ if (pluralUnit == StandardPlural::OTHER) {
|
||||
+ return nullptr; // No formatter found.
|
||||
}
|
||||
- style = fallBackCache[style];
|
||||
- } while (style != -1);
|
||||
- return nullptr; // No formatter found.
|
||||
+ pluralUnit = StandardPlural::OTHER;
|
||||
+ }
|
||||
}
|
||||
|
||||
static UBool getStringWithFallback(
|
||||
const UResourceBundle *resource,
|
||||
const char *key,
|
||||
UnicodeString &result,
|
||||
UErrorCode &status) {
|
||||
int32_t len = 0;
|
|
@ -162,14 +162,20 @@ const UnicodeString& RelativeDateTimeCacheData::getAbsoluteUnitString(
|
|||
URelativeDateTimeUnit unit,
|
||||
int32_t pastFutureIndex,
|
||||
int32_t pluralUnit) const {
|
||||
int32_t style = fStyle;
|
||||
do {
|
||||
if (relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit] != nullptr) {
|
||||
return relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit];
|
||||
while (true) {
|
||||
int32_t style = fStyle;
|
||||
do {
|
||||
if (relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit] != nullptr) {
|
||||
return relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit];
|
||||
}
|
||||
style = fallBackCache[style];
|
||||
} while (style != -1);
|
||||
|
||||
if (pluralUnit == StandardPlural::OTHER) {
|
||||
return nullptr; // No formatter found.
|
||||
}
|
||||
style = fallBackCache[style];
|
||||
} while (style != -1);
|
||||
return nullptr; // No formatter found.
|
||||
pluralUnit = StandardPlural::OTHER;
|
||||
}
|
||||
}
|
||||
|
||||
static UBool getStringWithFallback(
|
||||
|
|
|
@ -86,6 +86,7 @@ for patch in \
|
|||
suppress-warnings.diff \
|
||||
bug-1172609-timezone-recreateDefault.diff \
|
||||
bug-1198952-workaround-make-3.82-bug.diff \
|
||||
bug-1504656-relativetimeformat-plural-other-fallback.diff \
|
||||
; do
|
||||
echo "Applying local patch $patch"
|
||||
patch -d ${icu_dir}/../../ -p1 --no-backup-if-mismatch < ${icu_dir}/../icu-patches/$patch
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("Intl"))
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// In locales that don't have a relative-date/time formatter -- and presently
|
||||
// "ak" is such a locale -- behavior is expected to fall back to the root-locale
|
||||
// formatter. This test verifies such fallback works as long as "ak" satisfies
|
||||
// these properties; "ak" may safely be changed to a different locale if that
|
||||
// ever changes. See bug 1504656.
|
||||
assertEq(new Intl.RelativeTimeFormat("ak").format(1, "second"),
|
||||
"+1 s");
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(0, 0, 'ok');
|
Загрузка…
Ссылка в новой задаче