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/unisetspan.cpp | |
parent | ccb790c507bd5e8ffe2ef9886ce5ee0a7ce22a15 (diff) | |
download | ydb-cfcd865e05c0d0525ea27d1e153a043b32a85138.tar.gz |
Update ICU to 73.2
Diffstat (limited to 'contrib/libs/icu/common/unisetspan.cpp')
-rw-r--r-- | contrib/libs/icu/common/unisetspan.cpp | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/contrib/libs/icu/common/unisetspan.cpp b/contrib/libs/icu/common/unisetspan.cpp index fe0d74f5b2..b7256d8fd1 100644 --- a/contrib/libs/icu/common/unisetspan.cpp +++ b/contrib/libs/icu/common/unisetspan.cpp @@ -70,7 +70,7 @@ public: capacity=(int32_t)sizeof(staticList); } else { UBool *l=(UBool *)uprv_malloc(maxLength); - if(l!=NULL) { + if(l!=nullptr) { list=l; capacity=maxLength; } @@ -98,7 +98,7 @@ public: i-=capacity; } if(list[i]) { - list[i]=FALSE; + list[i]=false; --length; } start=i; @@ -111,7 +111,7 @@ public: if(i>=capacity) { i-=capacity; } - list[i]=TRUE; + list[i]=true; ++length; } @@ -132,7 +132,7 @@ public: int32_t i=start, result; while(++i<capacity) { if(list[i]) { - list[i]=FALSE; + list[i]=false; --length; result=i-start; start=i; @@ -148,7 +148,7 @@ public: while(!list[i]) { ++i; } - list[i]=FALSE; + list[i]=false; --length; start=i; return result+=i; @@ -165,10 +165,10 @@ private: // Get the number of UTF-8 bytes for a UTF-16 (sub)string. static int32_t -getUTF8Length(const UChar *s, int32_t length) { +getUTF8Length(const char16_t *s, int32_t length) { UErrorCode errorCode=U_ZERO_ERROR; int32_t length8=0; - u_strToUTF8(NULL, 0, &length8, s, length, &errorCode); + u_strToUTF8(nullptr, 0, &length8, s, length, &errorCode); if(U_SUCCESS(errorCode) || errorCode==U_BUFFER_OVERFLOW_ERROR) { return length8; } else { @@ -180,7 +180,7 @@ getUTF8Length(const UChar *s, int32_t length) { // Append the UTF-8 version of the string to t and return the appended UTF-8 length. static int32_t -appendUTF8(const UChar *s, int32_t length, uint8_t *t, int32_t capacity) { +appendUTF8(const char16_t *s, int32_t length, uint8_t *t, int32_t capacity) { UErrorCode errorCode=U_ZERO_ERROR; int32_t length8=0; u_strToUTF8((char *)t, capacity, &length8, s, length, &errorCode); @@ -204,8 +204,8 @@ makeSpanLengthByte(int32_t spanLength) { UnicodeSetStringSpan::UnicodeSetStringSpan(const UnicodeSet &set, const UVector &setStrings, uint32_t which) - : spanSet(0, 0x10ffff), pSpanNotSet(NULL), strings(setStrings), - utf8Lengths(NULL), spanLengths(NULL), utf8(NULL), + : spanSet(0, 0x10ffff), pSpanNotSet(nullptr), strings(setStrings), + utf8Lengths(nullptr), spanLengths(nullptr), utf8(nullptr), utf8Length(0), maxLength16(0), maxLength8(0), all((UBool)(which==ALL)) { @@ -226,10 +226,10 @@ UnicodeSetStringSpan::UnicodeSetStringSpan(const UnicodeSet &set, int32_t stringsLength=strings.size(); int32_t i, spanLength; - UBool someRelevant=FALSE; + UBool someRelevant=false; for(i=0; i<stringsLength; ++i) { const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i); - const UChar *s16=string.getBuffer(); + const char16_t *s16=string.getBuffer(); int32_t length16=string.length(); if (length16==0) { continue; // skip the empty string @@ -237,9 +237,9 @@ UnicodeSetStringSpan::UnicodeSetStringSpan(const UnicodeSet &set, UBool thisRelevant; spanLength=spanSet.span(s16, length16, USET_SPAN_CONTAINED); if(spanLength<length16) { // Relevant string. - someRelevant=thisRelevant=TRUE; + someRelevant=thisRelevant=true; } else { - thisRelevant=FALSE; + thisRelevant=false; } if((which&UTF16) && length16>maxLength16) { maxLength16=length16; @@ -283,8 +283,8 @@ UnicodeSetStringSpan::UnicodeSetStringSpan(const UnicodeSet &set, utf8Lengths=staticLengths; } else { utf8Lengths=(int32_t *)uprv_malloc(allocSize); - if(utf8Lengths==NULL) { - maxLength16=maxLength8=0; // Prevent usage by making needsStringSpanUTF16/8() return FALSE. + if(utf8Lengths==nullptr) { + maxLength16=maxLength8=0; // Prevent usage by making needsStringSpanUTF16/8() return false. return; // Out of memory. } } @@ -312,7 +312,7 @@ UnicodeSetStringSpan::UnicodeSetStringSpan(const UnicodeSet &set, for(i=0; i<stringsLength; ++i) { const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i); - const UChar *s16=string.getBuffer(); + const char16_t *s16=string.getBuffer(); int32_t length16=string.length(); spanLength=spanSet.span(s16, length16, USET_SPAN_CONTAINED); if(spanLength<length16 && length16>0) { // Relevant string. @@ -395,11 +395,11 @@ UnicodeSetStringSpan::UnicodeSetStringSpan(const UnicodeSet &set, // Copy constructor. Assumes which==ALL for a frozen set. UnicodeSetStringSpan::UnicodeSetStringSpan(const UnicodeSetStringSpan &otherStringSpan, const UVector &newParentSetStrings) - : spanSet(otherStringSpan.spanSet), pSpanNotSet(NULL), strings(newParentSetStrings), - utf8Lengths(NULL), spanLengths(NULL), utf8(NULL), + : spanSet(otherStringSpan.spanSet), pSpanNotSet(nullptr), strings(newParentSetStrings), + utf8Lengths(nullptr), spanLengths(nullptr), utf8(nullptr), utf8Length(otherStringSpan.utf8Length), maxLength16(otherStringSpan.maxLength16), maxLength8(otherStringSpan.maxLength8), - all(TRUE) { + all(true) { if(otherStringSpan.pSpanNotSet==&otherStringSpan.spanSet) { pSpanNotSet=&spanSet; } else { @@ -414,8 +414,8 @@ UnicodeSetStringSpan::UnicodeSetStringSpan(const UnicodeSetStringSpan &otherStri utf8Lengths=staticLengths; } else { utf8Lengths=(int32_t *)uprv_malloc(allocSize); - if(utf8Lengths==NULL) { - maxLength16=maxLength8=0; // Prevent usage by making needsStringSpanUTF16/8() return FALSE. + if(utf8Lengths==nullptr) { + maxLength16=maxLength8=0; // Prevent usage by making needsStringSpanUTF16/8() return false. return; // Out of memory. } } @@ -426,21 +426,21 @@ UnicodeSetStringSpan::UnicodeSetStringSpan(const UnicodeSetStringSpan &otherStri } UnicodeSetStringSpan::~UnicodeSetStringSpan() { - if(pSpanNotSet!=NULL && pSpanNotSet!=&spanSet) { + if(pSpanNotSet!=nullptr && pSpanNotSet!=&spanSet) { delete pSpanNotSet; } - if(utf8Lengths!=NULL && utf8Lengths!=staticLengths) { + if(utf8Lengths!=nullptr && utf8Lengths!=staticLengths) { uprv_free(utf8Lengths); } } void UnicodeSetStringSpan::addToSpanNotSet(UChar32 c) { - if(pSpanNotSet==NULL || pSpanNotSet==&spanSet) { + if(pSpanNotSet==nullptr || pSpanNotSet==&spanSet) { if(spanSet.contains(c)) { return; // Nothing to do. } UnicodeSet *newSet=spanSet.cloneAsThawed(); - if(newSet==NULL) { + if(newSet==nullptr) { return; // Out of memory. } else { pSpanNotSet=newSet; @@ -451,30 +451,30 @@ void UnicodeSetStringSpan::addToSpanNotSet(UChar32 c) { // Compare strings without any argument checks. Requires length>0. static inline UBool -matches16(const UChar *s, const UChar *t, int32_t length) { +matches16(const char16_t *s, const char16_t *t, int32_t length) { do { if(*s++!=*t++) { - return FALSE; + return false; } } while(--length>0); - return TRUE; + return true; } static inline UBool matches8(const uint8_t *s, const uint8_t *t, int32_t length) { do { if(*s++!=*t++) { - return FALSE; + return false; } } while(--length>0); - return TRUE; + return true; } // Compare 16-bit Unicode strings (which may be malformed UTF-16) // at code point boundaries. // That is, each edge of a match must not be in the middle of a surrogate pair. static inline UBool -matches16CPB(const UChar *s, int32_t start, int32_t limit, const UChar *t, int32_t length) { +matches16CPB(const char16_t *s, int32_t start, int32_t limit, const char16_t *t, int32_t length) { s+=start; limit-=start; return matches16(s, t, length) && @@ -485,8 +485,8 @@ matches16CPB(const UChar *s, int32_t start, int32_t limit, const UChar *t, int32 // Does the set contain the next code point? // If so, return its length; otherwise return its negative length. static inline int32_t -spanOne(const UnicodeSet &set, const UChar *s, int32_t length) { - UChar c=*s, c2; +spanOne(const UnicodeSet &set, const char16_t *s, int32_t length) { + char16_t c=*s, c2; if(c>=0xd800 && c<=0xdbff && length>=2 && U16_IS_TRAIL(c2=s[1])) { return set.contains(U16_GET_SUPPLEMENTARY(c, c2)) ? 2 : -2; } @@ -494,8 +494,8 @@ spanOne(const UnicodeSet &set, const UChar *s, int32_t length) { } static inline int32_t -spanOneBack(const UnicodeSet &set, const UChar *s, int32_t length) { - UChar c=s[length-1], c2; +spanOneBack(const UnicodeSet &set, const char16_t *s, int32_t length) { + char16_t c=s[length-1], c2; if(c>=0xdc00 && c<=0xdfff && length>=2 && U16_IS_LEAD(c2=s[length-2])) { return set.contains(U16_GET_SUPPLEMENTARY(c2, c)) ? 2 : -2; } @@ -634,7 +634,7 @@ spanOneBackUTF8(const UnicodeSet &set, const uint8_t *s, int32_t length) { * Stop if spanLength==0, otherwise continue the loop. */ -int32_t UnicodeSetStringSpan::span(const UChar *s, int32_t length, USetSpanCondition spanCondition) const { +int32_t UnicodeSetStringSpan::span(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const { if(spanCondition==USET_SPAN_NOT_CONTAINED) { return spanNot(s, length); } @@ -659,7 +659,7 @@ int32_t UnicodeSetStringSpan::span(const UChar *s, int32_t length, USetSpanCondi continue; // Irrelevant string. (Also the empty string.) } const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i); - const UChar *s16=string.getBuffer(); + const char16_t *s16=string.getBuffer(); int32_t length16=string.length(); U_ASSERT(length>0); @@ -699,7 +699,7 @@ int32_t UnicodeSetStringSpan::span(const UChar *s, int32_t length, USetSpanCondi // to find the match from the earliest start. const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i); - const UChar *s16=string.getBuffer(); + const char16_t *s16=string.getBuffer(); int32_t length16=string.length(); if (length16==0) { continue; // skip the empty string @@ -798,7 +798,7 @@ int32_t UnicodeSetStringSpan::span(const UChar *s, int32_t length, USetSpanCondi } } -int32_t UnicodeSetStringSpan::spanBack(const UChar *s, int32_t length, USetSpanCondition spanCondition) const { +int32_t UnicodeSetStringSpan::spanBack(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const { if(spanCondition==USET_SPAN_NOT_CONTAINED) { return spanNotBack(s, length); } @@ -827,7 +827,7 @@ int32_t UnicodeSetStringSpan::spanBack(const UChar *s, int32_t length, USetSpanC continue; // Irrelevant string. (Also the empty string.) } const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i); - const UChar *s16=string.getBuffer(); + const char16_t *s16=string.getBuffer(); int32_t length16=string.length(); U_ASSERT(length>0); @@ -869,7 +869,7 @@ int32_t UnicodeSetStringSpan::spanBack(const UChar *s, int32_t length, USetSpanC // to find the match from the latest end. const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i); - const UChar *s16=string.getBuffer(); + const char16_t *s16=string.getBuffer(); int32_t length16=string.length(); if (length16==0) { continue; // skip the empty string @@ -1346,7 +1346,7 @@ int32_t UnicodeSetStringSpan::spanBackUTF8(const uint8_t *s, int32_t length, USe * when there is not actually a match for such a set string. */ -int32_t UnicodeSetStringSpan::spanNot(const UChar *s, int32_t length) const { +int32_t UnicodeSetStringSpan::spanNot(const char16_t *s, int32_t length) const { int32_t pos=0, rest=length; int32_t i, stringsLength=strings.size(); do { @@ -1372,7 +1372,7 @@ int32_t UnicodeSetStringSpan::spanNot(const UChar *s, int32_t length) const { continue; // Irrelevant string. (Also the empty string.) } const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i); - const UChar *s16=string.getBuffer(); + const char16_t *s16=string.getBuffer(); int32_t length16=string.length(); U_ASSERT(length>0); if(length16<=rest && matches16CPB(s, pos, length, s16, length16)) { @@ -1389,7 +1389,7 @@ int32_t UnicodeSetStringSpan::spanNot(const UChar *s, int32_t length) const { return length; // Reached the end of the string. } -int32_t UnicodeSetStringSpan::spanNotBack(const UChar *s, int32_t length) const { +int32_t UnicodeSetStringSpan::spanNotBack(const char16_t *s, int32_t length) const { int32_t pos=length; int32_t i, stringsLength=strings.size(); do { @@ -1416,7 +1416,7 @@ int32_t UnicodeSetStringSpan::spanNotBack(const UChar *s, int32_t length) const continue; // Irrelevant string. (Also the empty string.) } const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i); - const UChar *s16=string.getBuffer(); + const char16_t *s16=string.getBuffer(); int32_t length16=string.length(); U_ASSERT(length>0); if(length16<=pos && matches16CPB(s, pos-length16, length, s16, length16)) { |