Lines Matching refs:ut
37 utext_access(UText *ut, int64_t index, UBool forward) { in utext_access() argument
38 return ut->pFuncs->access(ut, index, forward); in utext_access()
44 utext_moveIndex32(UText *ut, int32_t delta) { in utext_moveIndex32() argument
48 if(ut->chunkOffset>=ut->chunkLength && !utext_access(ut, ut->chunkNativeLimit, TRUE)) { in utext_moveIndex32()
51 c = ut->chunkContents[ut->chunkOffset]; in utext_moveIndex32()
53 c = utext_next32(ut); in utext_moveIndex32()
58 ut->chunkOffset++; in utext_moveIndex32()
64 if(ut->chunkOffset<=0 && !utext_access(ut, ut->chunkNativeStart, FALSE)) { in utext_moveIndex32()
67 c = ut->chunkContents[ut->chunkOffset-1]; in utext_moveIndex32()
69 c = utext_previous32(ut); in utext_moveIndex32()
74 ut->chunkOffset--; in utext_moveIndex32()
84 utext_nativeLength(UText *ut) { in utext_nativeLength() argument
85 return ut->pFuncs->nativeLength(ut); in utext_nativeLength()
90 utext_isLengthExpensive(const UText *ut) { in utext_isLengthExpensive() argument
91 UBool r = (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE)) != 0; in utext_isLengthExpensive()
97 utext_getNativeIndex(const UText *ut) { in utext_getNativeIndex() argument
98 if(ut->chunkOffset <= ut->nativeIndexingLimit) { in utext_getNativeIndex()
99 return ut->chunkNativeStart+ut->chunkOffset; in utext_getNativeIndex()
101 return ut->pFuncs->mapOffsetToNative(ut); in utext_getNativeIndex()
107 utext_setNativeIndex(UText *ut, int64_t index) { in utext_setNativeIndex() argument
108 if(index<ut->chunkNativeStart || index>=ut->chunkNativeLimit) { in utext_setNativeIndex()
113 ut->pFuncs->access(ut, index, TRUE); in utext_setNativeIndex()
114 } else if((int32_t)(index - ut->chunkNativeStart) <= ut->nativeIndexingLimit) { in utext_setNativeIndex()
116 ut->chunkOffset=(int32_t)(index-ut->chunkNativeStart); in utext_setNativeIndex()
118 ut->chunkOffset=ut->pFuncs->mapNativeIndexToUTF16(ut, index); in utext_setNativeIndex()
122 if (ut->chunkOffset<ut->chunkLength) { in utext_setNativeIndex()
123 UChar c= ut->chunkContents[ut->chunkOffset]; in utext_setNativeIndex()
125 if (ut->chunkOffset==0) { in utext_setNativeIndex()
126 ut->pFuncs->access(ut, ut->chunkNativeStart, FALSE); in utext_setNativeIndex()
128 if (ut->chunkOffset>0) { in utext_setNativeIndex()
129 UChar lead = ut->chunkContents[ut->chunkOffset-1]; in utext_setNativeIndex()
131 ut->chunkOffset--; in utext_setNativeIndex()
141 utext_getPreviousNativeIndex(UText *ut) { in utext_getPreviousNativeIndex() argument
147 int32_t i = ut->chunkOffset - 1; in utext_getPreviousNativeIndex()
150 UChar c = ut->chunkContents[i]; in utext_getPreviousNativeIndex()
152 if (i <= ut->nativeIndexingLimit) { in utext_getPreviousNativeIndex()
153 result = ut->chunkNativeStart + i; in utext_getPreviousNativeIndex()
155 ut->chunkOffset = i; in utext_getPreviousNativeIndex()
156 result = ut->pFuncs->mapOffsetToNative(ut); in utext_getPreviousNativeIndex()
157 ut->chunkOffset++; in utext_getPreviousNativeIndex()
164 if (ut->chunkOffset==0 && ut->chunkNativeStart==0) { in utext_getPreviousNativeIndex()
171 utext_previous32(ut); in utext_getPreviousNativeIndex()
172 result = UTEXT_GETNATIVEINDEX(ut); in utext_getPreviousNativeIndex()
173 utext_next32(ut); in utext_getPreviousNativeIndex()
184 utext_current32(UText *ut) { in utext_current32() argument
186 if (ut->chunkOffset==ut->chunkLength) { in utext_current32()
188 if (ut->pFuncs->access(ut, ut->chunkNativeLimit, TRUE) == FALSE) { in utext_current32()
194 c = ut->chunkContents[ut->chunkOffset]; in utext_current32()
205 if ((ut->chunkOffset+1) < ut->chunkLength) { in utext_current32()
207 trail = ut->chunkContents[ut->chunkOffset+1]; in utext_current32()
216 int64_t nativePosition = ut->chunkNativeLimit; in utext_current32()
217 int32_t originalOffset = ut->chunkOffset; in utext_current32()
218 if (ut->pFuncs->access(ut, nativePosition, TRUE)) { in utext_current32()
219 trail = ut->chunkContents[ut->chunkOffset]; in utext_current32()
221 …UBool r = ut->pFuncs->access(ut, nativePosition, FALSE); // reverse iteration flag loads precedin… in utext_current32()
223 ut->chunkOffset = originalOffset; in utext_current32()
238 utext_char32At(UText *ut, int64_t nativeIndex) { in utext_char32At() argument
242 …if (nativeIndex>=ut->chunkNativeStart && nativeIndex < ut->chunkNativeStart + ut->nativeIndexingLi… in utext_char32At()
243 ut->chunkOffset = (int32_t)(nativeIndex - ut->chunkNativeStart); in utext_char32At()
244 c = ut->chunkContents[ut->chunkOffset]; in utext_char32At()
251 utext_setNativeIndex(ut, nativeIndex); in utext_char32At()
252 if (nativeIndex>=ut->chunkNativeStart && ut->chunkOffset<ut->chunkLength) { in utext_char32At()
253 c = ut->chunkContents[ut->chunkOffset]; in utext_char32At()
257 c = utext_current32(ut); in utext_char32At()
265 utext_next32(UText *ut) { in utext_next32() argument
268 if (ut->chunkOffset >= ut->chunkLength) { in utext_next32()
269 if (ut->pFuncs->access(ut, ut->chunkNativeLimit, TRUE) == FALSE) { in utext_next32()
274 c = ut->chunkContents[ut->chunkOffset++]; in utext_next32()
282 if (ut->chunkOffset >= ut->chunkLength) { in utext_next32()
283 if (ut->pFuncs->access(ut, ut->chunkNativeLimit, TRUE) == FALSE) { in utext_next32()
289 UChar32 trail = ut->chunkContents[ut->chunkOffset]; in utext_next32()
299 ut->chunkOffset++; // move iteration position over the trail surrogate. in utext_next32()
305 utext_previous32(UText *ut) { in utext_previous32() argument
308 if (ut->chunkOffset <= 0) { in utext_previous32()
309 if (ut->pFuncs->access(ut, ut->chunkNativeStart, FALSE) == FALSE) { in utext_previous32()
313 ut->chunkOffset--; in utext_previous32()
314 c = ut->chunkContents[ut->chunkOffset]; in utext_previous32()
322 if (ut->chunkOffset <= 0) { in utext_previous32()
323 if (ut->pFuncs->access(ut, ut->chunkNativeStart, FALSE) == FALSE) { in utext_previous32()
330 UChar32 lead = ut->chunkContents[ut->chunkOffset-1]; in utext_previous32()
338 ut->chunkOffset--; // move iteration position over the lead surrogate. in utext_previous32()
345 utext_next32From(UText *ut, int64_t index) { in utext_next32From() argument
348 if(index<ut->chunkNativeStart || index>=ut->chunkNativeLimit) { in utext_next32From()
350 if(!ut->pFuncs->access(ut, index, TRUE)) { in utext_next32From()
354 } else if (index - ut->chunkNativeStart <= (int64_t)ut->nativeIndexingLimit) { in utext_next32From()
356 ut->chunkOffset = (int32_t)(index - ut->chunkNativeStart); in utext_next32From()
359 ut->chunkOffset = ut->pFuncs->mapNativeIndexToUTF16(ut, index); in utext_next32From()
362 c = ut->chunkContents[ut->chunkOffset++]; in utext_next32From()
366 utext_setNativeIndex(ut, index); in utext_next32From()
367 c = utext_next32(ut); in utext_next32From()
374 utext_previous32From(UText *ut, int64_t index) { in utext_previous32From() argument
388 if(index<=ut->chunkNativeStart || index>ut->chunkNativeLimit) { in utext_previous32From()
390 if(!ut->pFuncs->access(ut, index, FALSE)) { in utext_previous32From()
394 } else if(index - ut->chunkNativeStart <= (int64_t)ut->nativeIndexingLimit) { in utext_previous32From()
396 ut->chunkOffset = (int32_t)(index - ut->chunkNativeStart); in utext_previous32From()
398 ut->chunkOffset=ut->pFuncs->mapNativeIndexToUTF16(ut, index); in utext_previous32From()
399 if (ut->chunkOffset==0 && !ut->pFuncs->access(ut, index, FALSE)) { in utext_previous32From()
408 ut->chunkOffset--; in utext_previous32From()
409 cPrev = ut->chunkContents[ut->chunkOffset]; in utext_previous32From()
414 utext_setNativeIndex(ut, index); in utext_previous32From()
415 cPrev = utext_previous32(ut); in utext_previous32From()
422 utext_extract(UText *ut, in utext_extract() argument
426 return ut->pFuncs->extract(ut, start, limit, dest, destCapacity, status); in utext_extract()
458 utext_isWritable(const UText *ut) in utext_isWritable() argument
460 UBool b = (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_WRITABLE)) != 0; in utext_isWritable()
466 utext_freeze(UText *ut) { in utext_freeze() argument
468 ut->providerProperties &= ~(I32_FLAG(UTEXT_PROVIDER_WRITABLE)); in utext_freeze()
473 utext_hasMetaData(const UText *ut) in utext_hasMetaData() argument
475 UBool b = (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_HAS_META_DATA)) != 0; in utext_hasMetaData()
482 utext_replace(UText *ut, in utext_replace() argument
490 if ((ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_WRITABLE)) == 0) { in utext_replace()
494 …int32_t i = ut->pFuncs->replace(ut, nativeStart, nativeLimit, replacementText, replacementLength, … in utext_replace()
499 utext_copy(UText *ut, in utext_copy() argument
508 if ((ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_WRITABLE)) == 0) { in utext_copy()
512 ut->pFuncs->copy(ut, nativeStart, nativeLimit, destIndex, move, status); in utext_copy()
567 UText ut; member
574 utext_setup(UText *ut, int32_t extraSpace, UErrorCode *status) { in utext_setup() argument
576 return ut; in utext_setup()
579 if (ut == NULL) { in utext_setup()
585 ut = (UText *)uprv_malloc(spaceRequired); in utext_setup()
586 if (ut == NULL) { in utext_setup()
590 *ut = emptyText; in utext_setup()
591 ut->flags |= UTEXT_HEAP_ALLOCATED; in utext_setup()
593 ut->extraSize = extraSpace; in utext_setup()
594 ut->pExtra = &((ExtendedUText *)ut)->extension; in utext_setup()
600 if (ut->magic != UTEXT_MAGIC) { in utext_setup()
602 return ut; in utext_setup()
606 if ((ut->flags & UTEXT_OPEN) && ut->pFuncs->close != NULL) { in utext_setup()
607 ut->pFuncs->close(ut); in utext_setup()
609 ut->flags &= ~UTEXT_OPEN; in utext_setup()
613 if (extraSpace > ut->extraSize) { in utext_setup()
616 if (ut->flags & UTEXT_EXTRA_HEAP_ALLOCATED) { in utext_setup()
617 uprv_free(ut->pExtra); in utext_setup()
618 ut->extraSize = 0; in utext_setup()
620 ut->pExtra = uprv_malloc(extraSpace); in utext_setup()
621 if (ut->pExtra == NULL) { in utext_setup()
624 ut->extraSize = extraSpace; in utext_setup()
625 ut->flags |= UTEXT_EXTRA_HEAP_ALLOCATED; in utext_setup()
630 ut->flags |= UTEXT_OPEN; in utext_setup()
634 ut->context = NULL; in utext_setup()
635 ut->chunkContents = NULL; in utext_setup()
636 ut->p = NULL; in utext_setup()
637 ut->q = NULL; in utext_setup()
638 ut->r = NULL; in utext_setup()
639 ut->a = 0; in utext_setup()
640 ut->b = 0; in utext_setup()
641 ut->c = 0; in utext_setup()
642 ut->chunkOffset = 0; in utext_setup()
643 ut->chunkLength = 0; in utext_setup()
644 ut->chunkNativeStart = 0; in utext_setup()
645 ut->chunkNativeLimit = 0; in utext_setup()
646 ut->nativeIndexingLimit = 0; in utext_setup()
647 ut->providerProperties = 0; in utext_setup()
648 ut->privA = 0; in utext_setup()
649 ut->privB = 0; in utext_setup()
650 ut->privC = 0; in utext_setup()
651 ut->privP = NULL; in utext_setup()
652 if (ut->pExtra!=NULL && ut->extraSize>0) in utext_setup()
653 uprv_memset(ut->pExtra, 0, ut->extraSize); in utext_setup()
656 return ut; in utext_setup()
661 utext_close(UText *ut) { in utext_close() argument
662 if (ut==NULL || in utext_close()
663 ut->magic != UTEXT_MAGIC || in utext_close()
664 (ut->flags & UTEXT_OPEN) == 0) in utext_close()
668 return ut; in utext_close()
673 if (ut->pFuncs->close != NULL) { in utext_close()
674 ut->pFuncs->close(ut); in utext_close()
676 ut->flags &= ~UTEXT_OPEN; in utext_close()
680 if (ut->flags & UTEXT_EXTRA_HEAP_ALLOCATED) { in utext_close()
681 uprv_free(ut->pExtra); in utext_close()
682 ut->pExtra = NULL; in utext_close()
683 ut->flags &= ~UTEXT_EXTRA_HEAP_ALLOCATED; in utext_close()
684 ut->extraSize = 0; in utext_close()
690 ut->pFuncs = NULL; in utext_close()
692 if (ut->flags & UTEXT_HEAP_ALLOCATED) { in utext_close()
696 ut->magic = 0; in utext_close()
697 uprv_free(ut); in utext_close()
698 ut = NULL; in utext_close()
700 return ut; in utext_close()
714 invalidateChunk(UText *ut) { in invalidateChunk() argument
715 ut->chunkLength = 0; in invalidateChunk()
716 ut->chunkNativeLimit = 0; in invalidateChunk()
717 ut->chunkNativeStart = 0; in invalidateChunk()
718 ut->chunkOffset = 0; in invalidateChunk()
719 ut->nativeIndexingLimit = 0; in invalidateChunk()
904 utf8TextLength(UText *ut) { in utf8TextLength() argument
905 if (ut->b < 0) { in utf8TextLength()
908 const char *r = (const char *)ut->context + ut->c; in utf8TextLength()
912 if ((r - (const char *)ut->context) < 0x7fffffff) { in utf8TextLength()
913 ut->b = (int32_t)(r - (const char *)ut->context); in utf8TextLength()
917 ut->b = 0x7fffffff; in utf8TextLength()
919 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utf8TextLength()
921 return ut->b; in utf8TextLength()
930 utf8TextAccess(UText *ut, int64_t index, UBool forward) { in utf8TextAccess() argument
937 const uint8_t *s8=(const uint8_t *)ut->context; in utf8TextAccess()
939 int32_t length = ut->b; // Length of original utf-8 in utf8TextAccess()
953 } else if (ix>=ut->c) { in utf8TextAccess()
958 while (ut->c<ix && s8[ut->c]!=0) { in utf8TextAccess()
959 ut->c++; in utf8TextAccess()
962 if (s8[ut->c] == 0) { in utf8TextAccess()
965 ix = ut->c; in utf8TextAccess()
966 ut->b = ut->c; in utf8TextAccess()
967 length = ut->c; in utf8TextAccess()
968 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utf8TextAccess()
977 if (ix==ut->chunkNativeLimit) { in utf8TextAccess()
983 ut->chunkOffset = ut->chunkLength; in utf8TextAccess()
988 UTF8Buf *altB = (UTF8Buf *)ut->q; in utf8TextAccess()
1000 u8b = (UTF8Buf *)ut->q; // the alternate buffer in utf8TextAccess()
1009 if (ix == ut->chunkNativeLimit) { in utf8TextAccess()
1012 ut->chunkOffset = ut->chunkLength; in utf8TextAccess()
1025 if (ix<ut->chunkNativeStart || ix>=ut->chunkNativeLimit) { in utf8TextAccess()
1031 u8b = (UTF8Buf *)ut->p; // the current buffer in utf8TextAccess()
1033 ut->chunkOffset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx; in utf8TextAccess()
1044 if (ix==ut->chunkNativeStart) { in utf8TextAccess()
1050 ut->chunkOffset = 0; in utf8TextAccess()
1055 UTF8Buf *altB = (UTF8Buf *)ut->q; in utf8TextAccess()
1067 u8b = (UTF8Buf *)ut->q; // the alternate buffer in utf8TextAccess()
1088 if (ix<=ut->chunkNativeStart || ix>ut->chunkNativeLimit) { in utf8TextAccess()
1095 u8b = (UTF8Buf *)ut->p; in utf8TextAccess()
1097 ut->chunkOffset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx; in utf8TextAccess()
1098 if (ut->chunkOffset==0) { in utf8TextAccess()
1116 u8b = (UTF8Buf *)ut->q; in utf8TextAccess()
1117 ut->q = ut->p; in utf8TextAccess()
1118 ut->p = u8b; in utf8TextAccess()
1119 ut->chunkContents = &u8b->buf[u8b->bufStartIdx]; in utf8TextAccess()
1120 ut->chunkLength = u8b->bufLimitIdx - u8b->bufStartIdx; in utf8TextAccess()
1121 ut->chunkNativeStart = u8b->bufNativeStart; in utf8TextAccess()
1122 ut->chunkNativeLimit = u8b->bufNativeLimit; in utf8TextAccess()
1123 ut->nativeIndexingLimit = u8b->bufNILimit; in utf8TextAccess()
1133 ut->chunkOffset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx; in utf8TextAccess()
1148 u8b = (UTF8Buf *)ut->q; in utf8TextAccess()
1149 ut->q = ut->p; in utf8TextAccess()
1150 ut->p = u8b; in utf8TextAccess()
1151 ut->chunkContents = &u8b->buf[u8b->bufStartIdx]; in utf8TextAccess()
1152 ut->chunkLength = u8b->bufLimitIdx - u8b->bufStartIdx; in utf8TextAccess()
1153 ut->chunkNativeStart = u8b->bufNativeStart; in utf8TextAccess()
1154 ut->chunkNativeLimit = u8b->bufNativeLimit; in utf8TextAccess()
1155 ut->nativeIndexingLimit = u8b->bufNILimit; in utf8TextAccess()
1161 ut->chunkOffset = ut->chunkLength; in utf8TextAccess()
1163 ut->chunkOffset = 0; in utf8TextAccess()
1173 u8b = (UTF8Buf *)ut->q; in utf8TextAccess()
1194 UTF8Buf *u8b = (UTF8Buf *)ut->q; in utf8TextAccess()
1195 ut->q = ut->p; in utf8TextAccess()
1196 ut->p = u8b; in utf8TextAccess()
1198 int32_t strLen = ut->b; in utf8TextAccess()
1271 ut->chunkContents = buf; in utf8TextAccess()
1272 ut->chunkOffset = 0; in utf8TextAccess()
1273 ut->chunkLength = u8b->bufLimitIdx; in utf8TextAccess()
1274 ut->chunkNativeStart = u8b->bufNativeStart; in utf8TextAccess()
1275 ut->chunkNativeLimit = u8b->bufNativeLimit; in utf8TextAccess()
1276 ut->nativeIndexingLimit = u8b->bufNILimit; in utf8TextAccess()
1280 if (nulTerminated && srcIx>ut->c) { in utf8TextAccess()
1281 ut->c = srcIx; in utf8TextAccess()
1285 ut->b = srcIx; in utf8TextAccess()
1286 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utf8TextAccess()
1298 if (ix != ut->b) { in utf8TextAccess()
1305 UTF8Buf *u8b = (UTF8Buf *)ut->q; in utf8TextAccess()
1306 ut->q = ut->p; in utf8TextAccess()
1307 ut->p = u8b; in utf8TextAccess()
1383 ut->chunkContents = &buf[u8b->bufStartIdx]; in utf8TextAccess()
1384 ut->chunkLength = u8b->bufLimitIdx - u8b->bufStartIdx; in utf8TextAccess()
1385 ut->chunkOffset = ut->chunkLength; in utf8TextAccess()
1386 ut->chunkNativeStart = u8b->bufNativeStart; in utf8TextAccess()
1387 ut->chunkNativeLimit = u8b->bufNativeLimit; in utf8TextAccess()
1388 ut->nativeIndexingLimit = u8b->bufNILimit; in utf8TextAccess()
1464 utf8TextExtract(UText *ut, in utf8TextExtract() argument
1475 int32_t length = ut->b; in utf8TextExtract()
1488 const uint8_t *buf = (const uint8_t *)ut->context; in utf8TextExtract()
1490 if (start32 < ut->chunkNativeLimit) { in utf8TextExtract()
1499 if (limit32 < ut->chunkNativeLimit) { in utf8TextExtract()
1511 (const char *)ut->context+start32, limit32-start32, in utf8TextExtract()
1513 utf8TextAccess(ut, limit32, TRUE); in utf8TextExtract()
1522 utf8TextMapOffsetToNative(const UText *ut) { in utf8TextMapOffsetToNative() argument
1524 UTF8Buf *u8b = (UTF8Buf *)ut->p; in utf8TextMapOffsetToNative()
1525 U_ASSERT(ut->chunkOffset>ut->nativeIndexingLimit && ut->chunkOffset<=ut->chunkLength); in utf8TextMapOffsetToNative()
1526 …int32_t nativeOffset = u8b->mapToNative[ut->chunkOffset + u8b->bufStartIdx] + u8b->toUCharsMapStar… in utf8TextMapOffsetToNative()
1527 U_ASSERT(nativeOffset >= ut->chunkNativeStart && nativeOffset <= ut->chunkNativeLimit); in utf8TextMapOffsetToNative()
1535 utf8TextMapIndexToUTF16(const UText *ut, int64_t index64) { in utf8TextMapIndexToUTF16() argument
1538 UTF8Buf *u8b = (UTF8Buf *)ut->p; in utf8TextMapIndexToUTF16()
1539 U_ASSERT(index>=ut->chunkNativeStart+ut->nativeIndexingLimit); in utf8TextMapIndexToUTF16()
1540 U_ASSERT(index<=ut->chunkNativeLimit); in utf8TextMapIndexToUTF16()
1543 U_ASSERT(offset>=0 && offset<=ut->chunkLength); in utf8TextMapIndexToUTF16()
1578 utf8TextClose(UText *ut) { in utf8TextClose() argument
1582 if (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT)) { in utf8TextClose()
1583 char *s = (char *)ut->context; in utf8TextClose()
1585 ut->context = NULL; in utf8TextClose()
1614 utext_openUTF8(UText *ut, const char *s, int64_t length, UErrorCode *status) { in utext_openUTF8() argument
1627 ut = utext_setup(ut, sizeof(UTF8Buf) * 2, status); in utext_openUTF8()
1629 return ut; in utext_openUTF8()
1632 ut->pFuncs = &utf8Funcs; in utext_openUTF8()
1633 ut->context = s; in utext_openUTF8()
1634 ut->b = (int32_t)length; in utext_openUTF8()
1635 ut->c = (int32_t)length; in utext_openUTF8()
1636 if (ut->c < 0) { in utext_openUTF8()
1637 ut->c = 0; in utext_openUTF8()
1638 ut->providerProperties |= I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utext_openUTF8()
1640 ut->p = ut->pExtra; in utext_openUTF8()
1641 ut->q = (char *)ut->pExtra + sizeof(UTF8Buf); in utext_openUTF8()
1642 return ut; in utext_openUTF8()
1703 repTextClose(UText *ut) { in repTextClose() argument
1707 if (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT)) { in repTextClose()
1708 Replaceable *rep = (Replaceable *)ut->context; in repTextClose()
1710 ut->context = NULL; in repTextClose()
1716 repTextLength(UText *ut) { in repTextLength() argument
1717 const Replaceable *replSrc = (const Replaceable *)ut->context; in repTextLength()
1724 repTextAccess(UText *ut, int64_t index, UBool forward) { in repTextAccess() argument
1725 const Replaceable *rep=(const Replaceable *)ut->context; in repTextAccess()
1743 if (index32>=ut->chunkNativeStart && index32<ut->chunkNativeLimit) { in repTextAccess()
1745 ut->chunkOffset = (int32_t)(index - ut->chunkNativeStart); in repTextAccess()
1748 if (index32>=length && ut->chunkNativeLimit==length) { in repTextAccess()
1751 ut->chunkOffset = length - (int32_t)ut->chunkNativeStart; in repTextAccess()
1755 ut->chunkNativeLimit = index + REP_TEXT_CHUNK_SIZE - 1; in repTextAccess()
1760 if(ut->chunkNativeLimit > length) { in repTextAccess()
1761 ut->chunkNativeLimit = length; in repTextAccess()
1764 ut->chunkNativeStart = ut->chunkNativeLimit - REP_TEXT_CHUNK_SIZE; in repTextAccess()
1765 if(ut->chunkNativeStart < 0) { in repTextAccess()
1766 ut->chunkNativeStart = 0; in repTextAccess()
1770 if (index32>ut->chunkNativeStart && index32<=ut->chunkNativeLimit) { in repTextAccess()
1772 ut->chunkOffset = index32 - (int32_t)ut->chunkNativeStart; in repTextAccess()
1775 if (index32==0 && ut->chunkNativeStart==0) { in repTextAccess()
1778 ut->chunkOffset = 0; in repTextAccess()
1788 ut->chunkNativeStart = index32 + 1 - REP_TEXT_CHUNK_SIZE; in repTextAccess()
1789 if (ut->chunkNativeStart < 0) { in repTextAccess()
1790 ut->chunkNativeStart = 0; in repTextAccess()
1793 ut->chunkNativeLimit = index32 + 1; in repTextAccess()
1794 if (ut->chunkNativeLimit > length) { in repTextAccess()
1795 ut->chunkNativeLimit = length; in repTextAccess()
1800 ReplExtra *ex = (ReplExtra *)ut->pExtra; in repTextAccess()
1803 rep->extractBetween((int32_t)ut->chunkNativeStart, (int32_t)ut->chunkNativeLimit, buffer); in repTextAccess()
1805 ut->chunkContents = ex->s; in repTextAccess()
1806 ut->chunkLength = (int32_t)(ut->chunkNativeLimit - ut->chunkNativeStart); in repTextAccess()
1807 ut->chunkOffset = (int32_t)(index32 - ut->chunkNativeStart); in repTextAccess()
1811 if (ut->chunkNativeLimit < length && in repTextAccess()
1812 U16_IS_LEAD(ex->s[ut->chunkLength-1])) { in repTextAccess()
1813 ut->chunkLength--; in repTextAccess()
1814 ut->chunkNativeLimit--; in repTextAccess()
1815 if (ut->chunkOffset > ut->chunkLength) { in repTextAccess()
1816 ut->chunkOffset = ut->chunkLength; in repTextAccess()
1822 if(ut->chunkNativeStart>0 && U16_IS_TRAIL(ex->s[0])) { in repTextAccess()
1823 ++(ut->chunkContents); in repTextAccess()
1824 ++(ut->chunkNativeStart); in repTextAccess()
1825 --(ut->chunkLength); in repTextAccess()
1826 --(ut->chunkOffset); in repTextAccess()
1830 U16_SET_CP_START(ut->chunkContents, 0, ut->chunkOffset); in repTextAccess()
1833 ut->nativeIndexingLimit = ut->chunkLength; in repTextAccess()
1841 repTextExtract(UText *ut, in repTextExtract() argument
1845 const Replaceable *rep=(const Replaceable *)ut->context; in repTextExtract()
1878 repTextAccess(ut, limit32, TRUE); in repTextExtract()
1884 repTextReplace(UText *ut, in repTextReplace() argument
1888 Replaceable *rep=(Replaceable *)ut->context; in repTextReplace()
1926 if (ut->chunkNativeLimit > start32) { in repTextReplace()
1929 invalidateChunk(ut); in repTextReplace()
1934 repTextAccess(ut, newIndexPos, TRUE); in repTextReplace()
1941 repTextCopy(UText *ut, in repTextCopy() argument
1947 Replaceable *rep=(Replaceable *)ut->context; in repTextCopy()
1985 if (firstAffectedIndex < ut->chunkNativeLimit) { in repTextCopy()
1987 invalidateChunk(ut); in repTextCopy()
1998 repTextAccess(ut, nativeIterIndex, TRUE); in repTextCopy()
2021 utext_openReplaceable(UText *ut, Replaceable *rep, UErrorCode *status) in utext_openReplaceable() argument
2030 ut = utext_setup(ut, sizeof(ReplExtra), status); in utext_openReplaceable()
2032 return ut; in utext_openReplaceable()
2035 ut->providerProperties = I32_FLAG(UTEXT_PROVIDER_WRITABLE); in utext_openReplaceable()
2037 ut->providerProperties |=I32_FLAG(UTEXT_PROVIDER_HAS_META_DATA); in utext_openReplaceable()
2040 ut->pFuncs = &repFuncs; in utext_openReplaceable()
2041 ut->context = rep; in utext_openReplaceable()
2042 return ut; in utext_openReplaceable()
2092 unistrTextClose(UText *ut) { in unistrTextClose() argument
2096 if (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT)) { in unistrTextClose()
2097 UnicodeString *str = (UnicodeString *)ut->context; in unistrTextClose()
2099 ut->context = NULL; in unistrTextClose()
2111 unistrTextAccess(UText *ut, int64_t index, UBool forward) { in unistrTextAccess() argument
2112 int32_t length = ut->chunkLength; in unistrTextAccess()
2113 ut->chunkOffset = pinIndex(index, length); in unistrTextAccess()
2160 unistrTextReplace(UText *ut, in unistrTextReplace() argument
2164 UnicodeString *us=(UnicodeString *)ut->context; in unistrTextReplace()
2192 ut->chunkContents = us->getBuffer(); in unistrTextReplace()
2193 ut->chunkLength = newLength; in unistrTextReplace()
2194 ut->chunkNativeLimit = newLength; in unistrTextReplace()
2195 ut->nativeIndexingLimit = newLength; in unistrTextReplace()
2199 ut->chunkOffset = limit32 + lengthDelta; in unistrTextReplace()
2205 unistrTextCopy(UText *ut, in unistrTextCopy() argument
2210 UnicodeString *us=(UnicodeString *)ut->context; in unistrTextCopy()
2239 ut->chunkContents = us->getBuffer(); in unistrTextCopy()
2242 ut->chunkLength += limit32-start32; in unistrTextCopy()
2243 ut->chunkNativeLimit = ut->chunkLength; in unistrTextCopy()
2244 ut->nativeIndexingLimit = ut->chunkLength; in unistrTextCopy()
2248 ut->chunkOffset = destIndex32+limit32-start32; in unistrTextCopy()
2250 ut->chunkOffset = destIndex32; in unistrTextCopy()
2279 utext_openUnicodeString(UText *ut, UnicodeString *s, UErrorCode *status) { in utext_openUnicodeString() argument
2280 ut = utext_openConstUnicodeString(ut, s, status); in utext_openUnicodeString()
2282 ut->providerProperties |= I32_FLAG(UTEXT_PROVIDER_WRITABLE); in utext_openUnicodeString()
2284 return ut; in utext_openUnicodeString()
2290 utext_openConstUnicodeString(UText *ut, const UnicodeString *s, UErrorCode *status) { in utext_openConstUnicodeString() argument
2294 utext_openUChars(ut, NULL, 0, status); in utext_openConstUnicodeString()
2296 return ut; in utext_openConstUnicodeString()
2298 ut = utext_setup(ut, 0, status); in utext_openConstUnicodeString()
2303 ut->pFuncs = &unistrFuncs; in utext_openConstUnicodeString()
2304 ut->context = s; in utext_openConstUnicodeString()
2305 ut->providerProperties = I32_FLAG(UTEXT_PROVIDER_STABLE_CHUNKS); in utext_openConstUnicodeString()
2306 ut->chunkContents = s->getBuffer(); in utext_openConstUnicodeString()
2307 ut->chunkLength = s->length(); in utext_openConstUnicodeString()
2308 ut->chunkNativeStart = 0; in utext_openConstUnicodeString()
2309 ut->chunkNativeLimit = ut->chunkLength; in utext_openConstUnicodeString()
2310 ut->nativeIndexingLimit = ut->chunkLength; in utext_openConstUnicodeString()
2312 return ut; in utext_openConstUnicodeString()
2364 ucstrTextClose(UText *ut) { in ucstrTextClose() argument
2368 if (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT)) { in ucstrTextClose()
2369 UChar *s = (UChar *)ut->context; in ucstrTextClose()
2371 ut->context = NULL; in ucstrTextClose()
2378 ucstrTextLength(UText *ut) { in ucstrTextLength() argument
2379 if (ut->a < 0) { in ucstrTextLength()
2383 const UChar *str = (const UChar *)ut->context; in ucstrTextLength()
2385 if (str[ut->chunkNativeLimit] == 0) { in ucstrTextLength()
2388 ut->chunkNativeLimit++; in ucstrTextLength()
2390 ut->a = ut->chunkNativeLimit; in ucstrTextLength()
2391 ut->chunkLength = (int32_t)ut->chunkNativeLimit; in ucstrTextLength()
2392 ut->nativeIndexingLimit = ut->chunkLength; in ucstrTextLength()
2393 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in ucstrTextLength()
2395 return ut->a; in ucstrTextLength()
2400 ucstrTextAccess(UText *ut, int64_t index, UBool forward) { in ucstrTextAccess() argument
2401 const UChar *str = (const UChar *)ut->context; in ucstrTextAccess()
2407 } else if (index < ut->chunkNativeLimit) { in ucstrTextAccess()
2411 } else if (ut->a >= 0) { in ucstrTextAccess()
2414 index = ut->a; in ucstrTextAccess()
2426 int32_t chunkLimit = (int32_t)ut->chunkNativeLimit; in ucstrTextAccess()
2431 ut->a = chunkLimit; in ucstrTextAccess()
2432 ut->chunkLength = chunkLimit; in ucstrTextAccess()
2433 ut->nativeIndexingLimit = chunkLimit; in ucstrTextAccess()
2440 ut->chunkNativeLimit = chunkLimit; in ucstrTextAccess()
2441 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in ucstrTextAccess()
2451 ut->a = chunkLimit; in ucstrTextAccess()
2452 ut->chunkLength = chunkLimit; in ucstrTextAccess()
2453 ut->nativeIndexingLimit = chunkLimit; in ucstrTextAccess()
2457 ut->chunkNativeLimit = chunkLimit; in ucstrTextAccess()
2458 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in ucstrTextAccess()
2471 ut->chunkNativeLimit = chunkLimit; in ucstrTextAccess()
2472 ut->nativeIndexingLimit = chunkLimit; in ucstrTextAccess()
2473 ut->chunkLength = chunkLimit; in ucstrTextAccess()
2479 ut->chunkOffset = (int32_t)index; in ucstrTextAccess()
2482 UBool retVal = (forward && index<ut->chunkNativeLimit) || (!forward && index>0); in ucstrTextAccess()
2489 ucstrTextExtract(UText *ut, in ucstrTextExtract() argument
2511 ucstrTextAccess(ut, start, TRUE); in ucstrTextExtract()
2512 const UChar *s=ut->chunkContents; in ucstrTextExtract()
2513 start32 = ut->chunkOffset; in ucstrTextExtract()
2515 int32_t strLength=(int32_t)ut->a; in ucstrTextExtract()
2525 ut->a = si; // set string length for this UText in ucstrTextExtract()
2526 ut->chunkNativeLimit = si; in ucstrTextExtract()
2527 ut->chunkLength = si; in ucstrTextExtract()
2528 ut->nativeIndexingLimit = si; in ucstrTextExtract()
2560 ut->chunkOffset = uprv_min(strLength, start32 + destCapacity); in ucstrTextExtract()
2591 utext_openUChars(UText *ut, const UChar *s, int64_t length, UErrorCode *status) { in utext_openUChars() argument
2602 ut = utext_setup(ut, 0, status); in utext_openUChars()
2604 ut->pFuncs = &ucstrFuncs; in utext_openUChars()
2605 ut->context = s; in utext_openUChars()
2606 ut->providerProperties = I32_FLAG(UTEXT_PROVIDER_STABLE_CHUNKS); in utext_openUChars()
2608 ut->providerProperties |= I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utext_openUChars()
2610 ut->a = length; in utext_openUChars()
2611 ut->chunkContents = s; in utext_openUChars()
2612 ut->chunkNativeStart = 0; in utext_openUChars()
2613 ut->chunkNativeLimit = length>=0? length : 0; in utext_openUChars()
2614 ut->chunkLength = (int32_t)ut->chunkNativeLimit; in utext_openUChars()
2615 ut->chunkOffset = 0; in utext_openUChars()
2616 ut->nativeIndexingLimit = ut->chunkLength; in utext_openUChars()
2618 return ut; in utext_openUChars()
2641 charIterTextClose(UText *ut) { in charIterTextClose() argument
2645 CharacterIterator *ci = (CharacterIterator *)ut->r; in charIterTextClose()
2647 ut->r = NULL; in charIterTextClose()
2651 charIterTextLength(UText *ut) { in charIterTextLength() argument
2652 return (int32_t)ut->a; in charIterTextLength()
2656 charIterTextAccess(UText *ut, int64_t index, UBool forward) { in charIterTextAccess() argument
2657 CharacterIterator *ci = (CharacterIterator *)ut->context; in charIterTextAccess()
2662 } else if (clippedIndex>=ut->a) { in charIterTextAccess()
2663 clippedIndex=(int32_t)ut->a; in charIterTextAccess()
2669 } else if (forward && neededIndex==ut->a && neededIndex>0) { in charIterTextAccess()
2680 if (ut->chunkNativeStart == neededIndex) { in charIterTextAccess()
2683 } else if (ut->b == neededIndex) { in charIterTextAccess()
2685 buf = (UChar *)ut->p; in charIterTextAccess()
2686 } else if (ut->c == neededIndex) { in charIterTextAccess()
2688 buf = (UChar *)ut->q; in charIterTextAccess()
2693 buf = (UChar *)ut->p; in charIterTextAccess()
2694 if (ut->p == ut->chunkContents) { in charIterTextAccess()
2695 buf = (UChar *)ut->q; in charIterTextAccess()
2700 if (i+neededIndex > ut->a) { in charIterTextAccess()
2709 ut->chunkContents = buf; in charIterTextAccess()
2710 ut->chunkLength = CIBufSize; in charIterTextAccess()
2711 ut->chunkNativeStart = neededIndex; in charIterTextAccess()
2712 ut->chunkNativeLimit = neededIndex + CIBufSize; in charIterTextAccess()
2713 if (ut->chunkNativeLimit > ut->a) { in charIterTextAccess()
2714 ut->chunkNativeLimit = ut->a; in charIterTextAccess()
2715 ut->chunkLength = (int32_t)(ut->chunkNativeLimit)-(int32_t)(ut->chunkNativeStart); in charIterTextAccess()
2717 ut->nativeIndexingLimit = ut->chunkLength; in charIterTextAccess()
2718 U_ASSERT(ut->chunkOffset>=0 && ut->chunkOffset<=CIBufSize); in charIterTextAccess()
2720 ut->chunkOffset = clippedIndex - (int32_t)ut->chunkNativeStart; in charIterTextAccess()
2721 UBool success = (forward? ut->chunkOffset<ut->chunkLength : ut->chunkOffset>0); in charIterTextAccess()
2752 charIterTextExtract(UText *ut, in charIterTextExtract() argument
2764 int32_t length = (int32_t)ut->a; in charIterTextExtract()
2771 CharacterIterator *ci = (CharacterIterator *)ut->context; in charIterTextExtract()
2789 charIterTextAccess(ut, copyLimit, TRUE); in charIterTextExtract()
2816 utext_openCharacterIterator(UText *ut, CharacterIterator *ci, UErrorCode *status) { in utext_openCharacterIterator() argument
2829 ut = utext_setup(ut, extraSpace, status); in utext_openCharacterIterator()
2831 ut->pFuncs = &charIterFuncs; in utext_openCharacterIterator()
2832 ut->context = ci; in utext_openCharacterIterator()
2833 ut->providerProperties = 0; in utext_openCharacterIterator()
2834 ut->a = ci->endIndex(); // Length of text in utext_openCharacterIterator()
2835 ut->p = ut->pExtra; // First buffer in utext_openCharacterIterator()
2836 ut->b = -1; // Native index of first buffer contents in utext_openCharacterIterator()
2837 ut->q = (UChar*)ut->pExtra+CIBufSize; // Second buffer in utext_openCharacterIterator()
2838 ut->c = -1; // Native index of second buffer contents in utext_openCharacterIterator()
2846 ut->chunkContents = (UChar *)ut->p; in utext_openCharacterIterator()
2847 ut->chunkNativeStart = -1; in utext_openCharacterIterator()
2848 ut->chunkOffset = 1; in utext_openCharacterIterator()
2849 ut->chunkNativeLimit = 0; in utext_openCharacterIterator()
2850 ut->chunkLength = 0; in utext_openCharacterIterator()
2851 ut->nativeIndexingLimit = ut->chunkOffset; // enables native indexing in utext_openCharacterIterator()
2853 return ut; in utext_openCharacterIterator()