aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/common/uniset.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/uniset.cpp
parentccb790c507bd5e8ffe2ef9886ce5ee0a7ce22a15 (diff)
downloadydb-cfcd865e05c0d0525ea27d1e153a043b32a85138.tar.gz
Update ICU to 73.2
Diffstat (limited to 'contrib/libs/icu/common/uniset.cpp')
-rw-r--r--contrib/libs/icu/common/uniset.cpp116
1 files changed, 58 insertions, 58 deletions
diff --git a/contrib/libs/icu/common/uniset.cpp b/contrib/libs/icu/common/uniset.cpp
index 92a81a1a02..71f57fc12d 100644
--- a/contrib/libs/icu/common/uniset.cpp
+++ b/contrib/libs/icu/common/uniset.cpp
@@ -82,7 +82,7 @@ static int32_t _dbgCount = 0;
static inline void _dbgct(UnicodeSet* set) {
UnicodeString str;
- set->toPattern(str, TRUE);
+ set->toPattern(str, true);
char buf[40];
str.extract(0, 39, buf, "");
printf("DEBUG UnicodeSet: ct 0x%08X; %d %s\n", set, ++_dbgCount, buf);
@@ -90,7 +90,7 @@ static inline void _dbgct(UnicodeSet* set) {
static inline void _dbgdt(UnicodeSet* set) {
UnicodeString str;
- set->toPattern(str, TRUE);
+ set->toPattern(str, true);
char buf[40];
str.extract(0, 39, buf, "");
printf("DEBUG UnicodeSet: dt 0x%08X; %d %s\n", set, --_dbgCount, buf);
@@ -204,7 +204,7 @@ UnicodeSet::~UnicodeSet() {
* Assigns this object to be a copy of another.
*/
UnicodeSet& UnicodeSet::operator=(const UnicodeSet& o) {
- return copyFrom(o, FALSE);
+ return copyFrom(o, false);
}
UnicodeSet& UnicodeSet::copyFrom(const UnicodeSet& o, UBool asThawed) {
@@ -226,7 +226,7 @@ UnicodeSet& UnicodeSet::copyFrom(const UnicodeSet& o, UBool asThawed) {
uprv_memcpy(list, o.list, (size_t)len*sizeof(UChar32));
if (o.bmpSet != nullptr && !asThawed) {
bmpSet = new BMPSet(*o.bmpSet, list, len);
- if (bmpSet == NULL) { // Check for memory allocation error.
+ if (bmpSet == nullptr) { // Check for memory allocation error.
setToBogus();
return *this;
}
@@ -243,7 +243,7 @@ UnicodeSet& UnicodeSet::copyFrom(const UnicodeSet& o, UBool asThawed) {
}
if (o.stringSpan != nullptr && !asThawed) {
stringSpan = new UnicodeSetStringSpan(*o.stringSpan, *strings);
- if (stringSpan == NULL) { // Check for memory allocation error.
+ if (stringSpan == nullptr) { // Check for memory allocation error.
setToBogus();
return *this;
}
@@ -265,7 +265,7 @@ UnicodeSet* UnicodeSet::clone() const {
}
UnicodeSet *UnicodeSet::cloneAsThawed() const {
- return new UnicodeSet(*this, TRUE);
+ return new UnicodeSet(*this, true);
}
/**
@@ -294,7 +294,7 @@ bool UnicodeSet::operator==(const UnicodeSet& o) const {
* @return the hash code value for this set.
* @see Object#hashCode()
*/
-int32_t UnicodeSet::hashCode(void) const {
+int32_t UnicodeSet::hashCode() const {
uint32_t result = static_cast<uint32_t>(len);
for (int32_t i = 0; i < len; ++i) {
result *= 1000003u;
@@ -314,7 +314,7 @@ int32_t UnicodeSet::hashCode(void) const {
*
* @return the number of elements in this set (its cardinality).
*/
-int32_t UnicodeSet::size(void) const {
+int32_t UnicodeSet::size() const {
int32_t n = 0;
int32_t count = getRangeCount();
for (int32_t i = 0; i < count; ++i) {
@@ -328,7 +328,7 @@ int32_t UnicodeSet::size(void) const {
*
* @return <tt>true</tt> if this set contains no elements.
*/
-UBool UnicodeSet::isEmpty(void) const {
+UBool UnicodeSet::isEmpty() const {
return len == 1 && !hasStrings();
}
@@ -345,14 +345,14 @@ UBool UnicodeSet::contains(UChar32 c) const {
//for (;;) {
// if (c < list[++i]) break;
//}
- if (bmpSet != NULL) {
+ if (bmpSet != nullptr) {
return bmpSet->contains(c);
}
- if (stringSpan != NULL) {
+ if (stringSpan != nullptr) {
return stringSpan->contains(c);
}
if (c >= UNICODESET_HIGH) { // Don't need to check LOW bound
- return FALSE;
+ return false;
}
int32_t i = findCodePoint(c);
return (UBool)(i & 1); // return true if odd
@@ -447,7 +447,7 @@ UBool UnicodeSet::containsAll(const UnicodeSet& c) const {
int32_t n = c.getRangeCount();
for (int i=0; i<n; ++i) {
if (!contains(c.getRangeStart(i), c.getRangeEnd(i))) {
- return FALSE;
+ return false;
}
}
return !c.hasStrings() || (strings != nullptr && strings->containsAll(*c.strings));
@@ -493,7 +493,7 @@ UBool UnicodeSet::containsNone(const UnicodeSet& c) const {
int32_t n = c.getRangeCount();
for (int32_t i=0; i<n; ++i) {
if (!containsNone(c.getRangeStart(i), c.getRangeEnd(i))) {
- return FALSE;
+ return false;
}
}
return strings == nullptr || !c.hasStrings() || strings->containsNone(*c.strings);
@@ -531,10 +531,10 @@ UBool UnicodeSet::matchesIndexValue(uint8_t v) const {
UChar32 high = getRangeEnd(i);
if ((low & ~0xFF) == (high & ~0xFF)) {
if ((low & 0xFF) <= v && v <= (high & 0xFF)) {
- return TRUE;
+ return true;
}
} else if ((low & 0xFF) <= v || v <= (high & 0xFF)) {
- return TRUE;
+ return true;
}
}
if (hasStrings()) {
@@ -545,11 +545,11 @@ UBool UnicodeSet::matchesIndexValue(uint8_t v) const {
}
UChar32 c = s.char32At(0);
if ((c & 0xFF) == v) {
- return TRUE;
+ return true;
}
}
}
- return FALSE;
+ return false;
}
/**
@@ -582,7 +582,7 @@ UMatchDegree UnicodeSet::matches(const Replaceable& text,
// firstChar is the leftmost char to match in the
// forward direction or the rightmost char to match in
// the reverse direction.
- UChar firstChar = text.charAt(offset);
+ char16_t firstChar = text.charAt(offset);
// If there are multiple strings that can match we
// return the longest match.
@@ -594,7 +594,7 @@ UMatchDegree UnicodeSet::matches(const Replaceable& text,
continue; // skip the empty string
}
- UChar c = trial.charAt(forward ? 0 : trial.length() - 1);
+ char16_t c = trial.charAt(forward ? 0 : trial.length() - 1);
// Strings are sorted, so we can optimize in the
// forward direction.
@@ -977,7 +977,7 @@ void UnicodeSet::_add(const UnicodeString& s) {
return;
}
UnicodeString* t = new UnicodeString(s);
- if (t == NULL) { // Check for memory allocation error.
+ if (t == nullptr) { // Check for memory allocation error.
setToBogus();
return;
}
@@ -1075,7 +1075,7 @@ UnicodeSet& UnicodeSet::removeAllStrings() {
*/
UnicodeSet* U_EXPORT2 UnicodeSet::createFrom(const UnicodeString& s) {
UnicodeSet *set = new UnicodeSet();
- if (set != NULL) { // Check for memory allocation error.
+ if (set != nullptr) { // Check for memory allocation error.
set->add(s);
}
return set;
@@ -1089,7 +1089,7 @@ UnicodeSet* U_EXPORT2 UnicodeSet::createFrom(const UnicodeString& s) {
*/
UnicodeSet* U_EXPORT2 UnicodeSet::createFromAll(const UnicodeString& s) {
UnicodeSet *set = new UnicodeSet();
- if (set != NULL) { // Check for memory allocation error.
+ if (set != nullptr) { // Check for memory allocation error.
set->addAll(s);
}
return set;
@@ -1218,7 +1218,7 @@ UnicodeSet& UnicodeSet::complement(UChar32 c) {
* This is equivalent to
* <code>complement(MIN_VALUE, MAX_VALUE)</code>.
*/
-UnicodeSet& UnicodeSet::complement(void) {
+UnicodeSet& UnicodeSet::complement() {
if (isFrozen() || isBogus()) {
return *this;
}
@@ -1272,12 +1272,12 @@ UnicodeSet& UnicodeSet::complement(const UnicodeString& s) {
* @see #add(char, char)
*/
UnicodeSet& UnicodeSet::addAll(const UnicodeSet& c) {
- if ( c.len>0 && c.list!=NULL ) {
+ if ( c.len>0 && c.list!=nullptr ) {
add(c.list, c.len, 0);
}
// Add strings in order
- if ( c.strings!=NULL ) {
+ if ( c.strings!=nullptr ) {
for (int32_t i=0; i<c.strings->size(); ++i) {
const UnicodeString* s = (const UnicodeString*)c.strings->elementAt(i);
if (!stringsContains(*s)) {
@@ -1361,14 +1361,14 @@ UnicodeSet& UnicodeSet::complementAll(const UnicodeSet& c) {
* Removes all of the elements from this set. This set will be
* empty after this call returns.
*/
-UnicodeSet& UnicodeSet::clear(void) {
+UnicodeSet& UnicodeSet::clear() {
if (isFrozen()) {
return *this;
}
list[0] = UNICODESET_HIGH;
len = 1;
releasePattern();
- if (strings != NULL) {
+ if (strings != nullptr) {
strings->removeAllElements();
}
// Remove bogus
@@ -1421,7 +1421,7 @@ UnicodeSet& UnicodeSet::compact() {
// Delete buffer first to defragment memory less.
if (buffer != stackList) {
uprv_free(buffer);
- buffer = NULL;
+ buffer = nullptr;
bufferCapacity = 0;
}
if (list == stackList) {
@@ -1464,7 +1464,7 @@ UnicodeSet::UnicodeSet(const uint16_t data[], int32_t dataLen, ESerialization se
}
if( (serialization != kSerialized)
- || (data==NULL)
+ || (data==nullptr)
|| (dataLen < 1)) {
ec = U_ILLEGAL_ARGUMENT_ERROR;
setToBogus();
@@ -1513,7 +1513,7 @@ int32_t UnicodeSet::serialize(uint16_t *dest, int32_t destCapacity, UErrorCode&
return 0;
}
- if (destCapacity<0 || (destCapacity>0 && dest==NULL)) {
+ if (destCapacity<0 || (destCapacity>0 && dest==nullptr)) {
ec=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -1603,24 +1603,24 @@ int32_t UnicodeSet::serialize(uint16_t *dest, int32_t destCapacity, UErrorCode&
//----------------------------------------------------------------
/**
- * Allocate our strings vector and return TRUE if successful.
+ * Allocate our strings vector and return true if successful.
*/
UBool UnicodeSet::allocateStrings(UErrorCode &status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
strings = new UVector(uprv_deleteUObject,
uhash_compareUnicodeString, 1, status);
- if (strings == NULL) { // Check for memory allocation error.
+ if (strings == nullptr) { // Check for memory allocation error.
status = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
if (U_FAILURE(status)) {
delete strings;
- strings = NULL;
- return FALSE;
+ strings = nullptr;
+ return false;
}
- return TRUE;
+ return true;
}
int32_t UnicodeSet::nextCapacity(int32_t minCapacity) {
@@ -1647,7 +1647,7 @@ bool UnicodeSet::ensureCapacity(int32_t newLen) {
}
int32_t newCapacity = nextCapacity(newLen);
UChar32* temp = (UChar32*) uprv_malloc(newCapacity * sizeof(UChar32));
- if (temp == NULL) {
+ if (temp == nullptr) {
setToBogus(); // set the object to bogus state if an OOM failure occurred.
return false;
}
@@ -1670,7 +1670,7 @@ bool UnicodeSet::ensureBufferCapacity(int32_t newLen) {
}
int32_t newCapacity = nextCapacity(newLen);
UChar32* temp = (UChar32*) uprv_malloc(newCapacity * sizeof(UChar32));
- if (temp == NULL) {
+ if (temp == nullptr) {
setToBogus();
return false;
}
@@ -1687,7 +1687,7 @@ bool UnicodeSet::ensureBufferCapacity(int32_t newLen) {
/**
* Swap list and buffer.
*/
-void UnicodeSet::swapBuffers(void) {
+void UnicodeSet::swapBuffers() {
// swap list and buffer
UChar32* temp = list;
list = buffer;
@@ -1763,7 +1763,7 @@ void UnicodeSet::exclusiveOr(const UChar32* other, int32_t otherLen, int8_t pola
// polarity = 3: ~x union ~y
void UnicodeSet::add(const UChar32* other, int32_t otherLen, int8_t polarity) {
- if (isFrozen() || isBogus() || other==NULL) {
+ if (isFrozen() || isBogus() || other==nullptr) {
return;
}
if (!ensureBufferCapacity(len + otherLen)) {
@@ -2030,7 +2030,7 @@ void UnicodeSet::_appendToPat(UnicodeString &result, UChar32 start, UChar32 end,
UnicodeString& UnicodeSet::_toPattern(UnicodeString& result,
UBool escapeUnprintable) const
{
- if (pat != NULL) {
+ if (pat != nullptr) {
int32_t i;
int32_t backslashCount = 0;
for (i=0; i<patLen; ) {
@@ -2151,7 +2151,7 @@ UnicodeString& UnicodeSet::_generatePattern(UnicodeString& result,
void UnicodeSet::releasePattern() {
if (pat) {
uprv_free(pat);
- pat = NULL;
+ pat = nullptr;
patLen = 0;
}
}
@@ -2161,7 +2161,7 @@ void UnicodeSet::releasePattern() {
*/
void UnicodeSet::setPattern(const char16_t *newPat, int32_t newPatLen) {
releasePattern();
- pat = (UChar *)uprv_malloc((newPatLen + 1) * sizeof(UChar));
+ pat = (char16_t *)uprv_malloc((newPatLen + 1) * sizeof(char16_t));
if (pat) {
patLen = newPatLen;
u_memcpy(pat, newPat, patLen);
@@ -2188,13 +2188,13 @@ UnicodeSet *UnicodeSet::freeze() {
// many relevant strings as UTF-16.
// (Thus needsStringSpanUTF8() implies needsStringSpanUTF16().)
delete stringSpan;
- stringSpan = NULL;
+ stringSpan = nullptr;
}
}
- if (stringSpan == NULL) {
+ if (stringSpan == nullptr) {
// No span-relevant strings: Optimize for code point spans.
bmpSet=new BMPSet(list, len);
- if (bmpSet == NULL) { // Check for memory allocation error.
+ if (bmpSet == nullptr) { // Check for memory allocation error.
setToBogus();
}
}
@@ -2202,8 +2202,8 @@ UnicodeSet *UnicodeSet::freeze() {
return this;
}
-int32_t UnicodeSet::span(const UChar *s, int32_t length, USetSpanCondition spanCondition) const {
- if(length>0 && bmpSet!=NULL) {
+int32_t UnicodeSet::span(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const {
+ if(length>0 && bmpSet!=nullptr) {
return (int32_t)(bmpSet->span(s, s+length, spanCondition)-s);
}
if(length<0) {
@@ -2212,7 +2212,7 @@ int32_t UnicodeSet::span(const UChar *s, int32_t length, USetSpanCondition spanC
if(length==0) {
return 0;
}
- if(stringSpan!=NULL) {
+ if(stringSpan!=nullptr) {
return stringSpan->span(s, length, spanCondition);
} else if(hasStrings()) {
uint32_t which= spanCondition==USET_SPAN_NOT_CONTAINED ?
@@ -2239,8 +2239,8 @@ int32_t UnicodeSet::span(const UChar *s, int32_t length, USetSpanCondition spanC
return prev;
}
-int32_t UnicodeSet::spanBack(const UChar *s, int32_t length, USetSpanCondition spanCondition) const {
- if(length>0 && bmpSet!=NULL) {
+int32_t UnicodeSet::spanBack(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const {
+ if(length>0 && bmpSet!=nullptr) {
return (int32_t)(bmpSet->spanBack(s, s+length, spanCondition)-s);
}
if(length<0) {
@@ -2249,7 +2249,7 @@ int32_t UnicodeSet::spanBack(const UChar *s, int32_t length, USetSpanCondition s
if(length==0) {
return 0;
}
- if(stringSpan!=NULL) {
+ if(stringSpan!=nullptr) {
return stringSpan->spanBack(s, length, spanCondition);
} else if(hasStrings()) {
uint32_t which= spanCondition==USET_SPAN_NOT_CONTAINED ?
@@ -2277,7 +2277,7 @@ int32_t UnicodeSet::spanBack(const UChar *s, int32_t length, USetSpanCondition s
}
int32_t UnicodeSet::spanUTF8(const char *s, int32_t length, USetSpanCondition spanCondition) const {
- if(length>0 && bmpSet!=NULL) {
+ if(length>0 && bmpSet!=nullptr) {
const uint8_t *s0=(const uint8_t *)s;
return (int32_t)(bmpSet->spanUTF8(s0, length, spanCondition)-s0);
}
@@ -2287,7 +2287,7 @@ int32_t UnicodeSet::spanUTF8(const char *s, int32_t length, USetSpanCondition sp
if(length==0) {
return 0;
}
- if(stringSpan!=NULL) {
+ if(stringSpan!=nullptr) {
return stringSpan->spanUTF8((const uint8_t *)s, length, spanCondition);
} else if(hasStrings()) {
uint32_t which= spanCondition==USET_SPAN_NOT_CONTAINED ?
@@ -2315,7 +2315,7 @@ int32_t UnicodeSet::spanUTF8(const char *s, int32_t length, USetSpanCondition sp
}
int32_t UnicodeSet::spanBackUTF8(const char *s, int32_t length, USetSpanCondition spanCondition) const {
- if(length>0 && bmpSet!=NULL) {
+ if(length>0 && bmpSet!=nullptr) {
const uint8_t *s0=(const uint8_t *)s;
return bmpSet->spanBackUTF8(s0, length, spanCondition);
}
@@ -2325,7 +2325,7 @@ int32_t UnicodeSet::spanBackUTF8(const char *s, int32_t length, USetSpanConditio
if(length==0) {
return 0;
}
- if(stringSpan!=NULL) {
+ if(stringSpan!=nullptr) {
return stringSpan->spanBackUTF8((const uint8_t *)s, length, spanCondition);
} else if(hasStrings()) {
uint32_t which= spanCondition==USET_SPAN_NOT_CONTAINED ?