forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1504656 - Add patch to workaround ICU bug in RelativeDateTimeCach…
…eData::getRelativeDateTimeUnitFormatter. r=jwalden --HG-- extra : rebase_source : f70c72f9aa04e1adceb88ddfd8764c0de20f43a8
- Loading branch information
Showing
4 changed files
with
74 additions
and
7 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
intl/icu-patches/bug-1504656-relativetimeformat-plural-other-fallback.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
js/src/tests/non262/Intl/RelativeTimeFormat/locale-fallback-handling.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); |