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/edits.cpp | |
parent | ccb790c507bd5e8ffe2ef9886ce5ee0a7ce22a15 (diff) | |
download | ydb-cfcd865e05c0d0525ea27d1e153a043b32a85138.tar.gz |
Update ICU to 73.2
Diffstat (limited to 'contrib/libs/icu/common/edits.cpp')
-rw-r--r-- | contrib/libs/icu/common/edits.cpp | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/contrib/libs/icu/common/edits.cpp b/contrib/libs/icu/common/edits.cpp index 92ca36fb5d..3348145d48 100644 --- a/contrib/libs/icu/common/edits.cpp +++ b/contrib/libs/icu/common/edits.cpp @@ -35,7 +35,7 @@ const int32_t LENGTH_IN_2TRAIL = 62; } // namespace -void Edits::releaseArray() U_NOEXCEPT { +void Edits::releaseArray() noexcept { if (array != stackArray) { uprv_free(array); } @@ -63,7 +63,7 @@ Edits &Edits::copyArray(const Edits &other) { return *this; } -Edits &Edits::moveArray(Edits &src) U_NOEXCEPT { +Edits &Edits::moveArray(Edits &src) noexcept { if (U_FAILURE(errorCode_)) { length = delta = numChanges = 0; return *this; @@ -94,7 +94,7 @@ Edits &Edits::operator=(const Edits &other) { return copyArray(other); } -Edits &Edits::operator=(Edits &&src) U_NOEXCEPT { +Edits &Edits::operator=(Edits &&src) noexcept { length = src.length; delta = src.delta; numChanges = src.numChanges; @@ -106,7 +106,7 @@ Edits::~Edits() { releaseArray(); } -void Edits::reset() U_NOEXCEPT { +void Edits::reset() noexcept { length = delta = numChanges = 0; errorCode_ = U_ZERO_ERROR; } @@ -221,7 +221,7 @@ UBool Edits::growArray() { // Not U_BUFFER_OVERFLOW_ERROR because that could be confused on a string transform API // with a result-string-buffer overflow. errorCode_ = U_INDEX_OUTOFBOUNDS_ERROR; - return FALSE; + return false; } else if (capacity >= (INT32_MAX / 2)) { newCapacity = INT32_MAX; } else { @@ -230,25 +230,25 @@ UBool Edits::growArray() { // Grow by at least 5 units so that a maximal change record will fit. if ((newCapacity - capacity) < 5) { errorCode_ = U_INDEX_OUTOFBOUNDS_ERROR; - return FALSE; + return false; } uint16_t *newArray = (uint16_t *)uprv_malloc((size_t)newCapacity * 2); - if (newArray == NULL) { + if (newArray == nullptr) { errorCode_ = U_MEMORY_ALLOCATION_ERROR; - return FALSE; + return false; } uprv_memcpy(newArray, array, (size_t)length * 2); releaseArray(); array = newArray; capacity = newCapacity; - return TRUE; + return true; } UBool Edits::copyErrorTo(UErrorCode &outErrorCode) const { - if (U_FAILURE(outErrorCode)) { return TRUE; } - if (U_SUCCESS(errorCode_)) { return FALSE; } + if (U_FAILURE(outErrorCode)) { return true; } + if (U_SUCCESS(errorCode_)) { return false; } outErrorCode = errorCode_; - return TRUE; + return true; } Edits &Edits::mergeAndAppend(const Edits &ab, const Edits &bc, UErrorCode &errorCode) { @@ -257,7 +257,7 @@ Edits &Edits::mergeAndAppend(const Edits &ab, const Edits &bc, UErrorCode &error // Parallel iteration over both Edits. Iterator abIter = ab.getFineIterator(); Iterator bcIter = bc.getFineIterator(); - UBool abHasNext = TRUE, bcHasNext = TRUE; + UBool abHasNext = true, bcHasNext = true; // Copy iterator state into local variables, so that we can modify and subdivide spans. // ab old & new length, bc old & new length int32_t aLength = 0, ab_bLength = 0, bc_bLength = 0, cLength = 0; @@ -400,7 +400,7 @@ Edits &Edits::mergeAndAppend(const Edits &ab, const Edits &bc, UErrorCode &error Edits::Iterator::Iterator(const uint16_t *a, int32_t len, UBool oc, UBool crs) : array(a), index(0), length(len), remaining(0), onlyChanges_(oc), coarse(crs), - dir(0), changed(FALSE), oldLength_(0), newLength_(0), + dir(0), changed(false), oldLength_(0), newLength_(0), srcIndex(0), replIndex(0), destIndex(0) {} int32_t Edits::Iterator::readLength(int32_t head) { @@ -441,16 +441,16 @@ void Edits::Iterator::updatePreviousIndexes() { UBool Edits::Iterator::noNext() { // No change before or beyond the string. dir = 0; - changed = FALSE; + changed = false; oldLength_ = newLength_ = 0; - return FALSE; + return false; } UBool Edits::Iterator::next(UBool onlyChanges, UErrorCode &errorCode) { // Forward iteration: Update the string indexes to the limit of the current span, // and post-increment-read array units to assemble a new span. // Leaves the array index one after the last unit of that span. - if (U_FAILURE(errorCode)) { return FALSE; } + if (U_FAILURE(errorCode)) { return false; } // We have an errorCode in case we need to start guarding against integer overflows. // It is also convenient for caller loops if we bail out when an error was set elsewhere. if (dir > 0) { @@ -464,7 +464,7 @@ UBool Edits::Iterator::next(UBool onlyChanges, UErrorCode &errorCode) { // Stay on the current one of a sequence of compressed changes. ++index; // next() rests on the index after the sequence unit. dir = 1; - return TRUE; + return true; } } dir = 1; @@ -473,7 +473,7 @@ UBool Edits::Iterator::next(UBool onlyChanges, UErrorCode &errorCode) { // Fine-grained iterator: Continue a sequence of compressed changes. if (remaining > 1) { --remaining; - return TRUE; + return true; } remaining = 0; } @@ -483,7 +483,7 @@ UBool Edits::Iterator::next(UBool onlyChanges, UErrorCode &errorCode) { int32_t u = array[index++]; if (u <= MAX_UNCHANGED) { // Combine adjacent unchanged ranges. - changed = FALSE; + changed = false; oldLength_ = u + 1; while (index < length && (u = array[index]) <= MAX_UNCHANGED) { ++index; @@ -498,10 +498,10 @@ UBool Edits::Iterator::next(UBool onlyChanges, UErrorCode &errorCode) { // already fetched u > MAX_UNCHANGED at index ++index; } else { - return TRUE; + return true; } } - changed = TRUE; + changed = true; if (u <= MAX_SHORT_CHANGE) { int32_t oldLen = u >> 12; int32_t newLen = (u >> 9) & MAX_SHORT_CHANGE_NEW_LENGTH; @@ -516,14 +516,14 @@ UBool Edits::Iterator::next(UBool onlyChanges, UErrorCode &errorCode) { if (num > 1) { remaining = num; // This is the first of two or more changes. } - return TRUE; + return true; } } else { U_ASSERT(u <= 0x7fff); oldLength_ = readLength((u >> 6) & 0x3f); newLength_ = readLength(u & 0x3f); if (!coarse) { - return TRUE; + return true; } } // Combine adjacent changes. @@ -539,14 +539,14 @@ UBool Edits::Iterator::next(UBool onlyChanges, UErrorCode &errorCode) { newLength_ += readLength(u & 0x3f); } } - return TRUE; + return true; } UBool Edits::Iterator::previous(UErrorCode &errorCode) { // Backward iteration: Pre-decrement-read array units to assemble a new span, // then update the string indexes to the start of that span. // Leaves the array index on the head unit of that span. - if (U_FAILURE(errorCode)) { return FALSE; } + if (U_FAILURE(errorCode)) { return false; } // We have an errorCode in case we need to start guarding against integer overflows. // It is also convenient for caller loops if we bail out when an error was set elsewhere. if (dir >= 0) { @@ -559,7 +559,7 @@ UBool Edits::Iterator::previous(UErrorCode &errorCode) { // Stay on the current one of a sequence of compressed changes. --index; // previous() rests on the sequence unit. dir = -1; - return TRUE; + return true; } updateNextIndexes(); } @@ -572,7 +572,7 @@ UBool Edits::Iterator::previous(UErrorCode &errorCode) { if (remaining <= (u & SHORT_CHANGE_NUM_MASK)) { ++remaining; updatePreviousIndexes(); - return TRUE; + return true; } remaining = 0; } @@ -582,7 +582,7 @@ UBool Edits::Iterator::previous(UErrorCode &errorCode) { int32_t u = array[--index]; if (u <= MAX_UNCHANGED) { // Combine adjacent unchanged ranges. - changed = FALSE; + changed = false; oldLength_ = u + 1; while (index > 0 && (u = array[index - 1]) <= MAX_UNCHANGED) { --index; @@ -591,9 +591,9 @@ UBool Edits::Iterator::previous(UErrorCode &errorCode) { newLength_ = oldLength_; // No need to handle onlyChanges as long as previous() is called only from findIndex(). updatePreviousIndexes(); - return TRUE; + return true; } - changed = TRUE; + changed = true; if (u <= MAX_SHORT_CHANGE) { int32_t oldLen = u >> 12; int32_t newLen = (u >> 9) & MAX_SHORT_CHANGE_NEW_LENGTH; @@ -609,7 +609,7 @@ UBool Edits::Iterator::previous(UErrorCode &errorCode) { remaining = 1; // This is the last of two or more changes. } updatePreviousIndexes(); - return TRUE; + return true; } } else { if (u <= 0x7fff) { @@ -629,7 +629,7 @@ UBool Edits::Iterator::previous(UErrorCode &errorCode) { } if (!coarse) { updatePreviousIndexes(); - return TRUE; + return true; } } // Combine adjacent changes. @@ -648,7 +648,7 @@ UBool Edits::Iterator::previous(UErrorCode &errorCode) { } } updatePreviousIndexes(); - return TRUE; + return true; } int32_t Edits::Iterator::findIndex(int32_t i, UBool findSource, UErrorCode &errorCode) { @@ -705,7 +705,7 @@ int32_t Edits::Iterator::findIndex(int32_t i, UBool findSource, UErrorCode &erro // The index is in the current span. return 0; } - while (next(FALSE, errorCode)) { + while (next(false, errorCode)) { if (findSource) { spanStart = srcIndex; spanLength = oldLength_; @@ -739,7 +739,7 @@ int32_t Edits::Iterator::findIndex(int32_t i, UBool findSource, UErrorCode &erro } int32_t Edits::Iterator::destinationIndexFromSourceIndex(int32_t i, UErrorCode &errorCode) { - int32_t where = findIndex(i, TRUE, errorCode); + int32_t where = findIndex(i, true, errorCode); if (where < 0) { // Error or before the string. return 0; @@ -758,7 +758,7 @@ int32_t Edits::Iterator::destinationIndexFromSourceIndex(int32_t i, UErrorCode & } int32_t Edits::Iterator::sourceIndexFromDestinationIndex(int32_t i, UErrorCode &errorCode) { - int32_t where = findIndex(i, FALSE, errorCode); + int32_t where = findIndex(i, false, errorCode); if (where < 0) { // Error or before the string. return 0; |