summaryrefslogtreecommitdiff
path: root/deps/icu-small/source/i18n/tzfmt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'deps/icu-small/source/i18n/tzfmt.cpp')
-rw-r--r--deps/icu-small/source/i18n/tzfmt.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/deps/icu-small/source/i18n/tzfmt.cpp b/deps/icu-small/source/i18n/tzfmt.cpp
index c948c5f5e7..267d507aa7 100644
--- a/deps/icu-small/source/i18n/tzfmt.cpp
+++ b/deps/icu-small/source/i18n/tzfmt.cpp
@@ -19,12 +19,15 @@
#include "unicode/udat.h"
#include "unicode/ustring.h"
#include "unicode/utf16.h"
+#include "bytesinkutil.h"
+#include "charstr.h"
#include "tzgnames.h"
#include "cmemory.h"
#include "cstring.h"
#include "putilimp.h"
#include "uassert.h"
#include "ucln_in.h"
+#include "ulocimp.h"
#include "umutex.h"
#include "uresimp.h"
#include "ureslocs.h"
@@ -147,10 +150,7 @@ static icu::UInitOnce gZoneIdTrieInitOnce = U_INITONCE_INITIALIZER;
static TextTrieMap *gShortZoneIdTrie = NULL;
static icu::UInitOnce gShortZoneIdTrieInitOnce = U_INITONCE_INITIALIZER;
-static UMutex *gLock() {
- static UMutex m = U_MUTEX_INITIALIZER;
- return &m;
-}
+static UMutex gLock;
U_CDECL_BEGIN
/**
@@ -327,10 +327,13 @@ TimeZoneFormat::TimeZoneFormat(const Locale& locale, UErrorCode& status)
const char* region = fLocale.getCountry();
int32_t regionLen = static_cast<int32_t>(uprv_strlen(region));
if (regionLen == 0) {
- char loc[ULOC_FULLNAME_CAPACITY];
- uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status);
+ CharString loc;
+ {
+ CharStringByteSink sink(&loc);
+ ulocimp_addLikelySubtags(fLocale.getName(), sink, &status);
+ }
- regionLen = uloc_getCountry(loc, fTargetRegion, sizeof(fTargetRegion), &status);
+ regionLen = uloc_getCountry(loc.data(), fTargetRegion, sizeof(fTargetRegion), &status);
if (U_SUCCESS(status)) {
fTargetRegion[regionLen] = 0;
} else {
@@ -502,7 +505,7 @@ TimeZoneFormat::operator==(const Format& other) const {
return isEqual;
}
-Format*
+TimeZoneFormat*
TimeZoneFormat::clone() const {
return new TimeZoneFormat(*this);
}
@@ -1385,12 +1388,12 @@ TimeZoneFormat::getTimeZoneGenericNames(UErrorCode& status) const {
return NULL;
}
- umtx_lock(gLock());
+ umtx_lock(&gLock);
if (fTimeZoneGenericNames == NULL) {
TimeZoneFormat *nonConstThis = const_cast<TimeZoneFormat *>(this);
nonConstThis->fTimeZoneGenericNames = TimeZoneGenericNames::createInstance(fLocale, status);
}
- umtx_unlock(gLock());
+ umtx_unlock(&gLock);
return fTimeZoneGenericNames;
}
@@ -1401,7 +1404,7 @@ TimeZoneFormat::getTZDBTimeZoneNames(UErrorCode& status) const {
return NULL;
}
- umtx_lock(gLock());
+ umtx_lock(&gLock);
if (fTZDBTimeZoneNames == NULL) {
TZDBTimeZoneNames *tzdbNames = new TZDBTimeZoneNames(fLocale);
if (tzdbNames == NULL) {
@@ -1411,7 +1414,7 @@ TimeZoneFormat::getTZDBTimeZoneNames(UErrorCode& status) const {
nonConstThis->fTZDBTimeZoneNames = tzdbNames;
}
}
- umtx_unlock(gLock());
+ umtx_unlock(&gLock);
return fTZDBTimeZoneNames;
}
@@ -1875,7 +1878,7 @@ TimeZoneFormat::parseOffsetFieldsWithPattern(const UnicodeString& text, int32_t
while (len > 0) {
UChar32 ch;
int32_t chLen;
- U16_GET(patStr, 0, 0, len, ch)
+ U16_GET(patStr, 0, 0, len, ch);
if (PatternProps::isWhiteSpace(ch)) {
chLen = U16_LENGTH(ch);
len -= chLen;