diff options
author | mcheshkov <mcheshkov@yandex-team.ru> | 2022-02-10 16:46:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:15 +0300 |
commit | e9d19cec64684c9c1e6b0c98297e5b895cf904fe (patch) | |
tree | 2768b1223e96a8a0610a93d18425d9647c1123c8 /contrib/libs/icu/i18n/tznames_impl.cpp | |
parent | 60040c91ffe701a84689b2c6310ff845e65cff42 (diff) | |
download | ydb-e9d19cec64684c9c1e6b0c98297e5b895cf904fe.tar.gz |
Restoring authorship annotation for <mcheshkov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/icu/i18n/tznames_impl.cpp')
-rw-r--r-- | contrib/libs/icu/i18n/tznames_impl.cpp | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/contrib/libs/icu/i18n/tznames_impl.cpp b/contrib/libs/icu/i18n/tznames_impl.cpp index 186aaaf74d..258f104506 100644 --- a/contrib/libs/icu/i18n/tznames_impl.cpp +++ b/contrib/libs/icu/i18n/tznames_impl.cpp @@ -1,4 +1,4 @@ -// © 2016 and later: Unicode, Inc. and others. +// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* @@ -15,20 +15,20 @@ #if !UCONFIG_NO_FORMATTING -#include "unicode/strenum.h" +#include "unicode/strenum.h" #include "unicode/ustring.h" #include "unicode/timezone.h" -#include "unicode/utf16.h" +#include "unicode/utf16.h" #include "tznames_impl.h" -#include "bytesinkutil.h" -#include "charstr.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 "ulocimp.h" #include "uresimp.h" #include "ureslocs.h" #include "zonemeta.h" @@ -52,7 +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 gDataMutex; static UHashtable* gTZDBNamesMap = NULL; static icu::UInitOnce gTZDBNamesMapInitOnce = U_INITONCE_INITIALIZER; @@ -72,7 +72,7 @@ enum UTimeZoneNameTypeIndex { UTZNM_INDEX_SHORT_DAYLIGHT, UTZNM_INDEX_COUNT }; -static const UChar* const EMPTY_NAMES[UTZNM_INDEX_COUNT] = {0,0,0,0,0,0,0}; +static const UChar* const EMPTY_NAMES[UTZNM_INDEX_COUNT] = {0,0,0,0,0,0,0}; U_CDECL_BEGIN static UBool U_CALLCONV tzdbTimeZoneNames_cleanup(void) { @@ -386,10 +386,10 @@ TextTrieMap::search(const UnicodeString &text, int32_t start, // the ICU atomic safe functions for assigning and testing. // Don't test the pointer fLazyContents. // 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; - + + // Mutex for protecting the lazy creation of the Trie node structure on the first call to search(). + static UMutex TextTrieMutex; + Mutex lock(&TextTrieMutex); if (fLazyContents != NULL) { TextTrieMap *nonConstThis = const_cast<TextTrieMap *>(this); @@ -417,28 +417,28 @@ TextTrieMap::search(CharacterNode *node, const UnicodeString &text, int32_t star } } if (fIgnoreCase) { - // for folding we need to get a complete code point. - // size of character may grow after fold operation; - // then we need to get result as UTF16 code units. - UChar32 c32 = text.char32At(index); - index += U16_LENGTH(c32); - UnicodeString tmp(c32); + // for folding we need to get a complete code point. + // size of character may grow after fold operation; + // then we need to get result as UTF16 code units. + UChar32 c32 = text.char32At(index); + index += U16_LENGTH(c32); + UnicodeString tmp(c32); tmp.foldCase(); int32_t tmpidx = 0; while (tmpidx < tmp.length()) { - UChar c = tmp.charAt(tmpidx++); + UChar c = tmp.charAt(tmpidx++); node = getChildNode(node, c); if (node == NULL) { break; } } } else { - // here we just get the next UTF16 code unit - UChar c = text.charAt(index++); + // here we just get the next UTF16 code unit + UChar c = text.charAt(index++); node = getChildNode(node, c); } if (node != NULL) { - search(node, text, start, index, handler, status); + search(node, text, start, index, handler, status); } } @@ -1079,7 +1079,7 @@ TimeZoneNamesImpl::loadStrings(const UnicodeString& tzCanonicalID, UErrorCode& s U_ASSERT(!mzIDs.isNull()); const UnicodeString *mzID; - while (((mzID = mzIDs->snext(status)) != NULL) && U_SUCCESS(status)) { + while (((mzID = mzIDs->snext(status)) != NULL) && U_SUCCESS(status)) { loadMetaZoneNames(*mzID, status); } } @@ -1113,7 +1113,7 @@ TimeZoneNamesImpl::operator==(const TimeZoneNames& other) const { return FALSE; } -TimeZoneNamesImpl* +TimeZoneNamesImpl* TimeZoneNamesImpl::clone() const { UErrorCode status = U_ZERO_ERROR; return new TimeZoneNamesImpl(fLocale, status); @@ -1289,7 +1289,7 @@ static void mergeTimeZoneKey(const UnicodeString& mzID, char* result) { char mzIdChar[ZID_KEY_MAX + 1]; int32_t keyLen; - int32_t prefixLen = static_cast<int32_t>(uprv_strlen(gMZPrefix)); + int32_t prefixLen = static_cast<int32_t>(uprv_strlen(gMZPrefix)); keyLen = mzID.extract(0, mzID.length(), mzIdChar, ZID_KEY_MAX + 1, US_INV); uprv_memcpy((void *)result, (void *)gMZPrefix, prefixLen); uprv_memcpy((void *)(result + prefixLen), (void *)mzIdChar, keyLen); @@ -1457,7 +1457,7 @@ struct TimeZoneNamesImpl::ZoneStringsLoader : public ResourceSink { virtual ~ZoneStringsLoader(); void* createKey(const char* key, UErrorCode& status) { - int32_t len = sizeof(char) * (static_cast<int32_t>(uprv_strlen(key)) + 1); + int32_t len = sizeof(char) * (static_cast<int32_t>(uprv_strlen(key)) + 1); char* newKey = (char*) uprv_malloc(len); if (newKey == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -1473,7 +1473,7 @@ struct TimeZoneNamesImpl::ZoneStringsLoader : public ResourceSink { } UnicodeString mzIDFromKey(const char* key) { - return UnicodeString(key + MZ_PREFIX_LEN, static_cast<int32_t>(uprv_strlen(key)) - MZ_PREFIX_LEN, US_INV); + return UnicodeString(key + MZ_PREFIX_LEN, static_cast<int32_t>(uprv_strlen(key)) - MZ_PREFIX_LEN, US_INV); } UnicodeString tzIDFromKey(const char* key) { @@ -1660,7 +1660,7 @@ void TimeZoneNamesImpl::internalLoadAllDisplayNames(UErrorCode& status) { StringEnumeration *tzIDs = TimeZone::createTimeZoneIDEnumeration( UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, status); if (U_SUCCESS(status)) { - while ((id = tzIDs->snext(status)) != NULL) { + while ((id = tzIDs->snext(status)) != NULL) { if (U_FAILURE(status)) { break; } @@ -1948,8 +1948,8 @@ TZDBNameSearchHandler::handleMatch(int32_t matchLength, const CharacterNode *nod // metazone mapping for "CST" is America_Central, // but if region is one of CN/MO/TW, "CST" is parsed // as metazone China (China Standard Time). - for (int32_t j = 0; j < ninfo->nRegions; j++) { - const char *region = ninfo->parseRegions[j]; + for (int32_t j = 0; j < ninfo->nRegions; j++) { + const char *region = ninfo->parseRegions[j]; if (uprv_strcmp(fRegion, region) == 0) { match = ninfo; matchRegion = TRUE; @@ -2063,11 +2063,11 @@ static void U_CALLCONV prepareFind(UErrorCode &status) { const UnicodeString *mzID; StringEnumeration *mzIDs = TimeZoneNamesImpl::_getAvailableMetaZoneIDs(status); if (U_SUCCESS(status)) { - while ((mzID = mzIDs->snext(status)) != 0 && U_SUCCESS(status)) { + while ((mzID = mzIDs->snext(status)) != 0 && U_SUCCESS(status)) { const TZDBNames *names = TZDBTimeZoneNames::getMetaZoneNames(*mzID, status); - if (U_FAILURE(status)) { - break; - } + if (U_FAILURE(status)) { + break; + } if (names == NULL) { continue; } @@ -2132,15 +2132,15 @@ TZDBTimeZoneNames::TZDBTimeZoneNames(const Locale& locale) : fLocale(locale) { UBool useWorld = TRUE; const char* region = fLocale.getCountry(); - int32_t regionLen = static_cast<int32_t>(uprv_strlen(region)); + int32_t regionLen = static_cast<int32_t>(uprv_strlen(region)); if (regionLen == 0) { UErrorCode status = U_ZERO_ERROR; - CharString loc; - { - CharStringByteSink sink(&loc); - ulocimp_addLikelySubtags(fLocale.getName(), sink, &status); - } - regionLen = uloc_getCountry(loc.data(), 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; } @@ -2165,7 +2165,7 @@ TZDBTimeZoneNames::operator==(const TimeZoneNames& other) const { return FALSE; } -TZDBTimeZoneNames* +TZDBTimeZoneNames* TZDBTimeZoneNames::clone() const { return new TZDBTimeZoneNames(fLocale); } @@ -2202,11 +2202,11 @@ TZDBTimeZoneNames::getMetaZoneDisplayName(const UnicodeString& mzID, UErrorCode status = U_ZERO_ERROR; const TZDBNames *tzdbNames = TZDBTimeZoneNames::getMetaZoneNames(mzID, status); if (U_SUCCESS(status)) { - if (tzdbNames != NULL) { - const UChar *s = tzdbNames->getName(type); - if (s != NULL) { - name.setTo(TRUE, s, -1); - } + if (tzdbNames != NULL) { + const UChar *s = tzdbNames->getName(type); + if (s != NULL) { + name.setTo(TRUE, s, -1); + } } } @@ -2250,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; + static UMutex gTZDBNamesMapLock; umtx_lock(&gTZDBNamesMapLock); { void *cacheVal = uhash_get(gTZDBNamesMap, mzIDKey); |