diff options
author | romankoshelev <romankoshelev@yandex-team.com> | 2024-05-13 11:00:27 +0300 |
---|---|---|
committer | romankoshelev <romankoshelev@yandex-team.com> | 2024-05-13 11:13:05 +0300 |
commit | 5b22fadb0f035a3b82c328e0ae710ad2b92f6eac (patch) | |
tree | e15dc649c79c4fb78f35cd6694dfe9af9bfcc0ad /contrib/libs/icu/common/locavailable.cpp | |
parent | 5946aa7d3cbca62f6bcf074e8a2b9346e7a96af4 (diff) | |
download | ydb-5b22fadb0f035a3b82c328e0ae710ad2b92f6eac.tar.gz |
Update ICU to 75.1
904da4ae1c86fc5542eac7f1cd18d97b72eb8517
Diffstat (limited to 'contrib/libs/icu/common/locavailable.cpp')
-rw-r--r-- | contrib/libs/icu/common/locavailable.cpp | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/contrib/libs/icu/common/locavailable.cpp b/contrib/libs/icu/common/locavailable.cpp index 0ea2093988..4a2600e88c 100644 --- a/contrib/libs/icu/common/locavailable.cpp +++ b/contrib/libs/icu/common/locavailable.cpp @@ -39,14 +39,10 @@ static icu::Locale* availableLocaleList = nullptr; static int32_t availableLocaleListCount; static icu::UInitOnce gInitOnceLocale {}; -U_NAMESPACE_END - -U_CDECL_BEGIN +namespace { -static UBool U_CALLCONV locale_available_cleanup() +UBool U_CALLCONV locale_available_cleanup() { - U_NAMESPACE_USE - if (availableLocaleList) { delete []availableLocaleList; availableLocaleList = nullptr; @@ -57,9 +53,7 @@ static UBool U_CALLCONV locale_available_cleanup() return true; } -U_CDECL_END - -U_NAMESPACE_BEGIN +} // namespace void U_CALLCONV locale_available_init() { // This function is a friend of class Locale. @@ -107,10 +101,9 @@ icu::UInitOnce ginstalledLocalesInitOnce {}; class AvailableLocalesSink : public ResourceSink { public: void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) override { + if (U_FAILURE(status)) { return; } ResourceTable resIndexTable = value.getTable(status); - if (U_FAILURE(status)) { - return; - } + if (U_FAILURE(status)) { return; } for (int32_t i = 0; resIndexTable.getKeyAndValue(i, key, value); ++i) { ULocAvailableType type; if (uprv_strcmp(key, "InstalledLocales") == 0) { @@ -144,7 +137,8 @@ class AvailableLocalesStringEnumeration : public StringEnumeration { AvailableLocalesStringEnumeration(ULocAvailableType type) : fType(type) { } - const char* next(int32_t *resultLength, UErrorCode&) override { + const char* next(int32_t *resultLength, UErrorCode &status) override { + if (U_FAILURE(status)) { return nullptr; } ULocAvailableType actualType = fType; int32_t actualIndex = fIndex++; @@ -176,11 +170,13 @@ class AvailableLocalesStringEnumeration : public StringEnumeration { return result; } - void reset(UErrorCode&) override { + void reset(UErrorCode &status) override { + if (U_FAILURE(status)) { return; } fIndex = 0; } - int32_t count(UErrorCode&) const override { + int32_t count(UErrorCode &status) const override { + if (U_FAILURE(status)) { return 0; } if (fType == ULOC_AVAILABLE_WITH_LEGACY_ALIASES) { return gAvailableLocaleCounts[ULOC_AVAILABLE_DEFAULT] + gAvailableLocaleCounts[ULOC_AVAILABLE_ONLY_LEGACY_ALIASES]; @@ -196,7 +192,7 @@ class AvailableLocalesStringEnumeration : public StringEnumeration { /* ### Get available **************************************************/ -static UBool U_CALLCONV uloc_cleanup() { +UBool U_CALLCONV uloc_cleanup() { for (int32_t i = 0; i < UPRV_LENGTHOF(gAvailableLocaleNames); i++) { uprv_free(gAvailableLocaleNames[i]); gAvailableLocaleNames[i] = nullptr; @@ -209,7 +205,7 @@ static UBool U_CALLCONV uloc_cleanup() { // Load Installed Locales. This function will be called exactly once // via the initOnce mechanism. -static void U_CALLCONV loadInstalledLocales(UErrorCode& status) { +void U_CALLCONV loadInstalledLocales(UErrorCode& status) { ucln_common_registerCleanup(UCLN_COMMON_ULOC, uloc_cleanup); icu::LocalUResourceBundlePointer rb(ures_openDirect(nullptr, "res_index", &status)); @@ -267,4 +263,3 @@ uloc_openAvailableByType(ULocAvailableType type, UErrorCode* status) { } return uenum_openFromStringEnumeration(result.orphan(), status); } - |