diff options
author | romankoshelev <romankoshelev@yandex-team.com> | 2023-08-14 19:51:50 +0300 |
---|---|---|
committer | romankoshelev <romankoshelev@yandex-team.com> | 2023-08-15 01:24:11 +0300 |
commit | cfcd865e05c0d0525ea27d1e153a043b32a85138 (patch) | |
tree | 68d3b3b25271e8a4998505897a269ff7ce119b76 /contrib/libs/icu/common/uprops.cpp | |
parent | ccb790c507bd5e8ffe2ef9886ce5ee0a7ce22a15 (diff) | |
download | ydb-cfcd865e05c0d0525ea27d1e153a043b32a85138.tar.gz |
Update ICU to 73.2
Diffstat (limited to 'contrib/libs/icu/common/uprops.cpp')
-rw-r--r-- | contrib/libs/icu/common/uprops.cpp | 63 |
1 files changed, 38 insertions, 25 deletions
diff --git a/contrib/libs/icu/common/uprops.cpp b/contrib/libs/icu/common/uprops.cpp index 5186a0c75c..28540186c6 100644 --- a/contrib/libs/icu/common/uprops.cpp +++ b/contrib/libs/icu/common/uprops.cpp @@ -49,7 +49,7 @@ U_NAMESPACE_USE namespace { -icu::UInitOnce gLayoutInitOnce = U_INITONCE_INITIALIZER; +icu::UInitOnce gLayoutInitOnce {}; UDataMemory *gLayoutMemory = nullptr; UCPTrie *gInpcTrie = nullptr; // Indic_Positional_Category @@ -76,7 +76,7 @@ UBool U_CALLCONV uprops_cleanup() { gMaxVoValue = 0; gLayoutInitOnce.reset(); - return TRUE; + return true; } UBool U_CALLCONV @@ -141,7 +141,7 @@ void U_CALLCONV ulayout_load(UErrorCode &errorCode) { } UBool ulayout_ensureData(UErrorCode &errorCode) { - if (U_FAILURE(errorCode)) { return FALSE; } + if (U_FAILURE(errorCode)) { return false; } umtx_initOnce(gLayoutInitOnce, &ulayout_load, errorCode); return U_SUCCESS(errorCode); } @@ -188,7 +188,7 @@ static UBool isJoinControl(const BinaryProperty &/*prop*/, UChar32 c, UProperty #if UCONFIG_NO_NORMALIZATION static UBool hasFullCompositionExclusion(const BinaryProperty &, UChar32, UProperty) { - return FALSE; + return false; } #else static UBool hasFullCompositionExclusion(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) { @@ -202,7 +202,7 @@ static UBool hasFullCompositionExclusion(const BinaryProperty &/*prop*/, UChar32 // UCHAR_NF*_INERT properties #if UCONFIG_NO_NORMALIZATION static UBool isNormInert(const BinaryProperty &, UChar32, UProperty) { - return FALSE; + return false; } #else static UBool isNormInert(const BinaryProperty &/*prop*/, UChar32 c, UProperty which) { @@ -215,7 +215,7 @@ static UBool isNormInert(const BinaryProperty &/*prop*/, UChar32 c, UProperty wh #if UCONFIG_NO_NORMALIZATION static UBool changesWhenCasefolded(const BinaryProperty &, UChar32, UProperty) { - return FALSE; + return false; } #else static UBool changesWhenCasefolded(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) { @@ -223,7 +223,7 @@ static UBool changesWhenCasefolded(const BinaryProperty &/*prop*/, UChar32 c, UP UErrorCode errorCode=U_ZERO_ERROR; const Normalizer2 *nfcNorm2=Normalizer2::getNFCInstance(errorCode); if(U_FAILURE(errorCode)) { - return FALSE; + return false; } if(nfcNorm2->getDecomposition(c, nfd)) { /* c has a decomposition */ @@ -237,36 +237,36 @@ static UBool changesWhenCasefolded(const BinaryProperty &/*prop*/, UChar32 c, UP c=U_SENTINEL; } } else if(c<0) { - return FALSE; /* protect against bad input */ + return false; /* protect against bad input */ } if(c>=0) { /* single code point */ - const UChar *resultString; + const char16_t *resultString; return (UBool)(ucase_toFullFolding(c, &resultString, U_FOLD_CASE_DEFAULT)>=0); } else { /* guess some large but stack-friendly capacity */ - UChar dest[2*UCASE_MAX_STRING_LENGTH]; + char16_t dest[2*UCASE_MAX_STRING_LENGTH]; int32_t destLength; destLength=u_strFoldCase(dest, UPRV_LENGTHOF(dest), nfd.getBuffer(), nfd.length(), U_FOLD_CASE_DEFAULT, &errorCode); return (UBool)(U_SUCCESS(errorCode) && 0!=u_strCompare(nfd.getBuffer(), nfd.length(), - dest, destLength, FALSE)); + dest, destLength, false)); } } #endif #if UCONFIG_NO_NORMALIZATION static UBool changesWhenNFKC_Casefolded(const BinaryProperty &, UChar32, UProperty) { - return FALSE; + return false; } #else static UBool changesWhenNFKC_Casefolded(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) { UErrorCode errorCode=U_ZERO_ERROR; const Normalizer2Impl *kcf=Normalizer2Factory::getNFKC_CFImpl(errorCode); if(U_FAILURE(errorCode)) { - return FALSE; + return false; } UnicodeString src(c); UnicodeString dest; @@ -276,9 +276,9 @@ static UBool changesWhenNFKC_Casefolded(const BinaryProperty &/*prop*/, UChar32 ReorderingBuffer buffer(*kcf, dest); // Small destCapacity for NFKC_CF(c). if(buffer.init(5, errorCode)) { - const UChar *srcArray=src.getBuffer(); - kcf->compose(srcArray, srcArray+src.length(), FALSE, - TRUE, buffer, errorCode); + const char16_t *srcArray=src.getBuffer(); + kcf->compose(srcArray, srcArray+src.length(), false, + true, buffer, errorCode); } } return U_SUCCESS(errorCode) && dest!=src; @@ -287,7 +287,7 @@ static UBool changesWhenNFKC_Casefolded(const BinaryProperty &/*prop*/, UChar32 #if UCONFIG_NO_NORMALIZATION static UBool isCanonSegmentStarter(const BinaryProperty &, UChar32, UProperty) { - return FALSE; + return false; } #else static UBool isCanonSegmentStarter(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) { @@ -416,15 +416,28 @@ u_hasBinaryProperty(UChar32 c, UProperty which) { /* c is range-checked in the functions that are called from here */ if(which<UCHAR_BINARY_START || UCHAR_BINARY_LIMIT<=which) { /* not a known binary property */ - return FALSE; + return false; } else { const BinaryProperty &prop=binProps[which]; return prop.contains(prop, c, which); } } +/* Checks if the Unicode character can start a Unicode identifier.*/ U_CAPI UBool U_EXPORT2 -u_stringHasBinaryProperty(const UChar *s, int32_t length, UProperty which) { +u_isIDStart(UChar32 c) { + return u_hasBinaryProperty(c, UCHAR_ID_START); +} + +/* Checks if the Unicode character can be a Unicode identifier part other than starting the + identifier.*/ +U_CAPI UBool U_EXPORT2 +u_isIDPart(UChar32 c) { + return u_hasBinaryProperty(c, UCHAR_ID_CONTINUE); +} + +U_CAPI UBool U_EXPORT2 +u_stringHasBinaryProperty(const char16_t *s, int32_t length, UProperty which) { if (s == nullptr && length != 0) { return false; } if (length == 1) { return u_hasBinaryProperty(s[0], which); // single code point @@ -670,7 +683,7 @@ U_CAPI int32_t U_EXPORT2 u_getIntPropertyMaxValue(UProperty which) { if(which<UCHAR_INT_START) { if(UCHAR_BINARY_START<=which && which<UCHAR_BINARY_LIMIT) { - return 1; // maximum TRUE for all binary properties + return 1; // maximum true for all binary properties } } else if(which<UCHAR_INT_LIMIT) { const IntProperty &prop=intProps[which-UCHAR_INT_START]; @@ -780,11 +793,11 @@ uprops_addPropertyStarts(UPropertySource src, const USetAdder *sa, UErrorCode *p #if !UCONFIG_NO_NORMALIZATION U_CAPI int32_t U_EXPORT2 -u_getFC_NFKC_Closure(UChar32 c, UChar *dest, int32_t destCapacity, UErrorCode *pErrorCode) { - if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { +u_getFC_NFKC_Closure(UChar32 c, char16_t *dest, int32_t destCapacity, UErrorCode *pErrorCode) { + if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) { return 0; } - if(destCapacity<0 || (dest==NULL && destCapacity>0)) { + if(destCapacity<0 || (dest==nullptr && destCapacity>0)) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } @@ -800,7 +813,7 @@ u_getFC_NFKC_Closure(UChar32 c, UChar *dest, int32_t destCapacity, UErrorCode *p } // first: b = NFKC(Fold(a)) UnicodeString folded1String; - const UChar *folded1; + const char16_t *folded1; int32_t folded1Length=ucase_toFullFolding(c, &folded1, U_FOLD_CASE_DEFAULT); if(folded1Length<0) { const Normalizer2Impl *nfkcImpl=Normalizer2Factory::getImpl(nfkc); @@ -812,7 +825,7 @@ u_getFC_NFKC_Closure(UChar32 c, UChar *dest, int32_t destCapacity, UErrorCode *p if(folded1Length>UCASE_MAX_STRING_LENGTH) { folded1String.setTo(folded1Length); } else { - folded1String.setTo(FALSE, folded1, folded1Length); + folded1String.setTo(false, folded1, folded1Length); } } UnicodeString kc1=nfkc->normalize(folded1String, *pErrorCode); |