summaryrefslogtreecommitdiff
path: root/thirdparty/icu4c/common/utext.cpp
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-10-28 09:11:55 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-10-28 09:11:55 +0300
commit4e44a271f0cfd00f5d278fd3001f1750cf934e42 (patch)
tree4dda3aa82f579c74cf6db1116b50cf8c18a75304 /thirdparty/icu4c/common/utext.cpp
parent9ff3a43a329182ba2fad34263297052c70a4524e (diff)
ICU: Update to version 72.1
Diffstat (limited to 'thirdparty/icu4c/common/utext.cpp')
-rw-r--r--thirdparty/icu4c/common/utext.cpp126
1 files changed, 63 insertions, 63 deletions
diff --git a/thirdparty/icu4c/common/utext.cpp b/thirdparty/icu4c/common/utext.cpp
index ec79700ca8..548e6a60f3 100644
--- a/thirdparty/icu4c/common/utext.cpp
+++ b/thirdparty/icu4c/common/utext.cpp
@@ -49,14 +49,14 @@ utext_moveIndex32(UText *ut, int32_t delta) {
UChar32 c;
if (delta > 0) {
do {
- if(ut->chunkOffset>=ut->chunkLength && !utext_access(ut, ut->chunkNativeLimit, TRUE)) {
- return FALSE;
+ if(ut->chunkOffset>=ut->chunkLength && !utext_access(ut, ut->chunkNativeLimit, true)) {
+ return false;
}
c = ut->chunkContents[ut->chunkOffset];
if (U16_IS_SURROGATE(c)) {
c = utext_next32(ut);
if (c == U_SENTINEL) {
- return FALSE;
+ return false;
}
} else {
ut->chunkOffset++;
@@ -65,14 +65,14 @@ utext_moveIndex32(UText *ut, int32_t delta) {
} else if (delta<0) {
do {
- if(ut->chunkOffset<=0 && !utext_access(ut, ut->chunkNativeStart, FALSE)) {
- return FALSE;
+ if(ut->chunkOffset<=0 && !utext_access(ut, ut->chunkNativeStart, false)) {
+ return false;
}
c = ut->chunkContents[ut->chunkOffset-1];
if (U16_IS_SURROGATE(c)) {
c = utext_previous32(ut);
if (c == U_SENTINEL) {
- return FALSE;
+ return false;
}
} else {
ut->chunkOffset--;
@@ -80,7 +80,7 @@ utext_moveIndex32(UText *ut, int32_t delta) {
} while(++delta<0);
}
- return TRUE;
+ return true;
}
@@ -114,7 +114,7 @@ utext_setNativeIndex(UText *ut, int64_t index) {
// Access the new position. Assume a forward iteration from here,
// which will also be optimimum for a single random access.
// Reverse iterations may suffer slightly.
- ut->pFuncs->access(ut, index, TRUE);
+ ut->pFuncs->access(ut, index, true);
} else if((int32_t)(index - ut->chunkNativeStart) <= ut->nativeIndexingLimit) {
// utf-16 indexing.
ut->chunkOffset=(int32_t)(index-ut->chunkNativeStart);
@@ -127,7 +127,7 @@ utext_setNativeIndex(UText *ut, int64_t index) {
UChar c= ut->chunkContents[ut->chunkOffset];
if (U16_IS_TRAIL(c)) {
if (ut->chunkOffset==0) {
- ut->pFuncs->access(ut, ut->chunkNativeStart, FALSE);
+ ut->pFuncs->access(ut, ut->chunkNativeStart, false);
}
if (ut->chunkOffset>0) {
UChar lead = ut->chunkContents[ut->chunkOffset-1];
@@ -152,7 +152,7 @@ utext_getPreviousNativeIndex(UText *ut) {
int64_t result;
if (i >= 0) {
UChar c = ut->chunkContents[i];
- if (U16_IS_TRAIL(c) == FALSE) {
+ if (U16_IS_TRAIL(c) == false) {
if (i <= ut->nativeIndexingLimit) {
result = ut->chunkNativeStart + i;
} else {
@@ -189,14 +189,14 @@ utext_current32(UText *ut) {
UChar32 c;
if (ut->chunkOffset==ut->chunkLength) {
// Current position is just off the end of the chunk.
- if (ut->pFuncs->access(ut, ut->chunkNativeLimit, TRUE) == FALSE) {
+ if (ut->pFuncs->access(ut, ut->chunkNativeLimit, true) == false) {
// Off the end of the text.
return U_SENTINEL;
}
}
c = ut->chunkContents[ut->chunkOffset];
- if (U16_IS_LEAD(c) == FALSE) {
+ if (U16_IS_LEAD(c) == false) {
// Normal, non-supplementary case.
return c;
}
@@ -219,11 +219,11 @@ utext_current32(UText *ut) {
// the original position before the unpaired lead still needs to be restored.
int64_t nativePosition = ut->chunkNativeLimit;
int32_t originalOffset = ut->chunkOffset;
- if (ut->pFuncs->access(ut, nativePosition, TRUE)) {
+ if (ut->pFuncs->access(ut, nativePosition, true)) {
trail = ut->chunkContents[ut->chunkOffset];
}
- UBool r = ut->pFuncs->access(ut, nativePosition, FALSE); // reverse iteration flag loads preceding chunk
- U_ASSERT(r==TRUE);
+ UBool r = ut->pFuncs->access(ut, nativePosition, false); // reverse iteration flag loads preceding chunk
+ U_ASSERT(r==true);
ut->chunkOffset = originalOffset;
if(!r) {
return U_SENTINEL;
@@ -246,7 +246,7 @@ utext_char32At(UText *ut, int64_t nativeIndex) {
if (nativeIndex>=ut->chunkNativeStart && nativeIndex < ut->chunkNativeStart + ut->nativeIndexingLimit) {
ut->chunkOffset = (int32_t)(nativeIndex - ut->chunkNativeStart);
c = ut->chunkContents[ut->chunkOffset];
- if (U16_IS_SURROGATE(c) == FALSE) {
+ if (U16_IS_SURROGATE(c) == false) {
return c;
}
}
@@ -270,13 +270,13 @@ utext_next32(UText *ut) {
UChar32 c;
if (ut->chunkOffset >= ut->chunkLength) {
- if (ut->pFuncs->access(ut, ut->chunkNativeLimit, TRUE) == FALSE) {
+ if (ut->pFuncs->access(ut, ut->chunkNativeLimit, true) == false) {
return U_SENTINEL;
}
}
c = ut->chunkContents[ut->chunkOffset++];
- if (U16_IS_LEAD(c) == FALSE) {
+ if (U16_IS_LEAD(c) == false) {
// Normal case, not supplementary.
// (A trail surrogate seen here is just returned as is, as a surrogate value.
// It cannot be part of a pair.)
@@ -284,14 +284,14 @@ utext_next32(UText *ut) {
}
if (ut->chunkOffset >= ut->chunkLength) {
- if (ut->pFuncs->access(ut, ut->chunkNativeLimit, TRUE) == FALSE) {
+ if (ut->pFuncs->access(ut, ut->chunkNativeLimit, true) == false) {
// c is an unpaired lead surrogate at the end of the text.
// return it as it is.
return c;
}
}
UChar32 trail = ut->chunkContents[ut->chunkOffset];
- if (U16_IS_TRAIL(trail) == FALSE) {
+ if (U16_IS_TRAIL(trail) == false) {
// c was an unpaired lead surrogate, not at the end of the text.
// return it as it is (unpaired). Iteration position is on the
// following character, possibly in the next chunk, where the
@@ -310,13 +310,13 @@ utext_previous32(UText *ut) {
UChar32 c;
if (ut->chunkOffset <= 0) {
- if (ut->pFuncs->access(ut, ut->chunkNativeStart, FALSE) == FALSE) {
+ if (ut->pFuncs->access(ut, ut->chunkNativeStart, false) == false) {
return U_SENTINEL;
}
}
ut->chunkOffset--;
c = ut->chunkContents[ut->chunkOffset];
- if (U16_IS_TRAIL(c) == FALSE) {
+ if (U16_IS_TRAIL(c) == false) {
// Normal case, not supplementary.
// (A lead surrogate seen here is just returned as is, as a surrogate value.
// It cannot be part of a pair.)
@@ -324,7 +324,7 @@ utext_previous32(UText *ut) {
}
if (ut->chunkOffset <= 0) {
- if (ut->pFuncs->access(ut, ut->chunkNativeStart, FALSE) == FALSE) {
+ if (ut->pFuncs->access(ut, ut->chunkNativeStart, false) == false) {
// c is an unpaired trail surrogate at the start of the text.
// return it as it is.
return c;
@@ -332,7 +332,7 @@ utext_previous32(UText *ut) {
}
UChar32 lead = ut->chunkContents[ut->chunkOffset-1];
- if (U16_IS_LEAD(lead) == FALSE) {
+ if (U16_IS_LEAD(lead) == false) {
// c was an unpaired trail surrogate, not at the end of the text.
// return it as it is (unpaired). Iteration position is at c
return c;
@@ -351,7 +351,7 @@ utext_next32From(UText *ut, int64_t index) {
if(index<ut->chunkNativeStart || index>=ut->chunkNativeLimit) {
// Desired position is outside of the current chunk.
- if(!ut->pFuncs->access(ut, index, TRUE)) {
+ if(!ut->pFuncs->access(ut, index, true)) {
// no chunk available here
return U_SENTINEL;
}
@@ -391,7 +391,7 @@ utext_previous32From(UText *ut, int64_t index) {
//
if(index<=ut->chunkNativeStart || index>ut->chunkNativeLimit) {
// Requested native index is outside of the current chunk.
- if(!ut->pFuncs->access(ut, index, FALSE)) {
+ if(!ut->pFuncs->access(ut, index, false)) {
// no chunk available here
return U_SENTINEL;
}
@@ -400,7 +400,7 @@ utext_previous32From(UText *ut, int64_t index) {
ut->chunkOffset = (int32_t)(index - ut->chunkNativeStart);
} else {
ut->chunkOffset=ut->pFuncs->mapNativeIndexToUTF16(ut, index);
- if (ut->chunkOffset==0 && !ut->pFuncs->access(ut, index, FALSE)) {
+ if (ut->chunkOffset==0 && !ut->pFuncs->access(ut, index, false)) {
// no chunk available here
return U_SENTINEL;
}
@@ -438,24 +438,24 @@ utext_equals(const UText *a, const UText *b) {
a->magic != UTEXT_MAGIC ||
b->magic != UTEXT_MAGIC) {
// Null or invalid arguments don't compare equal to anything.
- return FALSE;
+ return false;
}
if (a->pFuncs != b->pFuncs) {
// Different types of text providers.
- return FALSE;
+ return false;
}
if (a->context != b->context) {
// Different sources (different strings)
- return FALSE;
+ return false;
}
if (utext_getNativeIndex(a) != utext_getNativeIndex(b)) {
// Different current position in the string.
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
U_CAPI UBool U_EXPORT2
@@ -987,7 +987,7 @@ utf8TextAccess(UText *ut, int64_t index, UBool forward) {
// Don't swap buffers, but do set the
// current buffer position.
ut->chunkOffset = ut->chunkLength;
- return FALSE;
+ return false;
} else {
// End of current buffer.
// check whether other buffer already has what we need.
@@ -1016,7 +1016,7 @@ utf8TextAccess(UText *ut, int64_t index, UBool forward) {
// Current buffer extends up to the end of the string.
// Leave it as the current buffer.
ut->chunkOffset = ut->chunkLength;
- return FALSE;
+ return false;
}
if (ix == u8b->bufNativeLimit) {
// Alternate buffer extends to the end of string.
@@ -1038,7 +1038,7 @@ utf8TextAccess(UText *ut, int64_t index, UBool forward) {
mapIndex = ix - u8b->toUCharsMapStart;
U_ASSERT(mapIndex < (int32_t)sizeof(UTF8Buf::mapToUChars));
ut->chunkOffset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx;
- return TRUE;
+ return true;
}
}
@@ -1055,7 +1055,7 @@ utf8TextAccess(UText *ut, int64_t index, UBool forward) {
// Don't swap buffers, but do set the
// current buffer position.
ut->chunkOffset = 0;
- return FALSE;
+ return false;
} else {
// Start of current buffer.
// check whether other buffer already has what we need.
@@ -1108,9 +1108,9 @@ utf8TextAccess(UText *ut, int64_t index, UBool forward) {
// one of the trailing bytes. Because there is no preceding ,
// character, this access fails. We can't pick up on the
// situation sooner because the requested index is not zero.
- return FALSE;
+ return false;
} else {
- return TRUE;
+ return true;
}
@@ -1139,7 +1139,7 @@ swapBuffers:
U_ASSERT(mapIndex<(int32_t)sizeof(u8b->mapToUChars));
ut->chunkOffset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx;
- return TRUE;
+ return true;
}
@@ -1170,7 +1170,7 @@ swapBuffers:
ut->chunkOffset = 0;
U_ASSERT(ix == u8b->bufNativeStart);
}
- return FALSE;
+ return false;
makeStubBuffer:
// The user has done a seek/access past the start or end
@@ -1203,10 +1203,10 @@ fillForward:
ut->p = u8b_swap;
int32_t strLen = ut->b;
- UBool nulTerminated = FALSE;
+ UBool nulTerminated = false;
if (strLen < 0) {
strLen = 0x7fffffff;
- nulTerminated = TRUE;
+ nulTerminated = true;
}
UChar *buf = u8b_swap->buf;
@@ -1214,7 +1214,7 @@ fillForward:
uint8_t *mapToUChars = u8b_swap->mapToUChars;
int32_t destIx = 0;
int32_t srcIx = ix;
- UBool seenNonAscii = FALSE;
+ UBool seenNonAscii = false;
UChar32 c = 0;
// Fill the chunk buffer and mapping arrays.
@@ -1230,8 +1230,8 @@ fillForward:
destIx++;
} else {
// General case, handle everything.
- if (seenNonAscii == FALSE) {
- seenNonAscii = TRUE;
+ if (seenNonAscii == false) {
+ seenNonAscii = true;
u8b_swap->bufNILimit = destIx;
}
@@ -1269,7 +1269,7 @@ fillForward:
u8b_swap->bufNativeLimit = srcIx;
u8b_swap->bufStartIdx = 0;
u8b_swap->bufLimitIdx = destIx;
- if (seenNonAscii == FALSE) {
+ if (seenNonAscii == false) {
u8b_swap->bufNILimit = destIx;
}
u8b_swap->toUCharsMapStart = u8b_swap->bufNativeStart;
@@ -1293,7 +1293,7 @@ fillForward:
ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE);
}
}
- return TRUE;
+ return true;
}
@@ -1402,7 +1402,7 @@ fillReverse:
ut->chunkNativeStart = u8b_swap->bufNativeStart;
ut->chunkNativeLimit = u8b_swap->bufNativeLimit;
ut->nativeIndexingLimit = u8b_swap->bufNILimit;
- return TRUE;
+ return true;
}
}
@@ -1526,7 +1526,7 @@ utf8TextExtract(UText *ut,
utext_strFromUTF8(dest, destCapacity, &destLength,
(const char *)ut->context+start32, limit32-start32,
pErrorCode);
- utf8TextAccess(ut, limit32, TRUE);
+ utf8TextAccess(ut, limit32, true);
return destLength;
}
@@ -1760,13 +1760,13 @@ repTextAccess(UText *ut, int64_t index, UBool forward) {
if (index32>=ut->chunkNativeStart && index32<ut->chunkNativeLimit) {
// Buffer already contains the requested position.
ut->chunkOffset = (int32_t)(index - ut->chunkNativeStart);
- return TRUE;
+ return true;
}
if (index32>=length && ut->chunkNativeLimit==length) {
// Request for end of string, and buffer already extends up to it.
// Can't get the data, but don't change the buffer.
ut->chunkOffset = length - (int32_t)ut->chunkNativeStart;
- return FALSE;
+ return false;
}
ut->chunkNativeLimit = index + REP_TEXT_CHUNK_SIZE - 1;
@@ -1787,13 +1787,13 @@ repTextAccess(UText *ut, int64_t index, UBool forward) {
if (index32>ut->chunkNativeStart && index32<=ut->chunkNativeLimit) {
// Requested position already in buffer.
ut->chunkOffset = index32 - (int32_t)ut->chunkNativeStart;
- return TRUE;
+ return true;
}
if (index32==0 && ut->chunkNativeStart==0) {
// Request for start, buffer already begins at start.
// No data, but keep the buffer as is.
ut->chunkOffset = 0;
- return FALSE;
+ return false;
}
// Figure out the bounds of the chunk to extract for reverse iteration.
@@ -1849,7 +1849,7 @@ repTextAccess(UText *ut, int64_t index, UBool forward) {
// Use fast indexing for get/setNativeIndex()
ut->nativeIndexingLimit = ut->chunkLength;
- return TRUE;
+ return true;
}
@@ -1892,7 +1892,7 @@ repTextExtract(UText *ut,
}
UnicodeString buffer(dest, 0, destCapacity); // writable alias
rep->extractBetween(start32, limit32, buffer);
- repTextAccess(ut, limit32, TRUE);
+ repTextAccess(ut, limit32, true);
return u_terminateUChars(dest, destCapacity, length, status);
}
@@ -1948,7 +1948,7 @@ repTextReplace(UText *ut,
// set the iteration position to the end of the newly inserted replacement text.
int32_t newIndexPos = limit32 + lengthDelta;
- repTextAccess(ut, newIndexPos, TRUE);
+ repTextAccess(ut, newIndexPos, true);
return lengthDelta;
}
@@ -2012,7 +2012,7 @@ repTextCopy(UText *ut,
}
// Set position, reload chunk if needed.
- repTextAccess(ut, nativeIterIndex, TRUE);
+ repTextAccess(ut, nativeIterIndex, true);
}
static const struct UTextFuncs repFuncs =
@@ -2254,7 +2254,7 @@ unistrTextCopy(UText *ut,
// update chunk description, set iteration position.
ut->chunkContents = us->getBuffer();
- if (move==FALSE) {
+ if (move==false) {
// copy operation, string length grows
ut->chunkLength += limit32-start32;
ut->chunkNativeLimit = ut->chunkLength;
@@ -2525,7 +2525,7 @@ ucstrTextExtract(UText *ut,
// Access the start. Does two things we need:
// Pins 'start' to the length of the string, if it came in out-of-bounds.
// Snaps 'start' to the beginning of a code point.
- ucstrTextAccess(ut, start, TRUE);
+ ucstrTextAccess(ut, start, true);
const UChar *s=ut->chunkContents;
start32 = ut->chunkOffset;
@@ -2579,7 +2579,7 @@ ucstrTextExtract(UText *ut,
if (si <= ut->chunkNativeLimit) {
ut->chunkOffset = si;
} else {
- ucstrTextAccess(ut, si, TRUE);
+ ucstrTextAccess(ut, si, true);
}
// Add a terminating NUL if space in the buffer permits,
@@ -2698,11 +2698,11 @@ charIterTextAccess(UText *ut, int64_t index, UBool forward) {
neededIndex -= neededIndex % CIBufSize;
UChar *buf = NULL;
- UBool needChunkSetup = TRUE;
+ UBool needChunkSetup = true;
int i;
if (ut->chunkNativeStart == neededIndex) {
// The buffer we want is already the current chunk.
- needChunkSetup = FALSE;
+ needChunkSetup = false;
} else if (ut->b == neededIndex) {
// The first buffer (buffer p) has what we need.
buf = (UChar *)ut->p;
@@ -2809,7 +2809,7 @@ charIterTextExtract(UText *ut,
srci += len;
}
- charIterTextAccess(ut, copyLimit, TRUE);
+ charIterTextAccess(ut, copyLimit, true);
u_terminateUChars(dest, destCapacity, desti, status);
return desti;