• Home
  • Raw
  • Download

Lines Matching +full:fast +full:- +full:deep +full:- +full:equal

6 *   Copyright (C) 2005-2016, International Business Machines
11 * encoding: UTF-8
42 return ut->pFuncs->access(ut, index, forward); in utext_access()
52 if(ut->chunkOffset>=ut->chunkLength && !utext_access(ut, ut->chunkNativeLimit, true)) { in utext_moveIndex32()
55 c = ut->chunkContents[ut->chunkOffset]; in utext_moveIndex32()
62 ut->chunkOffset++; in utext_moveIndex32()
64 } while(--delta>0); in utext_moveIndex32()
68 if(ut->chunkOffset<=0 && !utext_access(ut, ut->chunkNativeStart, false)) { in utext_moveIndex32()
71 c = ut->chunkContents[ut->chunkOffset-1]; in utext_moveIndex32()
78 ut->chunkOffset--; in utext_moveIndex32()
89 return ut->pFuncs->nativeLength(ut); in utext_nativeLength()
95 UBool r = (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE)) != 0; in utext_isLengthExpensive()
102 if(ut->chunkOffset <= ut->nativeIndexingLimit) { in utext_getNativeIndex()
103 return ut->chunkNativeStart+ut->chunkOffset; in utext_getNativeIndex()
105 return ut->pFuncs->mapOffsetToNative(ut); in utext_getNativeIndex()
112 if(index<ut->chunkNativeStart || index>=ut->chunkNativeLimit) { in utext_setNativeIndex()
117 ut->pFuncs->access(ut, index, true); in utext_setNativeIndex()
118 } else if((int32_t)(index - ut->chunkNativeStart) <= ut->nativeIndexingLimit) { in utext_setNativeIndex()
119 // utf-16 indexing. in utext_setNativeIndex()
120 ut->chunkOffset=(int32_t)(index-ut->chunkNativeStart); in utext_setNativeIndex()
122 ut->chunkOffset=ut->pFuncs->mapNativeIndexToUTF16(ut, index); in utext_setNativeIndex()
126 if (ut->chunkOffset<ut->chunkLength) { in utext_setNativeIndex()
127 UChar c= ut->chunkContents[ut->chunkOffset]; in utext_setNativeIndex()
129 if (ut->chunkOffset==0) { in utext_setNativeIndex()
130 ut->pFuncs->access(ut, ut->chunkNativeStart, false); in utext_setNativeIndex()
132 if (ut->chunkOffset>0) { in utext_setNativeIndex()
133 UChar lead = ut->chunkContents[ut->chunkOffset-1]; in utext_setNativeIndex()
135 ut->chunkOffset--; in utext_setNativeIndex()
147 // Fast-path the common case. in utext_getPreviousNativeIndex()
151 int32_t i = ut->chunkOffset - 1; in utext_getPreviousNativeIndex()
154 UChar c = ut->chunkContents[i]; in utext_getPreviousNativeIndex()
156 if (i <= ut->nativeIndexingLimit) { in utext_getPreviousNativeIndex()
157 result = ut->chunkNativeStart + i; in utext_getPreviousNativeIndex()
159 ut->chunkOffset = i; in utext_getPreviousNativeIndex()
160 result = ut->pFuncs->mapOffsetToNative(ut); in utext_getPreviousNativeIndex()
161 ut->chunkOffset++; in utext_getPreviousNativeIndex()
168 if (ut->chunkOffset==0 && ut->chunkNativeStart==0) { in utext_getPreviousNativeIndex()
190 if (ut->chunkOffset==ut->chunkLength) { in utext_current32()
192 if (ut->pFuncs->access(ut, ut->chunkNativeLimit, true) == false) { in utext_current32()
198 c = ut->chunkContents[ut->chunkOffset]; in utext_current32()
200 // Normal, non-supplementary case. in utext_current32()
209 if ((ut->chunkOffset+1) < ut->chunkLength) { in utext_current32()
211 trail = ut->chunkContents[ut->chunkOffset+1]; in utext_current32()
220 int64_t nativePosition = ut->chunkNativeLimit; in utext_current32()
221 int32_t originalOffset = ut->chunkOffset; in utext_current32()
222 if (ut->pFuncs->access(ut, nativePosition, true)) { in utext_current32()
223 trail = ut->chunkContents[ut->chunkOffset]; in utext_current32()
225 …UBool r = ut->pFuncs->access(ut, nativePosition, false); // reverse iteration flag loads precedin… in utext_current32()
227 ut->chunkOffset = originalOffset; in utext_current32()
245 // Fast path the common case. in utext_char32At()
246 …if (nativeIndex>=ut->chunkNativeStart && nativeIndex < ut->chunkNativeStart + ut->nativeIndexingLi… in utext_char32At()
247 ut->chunkOffset = (int32_t)(nativeIndex - ut->chunkNativeStart); in utext_char32At()
248 c = ut->chunkContents[ut->chunkOffset]; in utext_char32At()
256 if (nativeIndex>=ut->chunkNativeStart && ut->chunkOffset<ut->chunkLength) { in utext_char32At()
257 c = ut->chunkContents[ut->chunkOffset]; in utext_char32At()
272 if (ut->chunkOffset >= ut->chunkLength) { in utext_next32()
273 if (ut->pFuncs->access(ut, ut->chunkNativeLimit, true) == false) { in utext_next32()
278 c = ut->chunkContents[ut->chunkOffset++]; in utext_next32()
286 if (ut->chunkOffset >= ut->chunkLength) { in utext_next32()
287 if (ut->pFuncs->access(ut, ut->chunkNativeLimit, true) == false) { in utext_next32()
293 UChar32 trail = ut->chunkContents[ut->chunkOffset]; in utext_next32()
303 ut->chunkOffset++; // move iteration position over the trail surrogate. in utext_next32()
312 if (ut->chunkOffset <= 0) { in utext_previous32()
313 if (ut->pFuncs->access(ut, ut->chunkNativeStart, false) == false) { in utext_previous32()
317 ut->chunkOffset--; in utext_previous32()
318 c = ut->chunkContents[ut->chunkOffset]; in utext_previous32()
326 if (ut->chunkOffset <= 0) { in utext_previous32()
327 if (ut->pFuncs->access(ut, ut->chunkNativeStart, false) == false) { in utext_previous32()
334 UChar32 lead = ut->chunkContents[ut->chunkOffset-1]; in utext_previous32()
342 ut->chunkOffset--; // move iteration position over the lead surrogate. in utext_previous32()
352 if(index<ut->chunkNativeStart || index>=ut->chunkNativeLimit) { in utext_next32From()
354 if(!ut->pFuncs->access(ut, index, true)) { in utext_next32From()
358 } else if (index - ut->chunkNativeStart <= (int64_t)ut->nativeIndexingLimit) { in utext_next32From()
360 ut->chunkOffset = (int32_t)(index - ut->chunkNativeStart); in utext_next32From()
362 // Desired position is in chunk, with non-UTF16 indexing. in utext_next32From()
363 ut->chunkOffset = ut->pFuncs->mapNativeIndexToUTF16(ut, index); in utext_next32From()
366 c = ut->chunkContents[ut->chunkOffset++]; in utext_next32From()
389 // BUT, this test can fail with UTF-8 (or any other multibyte encoding), when the in utext_previous32From()
392 if(index<=ut->chunkNativeStart || index>ut->chunkNativeLimit) { in utext_previous32From()
394 if(!ut->pFuncs->access(ut, index, false)) { in utext_previous32From()
398 } else if(index - ut->chunkNativeStart <= (int64_t)ut->nativeIndexingLimit) { in utext_previous32From()
399 // Direct UTF-16 indexing. in utext_previous32From()
400 ut->chunkOffset = (int32_t)(index - ut->chunkNativeStart); in utext_previous32From()
402 ut->chunkOffset=ut->pFuncs->mapNativeIndexToUTF16(ut, index); in utext_previous32From()
403 if (ut->chunkOffset==0 && !ut->pFuncs->access(ut, index, false)) { in utext_previous32From()
412 ut->chunkOffset--; in utext_previous32From()
413 cPrev = ut->chunkContents[ut->chunkOffset]; in utext_previous32From()
430 return ut->pFuncs->extract(ut, start, limit, dest, destCapacity, status); in utext_extract()
438 a->magic != UTEXT_MAGIC || in utext_equals()
439 b->magic != UTEXT_MAGIC) { in utext_equals()
440 // Null or invalid arguments don't compare equal to anything. in utext_equals()
444 if (a->pFuncs != b->pFuncs) { in utext_equals()
449 if (a->context != b->context) { in utext_equals()
464 UBool b = (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_WRITABLE)) != 0; in utext_isWritable()
472 ut->providerProperties &= ~(I32_FLAG(UTEXT_PROVIDER_WRITABLE)); in utext_freeze()
479 UBool b = (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_HAS_META_DATA)) != 0; in utext_hasMetaData()
494 if ((ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_WRITABLE)) == 0) { in utext_replace()
498 …int32_t i = ut->pFuncs->replace(ut, nativeStart, nativeLimit, replacementText, replacementLength, … in utext_replace()
512 if ((ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_WRITABLE)) == 0) { in utext_copy()
516 ut->pFuncs->copy(ut, nativeStart, nativeLimit, destIndex, move, status); in utext_copy()
522 utext_clone(UText *dest, const UText *src, UBool deep, UBool readOnly, UErrorCode *status) { in utext_clone() argument
526 UText *result = src->pFuncs->clone(dest, src, deep, status); in utext_clone()
542 //------------------------------------------------------------------------------
546 //------------------------------------------------------------------------------
584 // We need to heap-allocate storage for the new UText in utext_setup()
587 spaceRequired = sizeof(ExtendedUText) + extraSpace - sizeof(std::max_align_t); in utext_setup()
595 ut->flags |= UTEXT_HEAP_ALLOCATED; in utext_setup()
597 ut->extraSize = extraSpace; in utext_setup()
598 ut->pExtra = &((ExtendedUText *)ut)->extension; in utext_setup()
604 if (ut->magic != UTEXT_MAGIC) { in utext_setup()
610 if ((ut->flags & UTEXT_OPEN) && ut->pFuncs->close != NULL) { in utext_setup()
611 ut->pFuncs->close(ut); in utext_setup()
613 ut->flags &= ~UTEXT_OPEN; in utext_setup()
617 if (extraSpace > ut->extraSize) { in utext_setup()
620 if (ut->flags & UTEXT_EXTRA_HEAP_ALLOCATED) { in utext_setup()
621 uprv_free(ut->pExtra); in utext_setup()
622 ut->extraSize = 0; in utext_setup()
624 ut->pExtra = uprv_malloc(extraSpace); in utext_setup()
625 if (ut->pExtra == NULL) { in utext_setup()
628 ut->extraSize = extraSpace; in utext_setup()
629 ut->flags |= UTEXT_EXTRA_HEAP_ALLOCATED; in utext_setup()
634 ut->flags |= UTEXT_OPEN; in utext_setup()
638 ut->context = NULL; in utext_setup()
639 ut->chunkContents = NULL; in utext_setup()
640 ut->p = NULL; in utext_setup()
641 ut->q = NULL; in utext_setup()
642 ut->r = NULL; in utext_setup()
643 ut->a = 0; in utext_setup()
644 ut->b = 0; in utext_setup()
645 ut->c = 0; in utext_setup()
646 ut->chunkOffset = 0; in utext_setup()
647 ut->chunkLength = 0; in utext_setup()
648 ut->chunkNativeStart = 0; in utext_setup()
649 ut->chunkNativeLimit = 0; in utext_setup()
650 ut->nativeIndexingLimit = 0; in utext_setup()
651 ut->providerProperties = 0; in utext_setup()
652 ut->privA = 0; in utext_setup()
653 ut->privB = 0; in utext_setup()
654 ut->privC = 0; in utext_setup()
655 ut->privP = NULL; in utext_setup()
656 if (ut->pExtra!=NULL && ut->extraSize>0) in utext_setup()
657 uprv_memset(ut->pExtra, 0, ut->extraSize); in utext_setup()
667 ut->magic != UTEXT_MAGIC || in utext_close()
668 (ut->flags & UTEXT_OPEN) == 0) in utext_close()
677 if (ut->pFuncs->close != NULL) { in utext_close()
678 ut->pFuncs->close(ut); in utext_close()
680 ut->flags &= ~UTEXT_OPEN; in utext_close()
684 if (ut->flags & UTEXT_EXTRA_HEAP_ALLOCATED) { in utext_close()
685 uprv_free(ut->pExtra); in utext_close()
686 ut->pExtra = NULL; in utext_close()
687 ut->flags &= ~UTEXT_EXTRA_HEAP_ALLOCATED; in utext_close()
688 ut->extraSize = 0; in utext_close()
694 ut->pFuncs = NULL; in utext_close()
696 if (ut->flags & UTEXT_HEAP_ALLOCATED) { in utext_close()
700 ut->magic = 0; in utext_close()
719 ut->chunkLength = 0; in invalidateChunk()
720 ut->chunkNativeLimit = 0; in invalidateChunk()
721 ut->chunkNativeStart = 0; in invalidateChunk()
722 ut->chunkOffset = 0; in invalidateChunk()
723 ut->nativeIndexingLimit = 0; in invalidateChunk()
756 if (dptr >= (char *)src->pExtra && dptr < ((char*)src->pExtra)+src->extraSize) { in adjustPointer()
759 *destPtr = ((char *)dest->pExtra) + (dptr - (char *)src->pExtra); in adjustPointer()
760 } else if (dptr>=sUText && dptr < sUText+src->sizeOfStruct) { in adjustPointer()
763 *destPtr = dUText + (dptr-sUText); in adjustPointer()
769 // Clone. This is a generic copy-the-utext-by-value clone function that can be
770 // used as-is with some utext types, and as a helper by other clones.
777 int32_t srcExtraSize = src->extraSize; in shallowTextClone()
793 void *destExtra = dest->pExtra; in shallowTextClone()
794 int32_t flags = dest->flags; in shallowTextClone()
801 int sizeToCopy = src->sizeOfStruct; in shallowTextClone()
802 if (sizeToCopy > dest->sizeOfStruct) { in shallowTextClone()
803 sizeToCopy = dest->sizeOfStruct; in shallowTextClone()
806 dest->pExtra = destExtra; in shallowTextClone()
807 dest->flags = flags; in shallowTextClone()
809 uprv_memcpy(dest->pExtra, src->pExtra, srcExtraSize); in shallowTextClone()
816 adjustPointer(dest, &dest->context, src); in shallowTextClone()
817 adjustPointer(dest, &dest->p, src); in shallowTextClone()
818 adjustPointer(dest, &dest->q, src); in shallowTextClone()
819 adjustPointer(dest, &dest->r, src); in shallowTextClone()
820 adjustPointer(dest, (const void **)&dest->chunkContents, src); in shallowTextClone()
822 // The newly shallow-cloned UText does _not_ own the underlying storage for the text. in shallowTextClone()
825 dest->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT); in shallowTextClone()
835 //------------------------------------------------------------------------------
837 // UText implementation for UTF-8 char * strings (read-only)
842 // context pointer to UTF-8 string
849 //------------------------------------------------------------------------------
856 // is a three-byte sequence (truncated four-byte sequence).
911 if (ut->b < 0) { in utf8TextLength()
914 const char *r = (const char *)ut->context + ut->c; in utf8TextLength()
918 if ((r - (const char *)ut->context) < 0x7fffffff) { in utf8TextLength()
919 ut->b = (int32_t)(r - (const char *)ut->context); in utf8TextLength()
923 ut->b = 0x7fffffff; in utf8TextLength()
925 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utf8TextLength()
927 return ut->b; in utf8TextLength()
943 const uint8_t *s8=(const uint8_t *)ut->context; in utf8TextAccess()
945 int32_t length = ut->b; // Length of original utf-8 in utf8TextAccess()
951 // Strings with 64 bit lengths not supported by this UTF-8 provider. in utf8TextAccess()
959 } else if (ix>=ut->c) { in utf8TextAccess()
964 while (ut->c<ix && s8[ut->c]!=0) { in utf8TextAccess()
965 ut->c++; in utf8TextAccess()
968 if (s8[ut->c] == 0) { in utf8TextAccess()
971 ix = ut->c; in utf8TextAccess()
972 ut->b = ut->c; in utf8TextAccess()
973 length = ut->c; in utf8TextAccess()
974 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utf8TextAccess()
983 if (ix==ut->chunkNativeLimit) { in utf8TextAccess()
989 ut->chunkOffset = ut->chunkLength; in utf8TextAccess()
994 UTF8Buf *altB = (UTF8Buf *)ut->q; in utf8TextAccess()
995 if (ix>=altB->bufNativeStart && ix<altB->bufNativeLimit) { in utf8TextAccess()
1006 u8b = (UTF8Buf *)ut->q; // the alternate buffer in utf8TextAccess()
1007 if (ix>=u8b->bufNativeStart && ix<u8b->bufNativeLimit) { in utf8TextAccess()
1012 // Requested index is end-of-string. in utf8TextAccess()
1015 if (ix == ut->chunkNativeLimit) { in utf8TextAccess()
1018 ut->chunkOffset = ut->chunkLength; in utf8TextAccess()
1021 if (ix == u8b->bufNativeLimit) { in utf8TextAccess()
1031 if (ix<ut->chunkNativeStart || ix>=ut->chunkNativeLimit) { in utf8TextAccess()
1037 u8b = (UTF8Buf *)ut->p; // the current buffer in utf8TextAccess()
1038 mapIndex = ix - u8b->toUCharsMapStart; in utf8TextAccess()
1040 ut->chunkOffset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx; in utf8TextAccess()
1051 if (ix==ut->chunkNativeStart) { in utf8TextAccess()
1057 ut->chunkOffset = 0; in utf8TextAccess()
1062 UTF8Buf *altB = (UTF8Buf *)ut->q; in utf8TextAccess()
1063 if (ix>altB->bufNativeStart && ix<=altB->bufNativeLimit) { in utf8TextAccess()
1074 u8b = (UTF8Buf *)ut->q; // the alternate buffer in utf8TextAccess()
1075 if (ix>u8b->bufNativeStart && ix<=u8b->bufNativeLimit) { in utf8TextAccess()
1079 // Requested index is start-of-string. in utf8TextAccess()
1083 if (u8b->bufNativeStart==0) { in utf8TextAccess()
1090 // set up a zero-length buffer. in utf8TextAccess()
1095 if (ix<=ut->chunkNativeStart || ix>ut->chunkNativeLimit) { in utf8TextAccess()
1102 u8b = (UTF8Buf *)ut->p; in utf8TextAccess()
1103 mapIndex = ix - u8b->toUCharsMapStart; in utf8TextAccess()
1104 ut->chunkOffset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx; in utf8TextAccess()
1105 if (ut->chunkOffset==0) { in utf8TextAccess()
1107 // a multi-byte UTF-8 char, and the requested index is to in utf8TextAccess()
1119 // The alternate buffer (ut->q) has the string data that was requested. in utf8TextAccess()
1123 u8b = (UTF8Buf *)ut->q; in utf8TextAccess()
1124 ut->q = ut->p; in utf8TextAccess()
1125 ut->p = u8b; in utf8TextAccess()
1126 ut->chunkContents = &u8b->buf[u8b->bufStartIdx]; in utf8TextAccess()
1127 ut->chunkLength = u8b->bufLimitIdx - u8b->bufStartIdx; in utf8TextAccess()
1128 ut->chunkNativeStart = u8b->bufNativeStart; in utf8TextAccess()
1129 ut->chunkNativeLimit = u8b->bufNativeLimit; in utf8TextAccess()
1130 ut->nativeIndexingLimit = u8b->bufNILimit; in utf8TextAccess()
1135 U_ASSERT(ix>=u8b->bufNativeStart); in utf8TextAccess()
1136 U_ASSERT(ix<=u8b->bufNativeLimit); in utf8TextAccess()
1137 mapIndex = ix - u8b->toUCharsMapStart; in utf8TextAccess()
1139 U_ASSERT(mapIndex<(int32_t)sizeof(u8b->mapToUChars)); in utf8TextAccess()
1140 ut->chunkOffset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx; in utf8TextAccess()
1148 // with iteration continuing in the out-of-bounds direction. in utf8TextAccess()
1155 u8b = (UTF8Buf *)ut->q; in utf8TextAccess()
1156 ut->q = ut->p; in utf8TextAccess()
1157 ut->p = u8b; in utf8TextAccess()
1158 ut->chunkContents = &u8b->buf[u8b->bufStartIdx]; in utf8TextAccess()
1159 ut->chunkLength = u8b->bufLimitIdx - u8b->bufStartIdx; in utf8TextAccess()
1160 ut->chunkNativeStart = u8b->bufNativeStart; in utf8TextAccess()
1161 ut->chunkNativeLimit = u8b->bufNativeLimit; in utf8TextAccess()
1162 ut->nativeIndexingLimit = u8b->bufNILimit; in utf8TextAccess()
1167 if (ix==u8b->bufNativeLimit) { in utf8TextAccess()
1168 ut->chunkOffset = ut->chunkLength; in utf8TextAccess()
1170 ut->chunkOffset = 0; in utf8TextAccess()
1171 U_ASSERT(ix == u8b->bufNativeStart); in utf8TextAccess()
1178 // to never be used, just set up a zero-length buffer at in utf8TextAccess()
1180 u8b = (UTF8Buf *)ut->q; in utf8TextAccess()
1181 u8b->bufNativeStart = ix; in utf8TextAccess()
1182 u8b->bufNativeLimit = ix; in utf8TextAccess()
1183 u8b->bufStartIdx = 0; in utf8TextAccess()
1184 u8b->bufLimitIdx = 0; in utf8TextAccess()
1185 u8b->bufNILimit = 0; in utf8TextAccess()
1186 u8b->toUCharsMapStart = ix; in utf8TextAccess()
1187 u8b->mapToNative[0] = 0; in utf8TextAccess()
1188 u8b->mapToUChars[0] = 0; in utf8TextAccess()
1201 UTF8Buf *u8b_swap = (UTF8Buf *)ut->q; in utf8TextAccess()
1202 ut->q = ut->p; in utf8TextAccess()
1203 ut->p = u8b_swap; in utf8TextAccess()
1205 int32_t strLen = ut->b; in utf8TextAccess()
1212 UChar *buf = u8b_swap->buf; in utf8TextAccess()
1213 uint8_t *mapToNative = u8b_swap->mapToNative; in utf8TextAccess()
1214 uint8_t *mapToUChars = u8b_swap->mapToUChars; in utf8TextAccess()
1227 mapToNative[destIx] = (uint8_t)(srcIx - ix); in utf8TextAccess()
1228 mapToUChars[srcIx-ix] = (uint8_t)destIx; in utf8TextAccess()
1235 u8b_swap->bufNILimit = destIx; in utf8TextAccess()
1243 srcIx--; in utf8TextAccess()
1249 mapToNative[dIx++] = (uint8_t)(cIx - ix); in utf8TextAccess()
1253 mapToUChars[cIx++ - ix] = (uint8_t)dIxSaved; in utf8TextAccess()
1262 // store Native <--> Chunk Map entries for the end of the buffer. in utf8TextAccess()
1264 mapToNative[destIx] = (uint8_t)(srcIx - ix); in utf8TextAccess()
1265 mapToUChars[srcIx - ix] = (uint8_t)destIx; in utf8TextAccess()
1268 u8b_swap->bufNativeStart = ix; in utf8TextAccess()
1269 u8b_swap->bufNativeLimit = srcIx; in utf8TextAccess()
1270 u8b_swap->bufStartIdx = 0; in utf8TextAccess()
1271 u8b_swap->bufLimitIdx = destIx; in utf8TextAccess()
1273 u8b_swap->bufNILimit = destIx; in utf8TextAccess()
1275 u8b_swap->toUCharsMapStart = u8b_swap->bufNativeStart; in utf8TextAccess()
1278 ut->chunkContents = buf; in utf8TextAccess()
1279 ut->chunkOffset = 0; in utf8TextAccess()
1280 ut->chunkLength = u8b_swap->bufLimitIdx; in utf8TextAccess()
1281 ut->chunkNativeStart = u8b_swap->bufNativeStart; in utf8TextAccess()
1282 ut->chunkNativeLimit = u8b_swap->bufNativeLimit; in utf8TextAccess()
1283 ut->nativeIndexingLimit = u8b_swap->bufNILimit; in utf8TextAccess()
1287 if (nulTerminated && srcIx>ut->c) { in utf8TextAccess()
1288 ut->c = srcIx; in utf8TextAccess()
1292 ut->b = srcIx; in utf8TextAccess()
1293 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utf8TextAccess()
1305 if (ix != ut->b) { in utf8TextAccess()
1308 // through this trail could be part of a valid UTF-8 sequence in utf8TextAccess()
1316 UTF8Buf *u8b_swap = (UTF8Buf *)ut->q; in utf8TextAccess()
1317 ut->q = ut->p; in utf8TextAccess()
1318 ut->p = u8b_swap; in utf8TextAccess()
1320 UChar *buf = u8b_swap->buf; in utf8TextAccess()
1321 uint8_t *mapToNative = u8b_swap->mapToNative; in utf8TextAccess()
1322 uint8_t *mapToUChars = u8b_swap->mapToUChars; in utf8TextAccess()
1323 int32_t toUCharsMapStart = ix - sizeof(UTF8Buf::mapToUChars) + 1; in utf8TextAccess()
1338 mapToNative[destIx] = (uint8_t)(srcIx - toUCharsMapStart); in utf8TextAccess()
1339 mapToUChars[srcIx - toUCharsMapStart] = (uint8_t)destIx; in utf8TextAccess()
1344 while (destIx>2 && (srcIx - toUCharsMapStart > 5) && (srcIx > 0)) { in utf8TextAccess()
1345 srcIx--; in utf8TextAccess()
1346 destIx--; in utf8TextAccess()
1348 // Get last byte of the UTF-8 character in utf8TextAccess()
1354 mapToUChars[srcIx - toUCharsMapStart] = (uint8_t)destIx; in utf8TextAccess()
1355 mapToNative[destIx] = (uint8_t)(srcIx - toUCharsMapStart); in utf8TextAccess()
1357 // General case, handle everything non-ASCII. in utf8TextAccess()
1359 int32_t sIx = srcIx; // ix of last byte of multi-byte u8 char in utf8TextAccess()
1363 // Leaves srcIx pointing at the first byte of the UTF-8 char. in utf8TextAccess()
1365 c=utf8_prevCharSafeBody(s8, 0, &srcIx, c, -3); in utf8TextAccess()
1366 // leaves srcIx at first byte of the multi-byte char. in utf8TextAccess()
1368 // Store the character in UTF-16 buffer. in utf8TextAccess()
1371 mapToNative[destIx] = (uint8_t)(srcIx - toUCharsMapStart); in utf8TextAccess()
1374 mapToNative[destIx] = (uint8_t)(srcIx - toUCharsMapStart); in utf8TextAccess()
1375 buf[--destIx] = U16_LEAD(c); in utf8TextAccess()
1376 mapToNative[destIx] = (uint8_t)(srcIx - toUCharsMapStart); in utf8TextAccess()
1381 mapToUChars[sIx-- - toUCharsMapStart] = (uint8_t)destIx; in utf8TextAccess()
1386 // We are processing a non-ascii, non-native-indexing char now; in utf8TextAccess()
1392 u8b_swap->bufNativeStart = srcIx; in utf8TextAccess()
1393 u8b_swap->bufNativeLimit = ix; in utf8TextAccess()
1394 u8b_swap->bufStartIdx = destIx; in utf8TextAccess()
1395 u8b_swap->bufLimitIdx = UTF8_TEXT_CHUNK_SIZE+2; in utf8TextAccess()
1396 u8b_swap->bufNILimit = bufNILimit - u8b_swap->bufStartIdx; in utf8TextAccess()
1397 u8b_swap->toUCharsMapStart = toUCharsMapStart; in utf8TextAccess()
1399 ut->chunkContents = &buf[u8b_swap->bufStartIdx]; in utf8TextAccess()
1400 ut->chunkLength = u8b_swap->bufLimitIdx - u8b_swap->bufStartIdx; in utf8TextAccess()
1401 ut->chunkOffset = ut->chunkLength; in utf8TextAccess()
1402 ut->chunkNativeStart = u8b_swap->bufNativeStart; in utf8TextAccess()
1403 ut->chunkNativeLimit = u8b_swap->bufNativeLimit; in utf8TextAccess()
1404 ut->nativeIndexingLimit = u8b_swap->bufNILimit; in utf8TextAccess()
1414 // Inserts a Replacement Char rather than failing on invalid UTF-8
1440 ch=utf8_nextCharSafeBody(pSrc, &index, srcLength, ch, -3); in utext_strFromUTF8()
1460 ch=utf8_nextCharSafeBody(pSrc, &index, srcLength, ch, -3); in utext_strFromUTF8()
1465 reqLength+=(int32_t)(pDest - dest); in utext_strFromUTF8()
1491 int32_t length = ut->b; in utf8TextExtract()
1504 const uint8_t *buf = (const uint8_t *)ut->context; in utf8TextExtract()
1506 if (start32 < ut->chunkNativeLimit) { in utf8TextExtract()
1511 start32--; in utf8TextExtract()
1515 if (limit32 < ut->chunkNativeLimit) { in utf8TextExtract()
1520 limit32--; in utf8TextExtract()
1527 (const char *)ut->context+start32, limit32-start32, in utf8TextExtract()
1536 // Map a chunk (UTF-16) offset to a native index.
1540 UTF8Buf *u8b = (UTF8Buf *)ut->p; in utf8TextMapOffsetToNative()
1541 U_ASSERT(ut->chunkOffset>ut->nativeIndexingLimit && ut->chunkOffset<=ut->chunkLength); in utf8TextMapOffsetToNative()
1542 …int32_t nativeOffset = u8b->mapToNative[ut->chunkOffset + u8b->bufStartIdx] + u8b->toUCharsMapStar… in utf8TextMapOffsetToNative()
1543 U_ASSERT(nativeOffset >= ut->chunkNativeStart && nativeOffset <= ut->chunkNativeLimit); in utf8TextMapOffsetToNative()
1554 UTF8Buf *u8b = (UTF8Buf *)ut->p; in utf8TextMapIndexToUTF16()
1555 U_ASSERT(index>=ut->chunkNativeStart+ut->nativeIndexingLimit); in utf8TextMapIndexToUTF16()
1556 U_ASSERT(index<=ut->chunkNativeLimit); in utf8TextMapIndexToUTF16()
1557 int32_t mapIndex = index - u8b->toUCharsMapStart; in utf8TextMapIndexToUTF16()
1559 int32_t offset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx; in utf8TextMapIndexToUTF16()
1560 U_ASSERT(offset>=0 && offset<=ut->chunkLength); in utf8TextMapIndexToUTF16()
1565 utf8TextClone(UText *dest, const UText *src, UBool deep, UErrorCode *status) in utf8TextClone() argument
1570 // For deep clones, make a copy of the string. in utf8TextClone()
1574 // That function is non-const in cases where the input was NUL terminated in utf8TextClone()
1579 if (deep && U_SUCCESS(*status)) { in utf8TextClone()
1585 uprv_memcpy(copyStr, src->context, len+1); in utf8TextClone()
1586 dest->context = copyStr; in utf8TextClone()
1587 dest->providerProperties |= I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT); in utf8TextClone()
1599 if (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT)) { in utf8TextClose()
1600 char *s = (char *)ut->context; in utf8TextClose()
1602 ut->context = NULL; in utf8TextClose()
1639 if(s==NULL || length<-1 || length>INT32_MAX) { in utext_openUTF8()
1649 ut->pFuncs = &utf8Funcs; in utext_openUTF8()
1650 ut->context = s; in utext_openUTF8()
1651 ut->b = (int32_t)length; in utext_openUTF8()
1652 ut->c = (int32_t)length; in utext_openUTF8()
1653 if (ut->c < 0) { in utext_openUTF8()
1654 ut->c = 0; in utext_openUTF8()
1655 ut->providerProperties |= I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utext_openUTF8()
1657 ut->p = ut->pExtra; in utext_openUTF8()
1658 ut->q = (char *)ut->pExtra + sizeof(UTF8Buf); in utext_openUTF8()
1670 //------------------------------------------------------------------------------
1678 //------------------------------------------------------------------------------
1698 repTextClone(UText *dest, const UText *src, UBool deep, UErrorCode *status) { in repTextClone() argument
1702 // For deep clones, make a copy of the Replaceable. in repTextClone()
1704 // A non-NULL pointer in UText.p is the signal to the close() function to delete in repTextClone()
1707 if (deep && U_SUCCESS(*status)) { in repTextClone()
1708 const Replaceable *replSrc = (const Replaceable *)src->context; in repTextClone()
1709 dest->context = replSrc->clone(); in repTextClone()
1710 dest->providerProperties |= I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT); in repTextClone()
1712 // with deep clone, the copy is writable, even when the source is not. in repTextClone()
1713 dest->providerProperties |= I32_FLAG(UTEXT_PROVIDER_WRITABLE); in repTextClone()
1724 if (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT)) { in repTextClose()
1725 Replaceable *rep = (Replaceable *)ut->context; in repTextClose()
1727 ut->context = NULL; in repTextClose()
1734 const Replaceable *replSrc = (const Replaceable *)ut->context; in repTextLength()
1735 int32_t len = replSrc->length(); in repTextLength()
1742 const Replaceable *rep=(const Replaceable *)ut->context; in repTextAccess()
1743 int32_t length=rep->length(); // Full length of the input text (bigger than a chunk) in repTextAccess()
1760 if (index32>=ut->chunkNativeStart && index32<ut->chunkNativeLimit) { in repTextAccess()
1762 ut->chunkOffset = (int32_t)(index - ut->chunkNativeStart); in repTextAccess()
1765 if (index32>=length && ut->chunkNativeLimit==length) { in repTextAccess()
1768 ut->chunkOffset = length - (int32_t)ut->chunkNativeStart; in repTextAccess()
1772 ut->chunkNativeLimit = index + REP_TEXT_CHUNK_SIZE - 1; in repTextAccess()
1774 // the requested index. The -1 gets us one code point before the in repTextAccess()
1777 if(ut->chunkNativeLimit > length) { in repTextAccess()
1778 ut->chunkNativeLimit = length; in repTextAccess()
1780 // unless buffer ran off end, start is index-1. in repTextAccess()
1781 ut->chunkNativeStart = ut->chunkNativeLimit - REP_TEXT_CHUNK_SIZE; in repTextAccess()
1782 if(ut->chunkNativeStart < 0) { in repTextAccess()
1783 ut->chunkNativeStart = 0; in repTextAccess()
1787 if (index32>ut->chunkNativeStart && index32<=ut->chunkNativeLimit) { in repTextAccess()
1789 ut->chunkOffset = index32 - (int32_t)ut->chunkNativeStart; in repTextAccess()
1792 if (index32==0 && ut->chunkNativeStart==0) { in repTextAccess()
1795 ut->chunkOffset = 0; in repTextAccess()
1805 ut->chunkNativeStart = index32 + 1 - REP_TEXT_CHUNK_SIZE; in repTextAccess()
1806 if (ut->chunkNativeStart < 0) { in repTextAccess()
1807 ut->chunkNativeStart = 0; in repTextAccess()
1810 ut->chunkNativeLimit = index32 + 1; in repTextAccess()
1811 if (ut->chunkNativeLimit > length) { in repTextAccess()
1812 ut->chunkNativeLimit = length; in repTextAccess()
1817 ReplExtra *ex = (ReplExtra *)ut->pExtra; in repTextAccess()
1819 UnicodeString buffer(ex->s, 0 /*buffer length*/, REP_TEXT_CHUNK_SIZE /*buffer capacity*/); in repTextAccess()
1820 rep->extractBetween((int32_t)ut->chunkNativeStart, (int32_t)ut->chunkNativeLimit, buffer); in repTextAccess()
1822 ut->chunkContents = ex->s; in repTextAccess()
1823 ut->chunkLength = (int32_t)(ut->chunkNativeLimit - ut->chunkNativeStart); in repTextAccess()
1824 ut->chunkOffset = (int32_t)(index32 - ut->chunkNativeStart); in repTextAccess()
1828 if (ut->chunkNativeLimit < length && in repTextAccess()
1829 U16_IS_LEAD(ex->s[ut->chunkLength-1])) { in repTextAccess()
1830 ut->chunkLength--; in repTextAccess()
1831 ut->chunkNativeLimit--; in repTextAccess()
1832 if (ut->chunkOffset > ut->chunkLength) { in repTextAccess()
1833 ut->chunkOffset = ut->chunkLength; in repTextAccess()
1839 if(ut->chunkNativeStart>0 && U16_IS_TRAIL(ex->s[0])) { in repTextAccess()
1840 ++(ut->chunkContents); in repTextAccess()
1841 ++(ut->chunkNativeStart); in repTextAccess()
1842 --(ut->chunkLength); in repTextAccess()
1843 --(ut->chunkOffset); in repTextAccess()
1847 U16_SET_CP_START(ut->chunkContents, 0, ut->chunkOffset); in repTextAccess()
1849 // Use fast indexing for get/setNativeIndex() in repTextAccess()
1850 ut->nativeIndexingLimit = ut->chunkLength; in repTextAccess()
1862 const Replaceable *rep=(const Replaceable *)ut->context; in repTextExtract()
1863 int32_t length=rep->length(); in repTextExtract()
1880 if (start32<length && U16_IS_TRAIL(rep->charAt(start32)) && in repTextExtract()
1881 U_IS_SUPPLEMENTARY(rep->char32At(start32))){ in repTextExtract()
1882 start32--; in repTextExtract()
1884 if (limit32<length && U16_IS_TRAIL(rep->charAt(limit32)) && in repTextExtract()
1885 U_IS_SUPPLEMENTARY(rep->char32At(limit32))){ in repTextExtract()
1886 limit32--; in repTextExtract()
1889 length=limit32-start32; in repTextExtract()
1894 rep->extractBetween(start32, limit32, buffer); in repTextExtract()
1905 Replaceable *rep=(Replaceable *)ut->context; in repTextReplace()
1915 oldLength=rep->length(); // will subtract from new length in repTextReplace()
1925 if (start32<oldLength && U16_IS_TRAIL(rep->charAt(start32)) && in repTextReplace()
1926 start32>0 && U16_IS_LEAD(rep->charAt(start32-1))) in repTextReplace()
1928 start32--; in repTextReplace()
1930 if (limit32<oldLength && U16_IS_LEAD(rep->charAt(limit32-1)) && in repTextReplace()
1931 U16_IS_TRAIL(rep->charAt(limit32))) in repTextReplace()
1937 UnicodeString replStr((UBool)(length<0), src, length); // read-only alias in repTextReplace()
1938 rep->handleReplaceBetween(start32, limit32, replStr); in repTextReplace()
1939 int32_t newLength = rep->length(); in repTextReplace()
1940 int32_t lengthDelta = newLength - oldLength; in repTextReplace()
1943 if (ut->chunkNativeLimit > start32) { in repTextReplace()
1964 Replaceable *rep=(Replaceable *)ut->context; in repTextCopy()
1965 int32_t length=rep->length(); in repTextCopy()
1984 int32_t segLength=limit32-start32; in repTextCopy()
1985 rep->copy(start32, limit32, destIndex32); in repTextCopy()
1990 rep->handleReplaceBetween(start32, limit32, UnicodeString()); in repTextCopy()
1993 rep->copy(start32, limit32, destIndex32); in repTextCopy()
2002 if (firstAffectedIndex < ut->chunkNativeLimit) { in repTextCopy()
2008 int32_t nativeIterIndex = destIndex32 + limit32 - start32; in repTextCopy()
2052 ut->providerProperties = I32_FLAG(UTEXT_PROVIDER_WRITABLE); in utext_openReplaceable()
2053 if(rep->hasMetaData()) { in utext_openReplaceable()
2054 ut->providerProperties |=I32_FLAG(UTEXT_PROVIDER_HAS_META_DATA); in utext_openReplaceable()
2057 ut->pFuncs = &repFuncs; in utext_openReplaceable()
2058 ut->context = rep; in utext_openReplaceable()
2071 //------------------------------------------------------------------------------
2082 //------------------------------------------------------------------------------
2088 unistrTextClone(UText *dest, const UText *src, UBool deep, UErrorCode *status) { in unistrTextClone() argument
2092 // For deep clones, make a copy of the UnicodeSring. in unistrTextClone()
2094 // A non-NULL pointer in UText.p is the signal to the close() function to delete in unistrTextClone()
2097 if (deep && U_SUCCESS(*status)) { in unistrTextClone()
2098 const UnicodeString *srcString = (const UnicodeString *)src->context; in unistrTextClone()
2099 dest->context = new UnicodeString(*srcString); in unistrTextClone()
2100 dest->providerProperties |= I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT); in unistrTextClone()
2102 // with deep clone, the copy is writable, even when the source is not. in unistrTextClone()
2103 dest->providerProperties |= I32_FLAG(UTEXT_PROVIDER_WRITABLE); in unistrTextClone()
2113 if (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT)) { in unistrTextClose()
2114 UnicodeString *str = (UnicodeString *)ut->context; in unistrTextClose()
2116 ut->context = NULL; in unistrTextClose()
2123 return ((const UnicodeString *)t->context)->length(); in unistrTextLength()
2129 int32_t length = ut->chunkLength; in unistrTextAccess()
2130 ut->chunkOffset = pinIndex(index, length); in unistrTextAccess()
2144 const UnicodeString *us=(const UnicodeString *)t->context; in unistrTextExtract()
2145 int32_t length=us->length(); in unistrTextExtract()
2158 int32_t start32 = start<length ? us->getChar32Start((int32_t)start) : length; in unistrTextExtract()
2159 int32_t limit32 = limit<length ? us->getChar32Start((int32_t)limit) : length; in unistrTextExtract()
2161 length=limit32-start32; in unistrTextExtract()
2167 us->extract(start32, trimmedLength, dest); in unistrTextExtract()
2168 t->chunkOffset = start32+trimmedLength; in unistrTextExtract()
2170 t->chunkOffset = start32; in unistrTextExtract()
2181 UnicodeString *us=(UnicodeString *)ut->context; in unistrTextReplace()
2194 oldLength=us->length(); in unistrTextReplace()
2198 start32 = us->getChar32Start(start32); in unistrTextReplace()
2201 limit32 = us->getChar32Start(limit32); in unistrTextReplace()
2205 us->replace(start32, limit32-start32, src, length); in unistrTextReplace()
2206 int32_t newLength = us->length(); in unistrTextReplace()
2209 ut->chunkContents = us->getBuffer(); in unistrTextReplace()
2210 ut->chunkLength = newLength; in unistrTextReplace()
2211 ut->chunkNativeLimit = newLength; in unistrTextReplace()
2212 ut->nativeIndexingLimit = newLength; in unistrTextReplace()
2215 int32_t lengthDelta = newLength - oldLength; in unistrTextReplace()
2216 ut->chunkOffset = limit32 + lengthDelta; in unistrTextReplace()
2227 UnicodeString *us=(UnicodeString *)ut->context; in unistrTextCopy()
2228 int32_t length=us->length(); in unistrTextCopy()
2244 int32_t segLength=limit32-start32; in unistrTextCopy()
2245 us->copy(start32, limit32, destIndex32); in unistrTextCopy()
2249 us->remove(start32, segLength); in unistrTextCopy()
2252 us->copy(start32, limit32, destIndex32); in unistrTextCopy()
2256 ut->chunkContents = us->getBuffer(); in unistrTextCopy()
2259 ut->chunkLength += limit32-start32; in unistrTextCopy()
2260 ut->chunkNativeLimit = ut->chunkLength; in unistrTextCopy()
2261 ut->nativeIndexingLimit = ut->chunkLength; in unistrTextCopy()
2265 ut->chunkOffset = destIndex32+limit32-start32; in unistrTextCopy()
2267 ut->chunkOffset = destIndex32; in unistrTextCopy()
2299 ut->providerProperties |= I32_FLAG(UTEXT_PROVIDER_WRITABLE); in utext_openUnicodeString()
2308 if (U_SUCCESS(*status) && s->isBogus()) { in utext_openConstUnicodeString()
2320 ut->pFuncs = &unistrFuncs; in utext_openConstUnicodeString()
2321 ut->context = s; in utext_openConstUnicodeString()
2322 ut->providerProperties = I32_FLAG(UTEXT_PROVIDER_STABLE_CHUNKS); in utext_openConstUnicodeString()
2323 ut->chunkContents = s->getBuffer(); in utext_openConstUnicodeString()
2324 ut->chunkLength = s->length(); in utext_openConstUnicodeString()
2325 ut->chunkNativeStart = 0; in utext_openConstUnicodeString()
2326 ut->chunkNativeLimit = ut->chunkLength; in utext_openConstUnicodeString()
2327 ut->nativeIndexingLimit = ut->chunkLength; in utext_openConstUnicodeString()
2332 //------------------------------------------------------------------------------
2338 // a length. -1 if not yet known.
2342 //------------------------------------------------------------------------------
2348 ucstrTextClone(UText *dest, const UText * src, UBool deep, UErrorCode * status) { in ucstrTextClone() argument
2352 // For deep clones, make a copy of the string. in ucstrTextClone()
2354 // A non-NULL pointer in UText.p is the signal to the close() function to delete in ucstrTextClone()
2357 if (deep && U_SUCCESS(*status)) { in ucstrTextClone()
2362 const UChar *srcStr = (const UChar *)src->context; in ucstrTextClone()
2372 dest->context = copyStr; in ucstrTextClone()
2373 dest->providerProperties |= I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT); in ucstrTextClone()
2385 if (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT)) { in ucstrTextClose()
2386 UChar *s = (UChar *)ut->context; in ucstrTextClose()
2388 ut->context = NULL; in ucstrTextClose()
2396 if (ut->a < 0) { in ucstrTextLength()
2400 const UChar *str = (const UChar *)ut->context; in ucstrTextLength()
2402 if (str[ut->chunkNativeLimit] == 0) { in ucstrTextLength()
2405 ut->chunkNativeLimit++; in ucstrTextLength()
2407 ut->a = ut->chunkNativeLimit; in ucstrTextLength()
2408 ut->chunkLength = (int32_t)ut->chunkNativeLimit; in ucstrTextLength()
2409 ut->nativeIndexingLimit = ut->chunkLength; in ucstrTextLength()
2410 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in ucstrTextLength()
2412 return ut->a; in ucstrTextLength()
2418 const UChar *str = (const UChar *)ut->context; in ucstrTextAccess()
2424 } else if (index < ut->chunkNativeLimit) { in ucstrTextAccess()
2428 } else if (ut->a >= 0) { in ucstrTextAccess()
2431 index = ut->a; in ucstrTextAccess()
2443 int32_t chunkLimit = (int32_t)ut->chunkNativeLimit; in ucstrTextAccess()
2448 ut->a = chunkLimit; in ucstrTextAccess()
2449 ut->chunkLength = chunkLimit; in ucstrTextAccess()
2450 ut->nativeIndexingLimit = chunkLimit; in ucstrTextAccess()
2457 ut->chunkNativeLimit = chunkLimit; in ucstrTextAccess()
2458 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in ucstrTextAccess()
2468 ut->a = chunkLimit; in ucstrTextAccess()
2469 ut->chunkLength = chunkLimit; in ucstrTextAccess()
2470 ut->nativeIndexingLimit = chunkLimit; in ucstrTextAccess()
2474 ut->chunkNativeLimit = chunkLimit; in ucstrTextAccess()
2475 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in ucstrTextAccess()
2481 if (U16_IS_LEAD(str[chunkLimit-1])) { in ucstrTextAccess()
2482 --chunkLimit; in ucstrTextAccess()
2484 // Null-terminated chunk with end still unknown. in ucstrTextAccess()
2487 // ut->a being < 0. in ucstrTextAccess()
2488 ut->chunkNativeLimit = chunkLimit; in ucstrTextAccess()
2489 ut->nativeIndexingLimit = chunkLimit; in ucstrTextAccess()
2490 ut->chunkLength = chunkLimit; in ucstrTextAccess()
2496 ut->chunkOffset = (int32_t)index; in ucstrTextAccess()
2499 UBool retVal = (forward && index<ut->chunkNativeLimit) || (!forward && index>0); in ucstrTextAccess()
2519 //const UChar *s=(const UChar *)ut->context; in ucstrTextExtract()
2526 // Pins 'start' to the length of the string, if it came in out-of-bounds. in ucstrTextExtract()
2529 const UChar *s=ut->chunkContents; in ucstrTextExtract()
2530 start32 = ut->chunkOffset; in ucstrTextExtract()
2532 int32_t strLength=(int32_t)ut->a; in ucstrTextExtract()
2541 // Just hit the end of a null-terminated string. in ucstrTextExtract()
2542 ut->a = si; // set string length for this UText in ucstrTextExtract()
2543 ut->chunkNativeLimit = si; in ucstrTextExtract()
2544 ut->chunkLength = si; in ucstrTextExtract()
2545 ut->nativeIndexingLimit = si; in ucstrTextExtract()
2558 di = limit32 - start32; in ucstrTextExtract()
2568 if (si>0 && U16_IS_LEAD(s[si-1]) && in ucstrTextExtract()
2579 if (si <= ut->chunkNativeLimit) { in ucstrTextExtract()
2580 ut->chunkOffset = si; in ucstrTextExtract()
2621 if (s==NULL || length < -1 || length>INT32_MAX) { in utext_openUChars()
2627 ut->pFuncs = &ucstrFuncs; in utext_openUChars()
2628 ut->context = s; in utext_openUChars()
2629 ut->providerProperties = I32_FLAG(UTEXT_PROVIDER_STABLE_CHUNKS); in utext_openUChars()
2630 if (length==-1) { in utext_openUChars()
2631 ut->providerProperties |= I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utext_openUChars()
2633 ut->a = length; in utext_openUChars()
2634 ut->chunkContents = s; in utext_openUChars()
2635 ut->chunkNativeStart = 0; in utext_openUChars()
2636 ut->chunkNativeLimit = length>=0? length : 0; in utext_openUChars()
2637 ut->chunkLength = (int32_t)ut->chunkNativeLimit; in utext_openUChars()
2638 ut->chunkOffset = 0; in utext_openUChars()
2639 ut->nativeIndexingLimit = ut->chunkLength; in utext_openUChars()
2645 //------------------------------------------------------------------------------
2659 //------------------------------------------------------------------------------
2668 CharacterIterator *ci = (CharacterIterator *)ut->r; in charIterTextClose()
2670 ut->r = NULL; in charIterTextClose()
2675 return (int32_t)ut->a; in charIterTextLength()
2680 CharacterIterator *ci = (CharacterIterator *)ut->context; in charIterTextAccess()
2685 } else if (clippedIndex>=ut->a) { in charIterTextAccess()
2686 clippedIndex=(int32_t)ut->a; in charIterTextAccess()
2691 neededIndex--; in charIterTextAccess()
2692 } else if (forward && neededIndex==ut->a && neededIndex>0) { in charIterTextAccess()
2694 neededIndex--; in charIterTextAccess()
2698 neededIndex -= neededIndex % CIBufSize; in charIterTextAccess()
2703 if (ut->chunkNativeStart == neededIndex) { in charIterTextAccess()
2706 } else if (ut->b == neededIndex) { in charIterTextAccess()
2708 buf = (UChar *)ut->p; in charIterTextAccess()
2709 } else if (ut->c == neededIndex) { in charIterTextAccess()
2711 buf = (UChar *)ut->q; in charIterTextAccess()
2716 buf = (UChar *)ut->p; in charIterTextAccess()
2717 if (ut->p == ut->chunkContents) { in charIterTextAccess()
2718 buf = (UChar *)ut->q; in charIterTextAccess()
2720 ci->setIndex(neededIndex); in charIterTextAccess()
2722 buf[i] = ci->nextPostInc(); in charIterTextAccess()
2723 if (i+neededIndex > ut->a) { in charIterTextAccess()
2732 ut->chunkContents = buf; in charIterTextAccess()
2733 ut->chunkLength = CIBufSize; in charIterTextAccess()
2734 ut->chunkNativeStart = neededIndex; in charIterTextAccess()
2735 ut->chunkNativeLimit = neededIndex + CIBufSize; in charIterTextAccess()
2736 if (ut->chunkNativeLimit > ut->a) { in charIterTextAccess()
2737 ut->chunkNativeLimit = ut->a; in charIterTextAccess()
2738 ut->chunkLength = (int32_t)(ut->chunkNativeLimit)-(int32_t)(ut->chunkNativeStart); in charIterTextAccess()
2740 ut->nativeIndexingLimit = ut->chunkLength; in charIterTextAccess()
2741 U_ASSERT(ut->chunkOffset>=0 && ut->chunkOffset<=CIBufSize); in charIterTextAccess()
2743 ut->chunkOffset = clippedIndex - (int32_t)ut->chunkNativeStart; in charIterTextAccess()
2744 UBool success = (forward? ut->chunkOffset<ut->chunkLength : ut->chunkOffset>0); in charIterTextAccess()
2749 charIterTextClone(UText *dest, const UText *src, UBool deep, UErrorCode * status) { in charIterTextClone() argument
2754 if (deep) { in charIterTextClone()
2759 CharacterIterator *srcCI =(CharacterIterator *)src->context; in charIterTextClone()
2760 srcCI = srcCI->clone(); in charIterTextClone()
2769 dest->r = srcCI; // flags that this UText owns the CharacterIterator in charIterTextClone()
2787 int32_t length = (int32_t)ut->a; in charIterTextExtract()
2794 CharacterIterator *ci = (CharacterIterator *)ut->context; in charIterTextExtract()
2795 ci->setIndex32(start32); // Moves ix to lead of surrogate pair, if needed. in charIterTextExtract()
2796 srci = ci->getIndex(); in charIterTextExtract()
2799 UChar32 c = ci->next32PostInc(); in charIterTextExtract()
2844 if (ci->startIndex() > 0) { in utext_openCharacterIterator()
2854 ut->pFuncs = &charIterFuncs; in utext_openCharacterIterator()
2855 ut->context = ci; in utext_openCharacterIterator()
2856 ut->providerProperties = 0; in utext_openCharacterIterator()
2857 ut->a = ci->endIndex(); // Length of text in utext_openCharacterIterator()
2858 ut->p = ut->pExtra; // First buffer in utext_openCharacterIterator()
2859 ut->b = -1; // Native index of first buffer contents in utext_openCharacterIterator()
2860 ut->q = (UChar*)ut->pExtra+CIBufSize; // Second buffer in utext_openCharacterIterator()
2861 ut->c = -1; // Native index of second buffer contents in utext_openCharacterIterator()
2869 ut->chunkContents = (UChar *)ut->p; in utext_openCharacterIterator()
2870 ut->chunkNativeStart = -1; in utext_openCharacterIterator()
2871 ut->chunkOffset = 1; in utext_openCharacterIterator()
2872 ut->chunkNativeLimit = 0; in utext_openCharacterIterator()
2873 ut->chunkLength = 0; in utext_openCharacterIterator()
2874 ut->nativeIndexingLimit = ut->chunkOffset; // enables native indexing in utext_openCharacterIterator()