From 418dd68b611cce7e916dae82c75cb3d63b3c43a6 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Sat, 2 Nov 2019 18:08:46 -0700 Subject: tools: update icu to 65.1 Update the version of the bundled ICU (deps/icu-small) to ICU version 65.2. Fixes: https://github.com/nodejs/node/issues/30211 Fixes: https://github.com/nodejs/node/issues/29540 PR-URL: https://github.com/nodejs/node/pull/30232 Reviewed-By: Steven R Loomis Reviewed-By: Michael Dawson Reviewed-By: Ujjwal Sharma --- deps/icu-small/source/i18n/tznames_impl.cpp | 39 ++++++++++++++++------------- 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'deps/icu-small/source/i18n/tznames_impl.cpp') diff --git a/deps/icu-small/source/i18n/tznames_impl.cpp b/deps/icu-small/source/i18n/tznames_impl.cpp index d6e0ee2fbb..180b7fefbf 100644 --- a/deps/icu-small/source/i18n/tznames_impl.cpp +++ b/deps/icu-small/source/i18n/tznames_impl.cpp @@ -21,11 +21,14 @@ #include "unicode/utf16.h" #include "tznames_impl.h" +#include "bytesinkutil.h" +#include "charstr.h" #include "cmemory.h" #include "cstring.h" #include "uassert.h" #include "mutex.h" #include "resource.h" +#include "ulocimp.h" #include "uresimp.h" #include "ureslocs.h" #include "zonemeta.h" @@ -49,10 +52,7 @@ static const UChar NO_NAME[] = { 0 }; // for empty no-fallback time static const char* TZDBNAMES_KEYS[] = {"ss", "sd"}; static const int32_t TZDBNAMES_KEYS_SIZE = UPRV_LENGTHOF(TZDBNAMES_KEYS); -static UMutex *gDataMutex() { - static UMutex m = U_MUTEX_INITIALIZER; - return &m; -} +static UMutex gDataMutex; static UHashtable* gTZDBNamesMap = NULL; static icu::UInitOnce gTZDBNamesMapInitOnce = U_INITONCE_INITIALIZER; @@ -388,7 +388,7 @@ TextTrieMap::search(const UnicodeString &text, int32_t start, // Don't do unless it's really required. // Mutex for protecting the lazy creation of the Trie node structure on the first call to search(). - static UMutex TextTrieMutex = U_MUTEX_INITIALIZER; + static UMutex TextTrieMutex; Mutex lock(&TextTrieMutex); if (fLazyContents != NULL) { @@ -1113,7 +1113,7 @@ TimeZoneNamesImpl::operator==(const TimeZoneNames& other) const { return FALSE; } -TimeZoneNames* +TimeZoneNamesImpl* TimeZoneNamesImpl::clone() const { UErrorCode status = U_ZERO_ERROR; return new TimeZoneNamesImpl(fLocale, status); @@ -1214,7 +1214,7 @@ TimeZoneNamesImpl::getMetaZoneDisplayName(const UnicodeString& mzID, TimeZoneNamesImpl *nonConstThis = const_cast(this); { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); UErrorCode status = U_ZERO_ERROR; znames = nonConstThis->loadMetaZoneNames(mzID, status); if (U_FAILURE(status)) { return name; } @@ -1240,7 +1240,7 @@ TimeZoneNamesImpl::getTimeZoneDisplayName(const UnicodeString& tzID, UTimeZoneNa TimeZoneNamesImpl *nonConstThis = const_cast(this); { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); UErrorCode status = U_ZERO_ERROR; tznames = nonConstThis->loadTimeZoneNames(tzID, status); if (U_FAILURE(status)) { return name; } @@ -1263,7 +1263,7 @@ TimeZoneNamesImpl::getExemplarLocationName(const UnicodeString& tzID, UnicodeStr TimeZoneNamesImpl *nonConstThis = const_cast(this); { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); UErrorCode status = U_ZERO_ERROR; tznames = nonConstThis->loadTimeZoneNames(tzID, status); if (U_FAILURE(status)) { return name; } @@ -1358,7 +1358,7 @@ TimeZoneNamesImpl::find(const UnicodeString& text, int32_t start, uint32_t types // Synchronize so that data is not loaded multiple times. // TODO: Consider more fine-grained synchronization. { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); // First try of lookup. matches = doFind(handler, text, start, status); @@ -1585,7 +1585,7 @@ void TimeZoneNamesImpl::loadAllDisplayNames(UErrorCode& status) { if (U_FAILURE(status)) return; { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); internalLoadAllDisplayNames(status); } } @@ -1602,7 +1602,7 @@ void TimeZoneNamesImpl::getDisplayNames(const UnicodeString& tzID, // Load the time zone strings { - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); tznames = (void*) nonConstThis->loadTimeZoneNames(tzID, status); if (U_FAILURE(status)) { return; } } @@ -1622,7 +1622,7 @@ void TimeZoneNamesImpl::getDisplayNames(const UnicodeString& tzID, } else { // Load the meta zone strings // Mutex is scoped to the "else" statement - Mutex lock(gDataMutex()); + Mutex lock(&gDataMutex); mznames = (void*) nonConstThis->loadMetaZoneNames(mzID, status); if (U_FAILURE(status)) { return; } // Note: when the metazone doesn't exist, in Java, loadMetaZoneNames returns @@ -2135,9 +2135,12 @@ TZDBTimeZoneNames::TZDBTimeZoneNames(const Locale& locale) int32_t regionLen = static_cast(uprv_strlen(region)); if (regionLen == 0) { UErrorCode status = U_ZERO_ERROR; - char loc[ULOC_FULLNAME_CAPACITY]; - uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status); - regionLen = uloc_getCountry(loc, fRegion, sizeof(fRegion), &status); + CharString loc; + { + CharStringByteSink sink(&loc); + ulocimp_addLikelySubtags(fLocale.getName(), sink, &status); + } + regionLen = uloc_getCountry(loc.data(), fRegion, sizeof(fRegion), &status); if (U_SUCCESS(status) && regionLen < (int32_t)sizeof(fRegion)) { useWorld = FALSE; } @@ -2162,7 +2165,7 @@ TZDBTimeZoneNames::operator==(const TimeZoneNames& other) const { return FALSE; } -TimeZoneNames* +TZDBTimeZoneNames* TZDBTimeZoneNames::clone() const { return new TZDBTimeZoneNames(fLocale); } @@ -2247,7 +2250,7 @@ TZDBTimeZoneNames::getMetaZoneNames(const UnicodeString& mzID, UErrorCode& statu U_ASSERT(status == U_ZERO_ERROR); // already checked length above mzIDKey[mzID.length()] = 0; - static UMutex gTZDBNamesMapLock = U_MUTEX_INITIALIZER; + static UMutex gTZDBNamesMapLock; umtx_lock(&gTZDBNamesMapLock); { void *cacheVal = uhash_get(gTZDBNamesMap, mzIDKey); -- cgit v1.2.3