aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/common/locutil.cpp
diff options
context:
space:
mode:
authorromankoshelev <romankoshelev@yandex-team.com>2023-08-14 19:51:50 +0300
committerromankoshelev <romankoshelev@yandex-team.com>2023-08-15 01:24:11 +0300
commitcfcd865e05c0d0525ea27d1e153a043b32a85138 (patch)
tree68d3b3b25271e8a4998505897a269ff7ce119b76 /contrib/libs/icu/common/locutil.cpp
parentccb790c507bd5e8ffe2ef9886ce5ee0a7ce22a15 (diff)
downloadydb-cfcd865e05c0d0525ea27d1e153a043b32a85138.tar.gz
Update ICU to 73.2
Diffstat (limited to 'contrib/libs/icu/common/locutil.cpp')
-rw-r--r--contrib/libs/icu/common/locutil.cpp58
1 files changed, 29 insertions, 29 deletions
diff --git a/contrib/libs/icu/common/locutil.cpp b/contrib/libs/icu/common/locutil.cpp
index 3d9d69ff7e..776d1d5963 100644
--- a/contrib/libs/icu/common/locutil.cpp
+++ b/contrib/libs/icu/common/locutil.cpp
@@ -21,12 +21,12 @@
#include "umutex.h"
// see LocaleUtility::getAvailableLocaleNames
-static icu::UInitOnce LocaleUtilityInitOnce = U_INITONCE_INITIALIZER;
-static icu::Hashtable * LocaleUtility_cache = NULL;
+static icu::UInitOnce LocaleUtilityInitOnce {};
+static icu::Hashtable * LocaleUtility_cache = nullptr;
-#define UNDERSCORE_CHAR ((UChar)0x005f)
-#define AT_SIGN_CHAR ((UChar)64)
-#define PERIOD_CHAR ((UChar)46)
+#define UNDERSCORE_CHAR ((char16_t)0x005f)
+#define AT_SIGN_CHAR ((char16_t)64)
+#define PERIOD_CHAR ((char16_t)46)
/*
******************************************************************
@@ -36,26 +36,26 @@ static icu::Hashtable * LocaleUtility_cache = NULL;
* Release all static memory held by Locale Utility.
*/
U_CDECL_BEGIN
-static UBool U_CALLCONV service_cleanup(void) {
+static UBool U_CALLCONV service_cleanup() {
if (LocaleUtility_cache) {
delete LocaleUtility_cache;
- LocaleUtility_cache = NULL;
+ LocaleUtility_cache = nullptr;
}
- return TRUE;
+ return true;
}
static void U_CALLCONV locale_utility_init(UErrorCode &status) {
using namespace icu;
- U_ASSERT(LocaleUtility_cache == NULL);
+ U_ASSERT(LocaleUtility_cache == nullptr);
ucln_common_registerCleanup(UCLN_COMMON_SERVICE, service_cleanup);
LocaleUtility_cache = new Hashtable(status);
if (U_FAILURE(status)) {
delete LocaleUtility_cache;
- LocaleUtility_cache = NULL;
+ LocaleUtility_cache = nullptr;
return;
}
- if (LocaleUtility_cache == NULL) {
+ if (LocaleUtility_cache == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -69,7 +69,7 @@ U_NAMESPACE_BEGIN
UnicodeString&
LocaleUtility::canonicalLocaleString(const UnicodeString* id, UnicodeString& result)
{
- if (id == NULL) {
+ if (id == nullptr) {
result.setToBogus();
} else {
// Fix case only (no other changes) up to the first '@' or '.' or
@@ -94,14 +94,14 @@ LocaleUtility::canonicalLocaleString(const UnicodeString* id, UnicodeString& res
n = end;
}
for (; i < n; ++i) {
- UChar c = result.charAt(i);
+ char16_t c = result.charAt(i);
if (c >= 0x0041 && c <= 0x005a) {
c += 0x20;
result.setCharAt(i, c);
}
}
for (n = end; i < n; ++i) {
- UChar c = result.charAt(i);
+ char16_t c = result.charAt(i);
if (c >= 0x0061 && c <= 0x007a) {
c -= 0x20;
result.setCharAt(i, c);
@@ -112,7 +112,7 @@ LocaleUtility::canonicalLocaleString(const UnicodeString* id, UnicodeString& res
#if 0
// This code does a proper full level 2 canonicalization of id.
- // It's nasty to go from UChar to char to char to UChar -- but
+ // It's nasty to go from char16_t to char to char to char16_t -- but
// that's what you have to do to use the uloc_canonicalize
// function on UnicodeStrings.
@@ -172,7 +172,7 @@ LocaleUtility::initLocaleFromName(const UnicodeString& id, Locale& result)
int32_t prev, i;
prev = 0;
for(;;) {
- i = id.indexOf((UChar)0x40, prev);
+ i = id.indexOf((char16_t)0x40, prev);
if(i < 0) {
// no @ between prev and the rest of the string
id.extract(prev, INT32_MAX, buffer + prev, BUFLEN - prev, US_INV);
@@ -214,45 +214,45 @@ LocaleUtility::getAvailableLocaleNames(const UnicodeString& bundleID)
UErrorCode status = U_ZERO_ERROR;
umtx_initOnce(LocaleUtilityInitOnce, locale_utility_init, status);
Hashtable *cache = LocaleUtility_cache;
- if (cache == NULL) {
+ if (cache == nullptr) {
// Catastrophic failure.
- return NULL;
+ return nullptr;
}
Hashtable* htp;
- umtx_lock(NULL);
+ umtx_lock(nullptr);
htp = (Hashtable*) cache->get(bundleID);
- umtx_unlock(NULL);
+ umtx_unlock(nullptr);
- if (htp == NULL) {
+ if (htp == nullptr) {
htp = new Hashtable(status);
if (htp && U_SUCCESS(status)) {
CharString cbundleID;
cbundleID.appendInvariantChars(bundleID, status);
- const char* path = cbundleID.isEmpty() ? NULL : cbundleID.data();
+ const char* path = cbundleID.isEmpty() ? nullptr : cbundleID.data();
icu::LocalUEnumerationPointer uenum(ures_openAvailableLocales(path, &status));
for (;;) {
- const UChar* id = uenum_unext(uenum.getAlias(), NULL, &status);
- if (id == NULL) {
+ const char16_t* id = uenum_unext(uenum.getAlias(), nullptr, &status);
+ if (id == nullptr) {
break;
}
htp->put(UnicodeString(id), (void*)htp, status);
}
if (U_FAILURE(status)) {
delete htp;
- return NULL;
+ return nullptr;
}
- umtx_lock(NULL);
+ umtx_lock(nullptr);
Hashtable *t = static_cast<Hashtable *>(cache->get(bundleID));
- if (t != NULL) {
+ if (t != nullptr) {
// Another thread raced through this code, creating the cache entry first.
// Discard ours and return theirs.
- umtx_unlock(NULL);
+ umtx_unlock(nullptr);
delete htp;
htp = t;
} else {
cache->put(bundleID, (void*)htp, status);
- umtx_unlock(NULL);
+ umtx_unlock(nullptr);
}
}
}