Bug 1172609 - Part 8: Fix the tz detection code. r=waldo

This commit is contained in:
Ted Clancy 2015-08-05 19:05:04 -07:00
parent 8ca2499a93
commit a332a1cb18
5 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,81 @@
This patch is taken from the version of ICU in Google's Chromium.
See: https://chromium.googlesource.com/chromium/deps/icu/+/10834e84d250eb31a73496bfdb7923eaa43ead51
diff --git a/intl/icu/source/common/putil.cpp b/intl/icu/source/common/putil.cpp
--- a/intl/icu/source/common/putil.cpp
+++ b/intl/icu/source/common/putil.cpp
@@ -965,16 +965,25 @@ static char* searchForTZFile(const char*
}
}
}
}
closedir(dirp);
return result;
}
#endif
+
+U_CAPI void U_EXPORT2
+uprv_tzname_clear_cache()
+{
+#if defined(CHECK_LOCALTIME_LINK) && !defined(DEBUG_SKIP_LOCALTIME_LINK)
+ gTimeZoneBufferPtr = NULL;
+#endif
+}
+
U_CAPI const char* U_EXPORT2
uprv_tzname(int n)
{
const char *tzid = NULL;
#if U_PLATFORM_USES_ONLY_WIN32_API
tzid = uprv_detectWindowsTimeZone();
if (tzid != NULL) {
diff --git a/intl/icu/source/common/putilimp.h b/intl/icu/source/common/putilimp.h
--- a/intl/icu/source/common/putilimp.h
+++ b/intl/icu/source/common/putilimp.h
@@ -478,16 +478,22 @@ U_INTERNAL int32_t U_EXPORT2 uprv_timez
* tzname(1) Three-letter DST zone name derived from TZ environment
* variable. E.g., "PDT". If DST zone is omitted from TZ,
* tzname(1) is an empty string.
* @internal
*/
U_INTERNAL const char* U_EXPORT2 uprv_tzname(int n);
/**
+ * Reset the global tzname cache.
+ * @internal
+ */
+U_INTERNAL void uprv_tzname_clear_cache();
+
+/**
* Get UTC (GMT) time measured in milliseconds since 0:00 on 1/1/1970.
* This function is affected by 'faketime' and should be the bottleneck for all user-visible ICU time functions.
* @return the UTC time measured in milliseconds
* @internal
*/
U_INTERNAL UDate U_EXPORT2 uprv_getUTCtime(void);
/**
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
@@ -453,16 +453,18 @@ TimeZone::detectHostTimeZone()
int32_t rawOffset = 0;
const char *hostID;
// First, try to create a system timezone, based
// on the string ID in tzname[0].
uprv_tzset(); // Initialize tz... system data
+ uprv_tzname_clear_cache();
+
// Get the timezone ID from the host. This function should do
// any required host-specific remapping; e.g., on Windows this
// function maps the Date and Time control panel setting to an
// ICU timezone ID.
hostID = uprv_tzname(0);
// Invert sign because UNIX semantics are backwards
rawOffset = uprv_timezone() * -U_MILLIS_PER_SECOND;

View File

@ -970,6 +970,15 @@ static char* searchForTZFile(const char* path, DefaultTZInfo* tzInfo) {
return result;
}
#endif
U_CAPI void U_EXPORT2
uprv_tzname_clear_cache()
{
#if defined(CHECK_LOCALTIME_LINK) && !defined(DEBUG_SKIP_LOCALTIME_LINK)
gTimeZoneBufferPtr = NULL;
#endif
}
U_CAPI const char* U_EXPORT2
uprv_tzname(int n)
{

View File

@ -482,6 +482,12 @@ U_INTERNAL int32_t U_EXPORT2 uprv_timezone(void);
*/
U_INTERNAL const char* U_EXPORT2 uprv_tzname(int n);
/**
* Reset the global tzname cache.
* @internal
*/
U_INTERNAL void uprv_tzname_clear_cache();
/**
* Get UTC (GMT) time measured in milliseconds since 0:00 on 1/1/1970.
* This function is affected by 'faketime' and should be the bottleneck for all user-visible ICU time functions.

View File

@ -458,6 +458,8 @@ TimeZone::detectHostTimeZone()
uprv_tzset(); // Initialize tz... system data
uprv_tzname_clear_cache();
// Get the timezone ID from the host. This function should do
// any required host-specific remapping; e.g., on Windows this
// function maps the Date and Time control panel setting to an

View File

@ -55,6 +55,7 @@ svn info $1 | grep -v '^Revision: [[:digit:]]\+$' > ${icu_dir}/SVN-INFO
patch -d ${icu_dir}/../../ -p1 < ${icu_dir}/../icu-patches/bug-915735
patch -d ${icu_dir}/../../ -p1 < ${icu_dir}/../icu-patches/suppress-warnings.diff
patch -d ${icu_dir}/../../ -p1 < ${icu_dir}/../icu-patches/pkgdata-large-buffer.diff
patch -d ${icu_dir}/../../ -p1 < ${icu_dir}/../icu-patches/bug-1172609-icu-fix.diff
# NOTE: If you're updating this script for a new ICU version, you have to rerun
# js/src/tests/ecma_6/String/make-normalize-generateddata-input.py for any