Bug 1533481 - Part 3: Remove no longer needed ICU patches or update to apply cleanly. r=jwalden!

Summary:

- Local patches for bug 1504656 and bug 1513934 are now present upstream.
- Patch for bug 1172609 needed to be rebased to apply cleanly.
- Update patch for bug 1172609 to follow new static mutex handling in ICU.

Reviewers: jwalden

Reviewed By: jwalden

Bug #: 1533481

Differential Revision: https://phabricator.services.mozilla.com/D25263

--HG--
extra : rebase_source : 2e1d2974394e336d714b16642dd9d02b226300c2
This commit is contained in:
André Bargull 2019-04-04 11:52:36 +03:00
parent 9402679b29
commit 0786be3f1f
5 changed files with 17 additions and 126 deletions

View File

@ -3,7 +3,7 @@
diff --git a/intl/icu/source/i18n/timezone.cpp b/intl/icu/source/i18n/timezone.cpp
--- a/intl/icu/source/i18n/timezone.cpp
+++ b/intl/icu/source/i18n/timezone.cpp
@@ -108,16 +108,19 @@ static const UChar WORLD[] = {0x
@@ -110,16 +110,22 @@ static const UChar WORLD[] = {0x30, 0x30, 0x31, 0x00}; /* "001" */
static const UChar GMT_ID[] = {0x47, 0x4D, 0x54, 0x00}; /* "GMT" */
static const UChar UNKNOWN_ZONE_ID[] = {0x45, 0x74, 0x63, 0x2F, 0x55, 0x6E, 0x6B, 0x6E, 0x6F, 0x77, 0x6E, 0x00}; /* "Etc/Unknown" */
static const int32_t GMT_ID_LENGTH = 3;
@ -13,17 +13,20 @@ diff --git a/intl/icu/source/i18n/timezone.cpp b/intl/icu/source/i18n/timezone.c
static icu::UInitOnce gDefaultZoneInitOnce = U_INITONCE_INITIALIZER;
+// Prevents DEFAULT_ZONE from being deleted while another thread is cloning it.
+static UMutex gDefaultZoneMutex = U_MUTEX_INITIALIZER;
+static icu::UMutex* defaultZoneMutex() {
+ static icu::UMutex gDefaultZoneMutex = U_MUTEX_INITIALIZER;
+ return &gDefaultZoneMutex;
+}
+
static icu::TimeZone* _GMT = NULL;
static icu::TimeZone* _UNKNOWN_ZONE = NULL;
alignas(icu::SimpleTimeZone)
static char gRawGMT[sizeof(icu::SimpleTimeZone)];
alignas(icu::SimpleTimeZone)
static char gRawUNKNOWN[sizeof(icu::SimpleTimeZone)];
static icu::UInitOnce gStaticZonesInitOnce = U_INITONCE_INITIALIZER;
static char TZDATA_VERSION[16];
static icu::UInitOnce gTZDataVersionInitOnce = U_INITONCE_INITIALIZER;
static int32_t* MAP_SYSTEM_ZONES = NULL;
@@ -554,26 +557,36 @@ static void U_CALLCONV initDefault()
static UBool gStaticZonesInitialized = FALSE; // Whether the static zones are initialized and ready to use.
@@ -566,26 +572,36 @@ static void U_CALLCONV initDefault()
}
// -------------------------------------
@ -33,7 +36,7 @@ diff --git a/intl/icu/source/i18n/timezone.cpp b/intl/icu/source/i18n/timezone.c
{
umtx_initOnce(gDefaultZoneInitOnce, initDefault);
+
+ Mutex mutex_lock(&gDefaultZoneMutex);
+ icu::Mutex mutex_lock(defaultZoneMutex());
return (DEFAULT_ZONE != NULL) ? DEFAULT_ZONE->clone() : NULL;
}
@ -51,7 +54,7 @@ diff --git a/intl/icu/source/i18n/timezone.cpp b/intl/icu/source/i18n/timezone.c
{
if (zone != NULL)
{
+ Mutex mutex_lock(&gDefaultZoneMutex);
+ icu::Mutex mutex_lock(defaultZoneMutex());
TimeZone *old = DEFAULT_ZONE;
DEFAULT_ZONE = zone;
delete old;
@ -63,11 +66,11 @@ diff --git a/intl/icu/source/i18n/timezone.cpp b/intl/icu/source/i18n/timezone.c
diff --git a/intl/icu/source/i18n/unicode/timezone.h b/intl/icu/source/i18n/unicode/timezone.h
--- a/intl/icu/source/i18n/unicode/timezone.h
+++ b/intl/icu/source/i18n/unicode/timezone.h
@@ -299,16 +299,19 @@ public:
* and made the default.
@@ -310,16 +310,19 @@ class U_I18N_API TimeZone : public UObject {
*
* @return A default TimeZone. Clients are responsible for deleting the time zone
* object returned.
* @see getUnknown
* @stable ICU 2.0
*/
static TimeZone* U_EXPORT2 createDefault(void);

View File

@ -1,45 +0,0 @@
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;

View File

@ -1,42 +0,0 @@
From 9a2c52d1744abaa57defc5f2fb25927ae16a3a0e Mon Sep 17 00:00:00 2001
From: Jeff Genovy <29107334+jefgen@users.noreply.github.com>
Date: Wed, 12 Dec 2018 19:42:48 -0800
Subject: [PATCH] ICU-20302 Timezone detection fails on Windows 7. Also add a
test case for Windows time zone detection failing.
---
icu4c/source/common/wintz.cpp | 6 +++---
icu4c/source/test/cintltst/putiltst.c | 11 +++++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/intl/icu/source/common/wintz.cpp b/intl/icu/source/common/wintz.cpp
index 5e9ac0d2f37..8a143d9e782 100644
--- a/intl/icu/source/common/wintz.cpp
+++ b/intl/icu/source/common/wintz.cpp
@@ -35,7 +35,7 @@
U_NAMESPACE_BEGIN
-// The value of MAX_TIMEZONE_ID_LENGTH is 128, which is defined in DYNAMIC_TIME_ZONE_INFORMATION
+// The max size of TimeZoneKeyName is 128, defined in DYNAMIC_TIME_ZONE_INFORMATION
#define MAX_TIMEZONE_ID_LENGTH 128
/**
@@ -44,7 +44,7 @@ U_NAMESPACE_BEGIN
* Note: We use the Win32 API GetDynamicTimeZoneInformation to get the current time zone info.
* This API returns a non-localized time zone name, which we can then map to an ICU time zone name.
*/
-U_CFUNC const char* U_EXPORT2
+U_INTERNAL const char* U_EXPORT2
uprv_detectWindowsTimeZone()
{
UErrorCode status = U_ZERO_ERROR;
@@ -79,7 +79,7 @@ uprv_detectWindowsTimeZone()
// convert from wchar_t* (UTF-16 on Windows) to char* (UTF-8).
u_strToUTF8(dynamicTZKeyName, UPRV_LENGTHOF(dynamicTZKeyName), nullptr,
- reinterpret_cast<const UChar*>(dynamicTZI.TimeZoneKeyName), UPRV_LENGTHOF(dynamicTZI.TimeZoneKeyName), &status);
+ reinterpret_cast<const UChar*>(dynamicTZI.TimeZoneKeyName), -1, &status);
if (U_FAILURE(status)) {
return nullptr;

View File

@ -1,22 +0,0 @@
From 3c644c62c71c890424ef5d20caa2f9dc354e02d6 Mon Sep 17 00:00:00 2001
From: Jeff Genovy <Jeff.Genovy@microsoft.com>
Date: Fri, 14 Dec 2018 00:56:51 -0800
Subject: [PATCH] ICU-20302 Fix wintz header file. (Thanks to Jungshik).
---
icu4c/source/common/wintz.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/intl/icu/source/common/wintz.h b/intl/icu/source/common/wintz.h
index f98b1779b5d..cd8565eef1e 100644
--- a/intl/icu/source/common/wintz.h
+++ b/intl/icu/source/common/wintz.h
@@ -28,7 +28,7 @@ U_CDECL_BEGIN
typedef struct _TIME_ZONE_INFORMATION TIME_ZONE_INFORMATION;
U_CDECL_END
-U_CFUNC const char* U_EXPORT2
+U_INTERNAL const char* U_EXPORT2
uprv_detectWindowsTimeZone();
#endif /* U_PLATFORM_USES_ONLY_WIN32_API */

View File

@ -86,9 +86,6 @@ 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 \
bug-1513934-timezone-detection-win7-part1.diff \
bug-1513934-timezone-detection-win7-part2.diff \
; do
echo "Applying local patch $patch"
patch -d ${icu_dir}/../../ -p1 --no-backup-if-mismatch < ${icu_dir}/../icu-patches/$patch