• Home
  • Raw
  • Download

Lines Matching refs:ut

39 utext_access(UText *ut, int64_t index, UBool forward) {  in utext_access()  argument
40 return ut->pFuncs->access(ut, index, forward); in utext_access()
46 utext_moveIndex32(UText *ut, int32_t delta) { in utext_moveIndex32() argument
50 if(ut->chunkOffset>=ut->chunkLength && !utext_access(ut, ut->chunkNativeLimit, TRUE)) { in utext_moveIndex32()
53 c = ut->chunkContents[ut->chunkOffset]; in utext_moveIndex32()
55 c = utext_next32(ut); in utext_moveIndex32()
60 ut->chunkOffset++; in utext_moveIndex32()
66 if(ut->chunkOffset<=0 && !utext_access(ut, ut->chunkNativeStart, FALSE)) { in utext_moveIndex32()
69 c = ut->chunkContents[ut->chunkOffset-1]; in utext_moveIndex32()
71 c = utext_previous32(ut); in utext_moveIndex32()
76 ut->chunkOffset--; in utext_moveIndex32()
86 utext_nativeLength(UText *ut) { in utext_nativeLength() argument
87 return ut->pFuncs->nativeLength(ut); in utext_nativeLength()
92 utext_isLengthExpensive(const UText *ut) { in utext_isLengthExpensive() argument
93 UBool r = (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE)) != 0; in utext_isLengthExpensive()
99 utext_getNativeIndex(const UText *ut) { in utext_getNativeIndex() argument
100 if(ut->chunkOffset <= ut->nativeIndexingLimit) { in utext_getNativeIndex()
101 return ut->chunkNativeStart+ut->chunkOffset; in utext_getNativeIndex()
103 return ut->pFuncs->mapOffsetToNative(ut); in utext_getNativeIndex()
109 utext_setNativeIndex(UText *ut, int64_t index) { in utext_setNativeIndex() argument
110 if(index<ut->chunkNativeStart || index>=ut->chunkNativeLimit) { in utext_setNativeIndex()
115 ut->pFuncs->access(ut, index, TRUE); in utext_setNativeIndex()
116 } else if((int32_t)(index - ut->chunkNativeStart) <= ut->nativeIndexingLimit) { in utext_setNativeIndex()
118 ut->chunkOffset=(int32_t)(index-ut->chunkNativeStart); in utext_setNativeIndex()
120 ut->chunkOffset=ut->pFuncs->mapNativeIndexToUTF16(ut, index); in utext_setNativeIndex()
124 if (ut->chunkOffset<ut->chunkLength) { in utext_setNativeIndex()
125 UChar c= ut->chunkContents[ut->chunkOffset]; in utext_setNativeIndex()
127 if (ut->chunkOffset==0) { in utext_setNativeIndex()
128 ut->pFuncs->access(ut, ut->chunkNativeStart, FALSE); in utext_setNativeIndex()
130 if (ut->chunkOffset>0) { in utext_setNativeIndex()
131 UChar lead = ut->chunkContents[ut->chunkOffset-1]; in utext_setNativeIndex()
133 ut->chunkOffset--; in utext_setNativeIndex()
143 utext_getPreviousNativeIndex(UText *ut) { in utext_getPreviousNativeIndex() argument
149 int32_t i = ut->chunkOffset - 1; in utext_getPreviousNativeIndex()
152 UChar c = ut->chunkContents[i]; in utext_getPreviousNativeIndex()
154 if (i <= ut->nativeIndexingLimit) { in utext_getPreviousNativeIndex()
155 result = ut->chunkNativeStart + i; in utext_getPreviousNativeIndex()
157 ut->chunkOffset = i; in utext_getPreviousNativeIndex()
158 result = ut->pFuncs->mapOffsetToNative(ut); in utext_getPreviousNativeIndex()
159 ut->chunkOffset++; in utext_getPreviousNativeIndex()
166 if (ut->chunkOffset==0 && ut->chunkNativeStart==0) { in utext_getPreviousNativeIndex()
173 utext_previous32(ut); in utext_getPreviousNativeIndex()
174 result = UTEXT_GETNATIVEINDEX(ut); in utext_getPreviousNativeIndex()
175 utext_next32(ut); in utext_getPreviousNativeIndex()
186 utext_current32(UText *ut) { in utext_current32() argument
188 if (ut->chunkOffset==ut->chunkLength) { in utext_current32()
190 if (ut->pFuncs->access(ut, ut->chunkNativeLimit, TRUE) == FALSE) { in utext_current32()
196 c = ut->chunkContents[ut->chunkOffset]; in utext_current32()
207 if ((ut->chunkOffset+1) < ut->chunkLength) { in utext_current32()
209 trail = ut->chunkContents[ut->chunkOffset+1]; in utext_current32()
218 int64_t nativePosition = ut->chunkNativeLimit; in utext_current32()
219 int32_t originalOffset = ut->chunkOffset; in utext_current32()
220 if (ut->pFuncs->access(ut, nativePosition, TRUE)) { in utext_current32()
221 trail = ut->chunkContents[ut->chunkOffset]; in utext_current32()
223 …UBool r = ut->pFuncs->access(ut, nativePosition, FALSE); // reverse iteration flag loads precedin… in utext_current32()
225 ut->chunkOffset = originalOffset; in utext_current32()
240 utext_char32At(UText *ut, int64_t nativeIndex) { in utext_char32At() argument
244 …if (nativeIndex>=ut->chunkNativeStart && nativeIndex < ut->chunkNativeStart + ut->nativeIndexingLi… in utext_char32At()
245 ut->chunkOffset = (int32_t)(nativeIndex - ut->chunkNativeStart); in utext_char32At()
246 c = ut->chunkContents[ut->chunkOffset]; in utext_char32At()
253 utext_setNativeIndex(ut, nativeIndex); in utext_char32At()
254 if (nativeIndex>=ut->chunkNativeStart && ut->chunkOffset<ut->chunkLength) { in utext_char32At()
255 c = ut->chunkContents[ut->chunkOffset]; in utext_char32At()
259 c = utext_current32(ut); in utext_char32At()
267 utext_next32(UText *ut) { in utext_next32() argument
270 if (ut->chunkOffset >= ut->chunkLength) { in utext_next32()
271 if (ut->pFuncs->access(ut, ut->chunkNativeLimit, TRUE) == FALSE) { in utext_next32()
276 c = ut->chunkContents[ut->chunkOffset++]; in utext_next32()
284 if (ut->chunkOffset >= ut->chunkLength) { in utext_next32()
285 if (ut->pFuncs->access(ut, ut->chunkNativeLimit, TRUE) == FALSE) { in utext_next32()
291 UChar32 trail = ut->chunkContents[ut->chunkOffset]; in utext_next32()
301 ut->chunkOffset++; // move iteration position over the trail surrogate. in utext_next32()
307 utext_previous32(UText *ut) { in utext_previous32() argument
310 if (ut->chunkOffset <= 0) { in utext_previous32()
311 if (ut->pFuncs->access(ut, ut->chunkNativeStart, FALSE) == FALSE) { in utext_previous32()
315 ut->chunkOffset--; in utext_previous32()
316 c = ut->chunkContents[ut->chunkOffset]; in utext_previous32()
324 if (ut->chunkOffset <= 0) { in utext_previous32()
325 if (ut->pFuncs->access(ut, ut->chunkNativeStart, FALSE) == FALSE) { in utext_previous32()
332 UChar32 lead = ut->chunkContents[ut->chunkOffset-1]; in utext_previous32()
340 ut->chunkOffset--; // move iteration position over the lead surrogate. in utext_previous32()
347 utext_next32From(UText *ut, int64_t index) { in utext_next32From() argument
350 if(index<ut->chunkNativeStart || index>=ut->chunkNativeLimit) { in utext_next32From()
352 if(!ut->pFuncs->access(ut, index, TRUE)) { in utext_next32From()
356 } else if (index - ut->chunkNativeStart <= (int64_t)ut->nativeIndexingLimit) { in utext_next32From()
358 ut->chunkOffset = (int32_t)(index - ut->chunkNativeStart); in utext_next32From()
361 ut->chunkOffset = ut->pFuncs->mapNativeIndexToUTF16(ut, index); in utext_next32From()
364 c = ut->chunkContents[ut->chunkOffset++]; in utext_next32From()
368 utext_setNativeIndex(ut, index); in utext_next32From()
369 c = utext_next32(ut); in utext_next32From()
376 utext_previous32From(UText *ut, int64_t index) { in utext_previous32From() argument
390 if(index<=ut->chunkNativeStart || index>ut->chunkNativeLimit) { in utext_previous32From()
392 if(!ut->pFuncs->access(ut, index, FALSE)) { in utext_previous32From()
396 } else if(index - ut->chunkNativeStart <= (int64_t)ut->nativeIndexingLimit) { in utext_previous32From()
398 ut->chunkOffset = (int32_t)(index - ut->chunkNativeStart); in utext_previous32From()
400 ut->chunkOffset=ut->pFuncs->mapNativeIndexToUTF16(ut, index); in utext_previous32From()
401 if (ut->chunkOffset==0 && !ut->pFuncs->access(ut, index, FALSE)) { in utext_previous32From()
410 ut->chunkOffset--; in utext_previous32From()
411 cPrev = ut->chunkContents[ut->chunkOffset]; in utext_previous32From()
416 utext_setNativeIndex(ut, index); in utext_previous32From()
417 cPrev = utext_previous32(ut); in utext_previous32From()
424 utext_extract(UText *ut, in utext_extract() argument
428 return ut->pFuncs->extract(ut, start, limit, dest, destCapacity, status); in utext_extract()
460 utext_isWritable(const UText *ut) in utext_isWritable() argument
462 UBool b = (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_WRITABLE)) != 0; in utext_isWritable()
468 utext_freeze(UText *ut) { in utext_freeze() argument
470 ut->providerProperties &= ~(I32_FLAG(UTEXT_PROVIDER_WRITABLE)); in utext_freeze()
475 utext_hasMetaData(const UText *ut) in utext_hasMetaData() argument
477 UBool b = (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_HAS_META_DATA)) != 0; in utext_hasMetaData()
484 utext_replace(UText *ut, in utext_replace() argument
492 if ((ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_WRITABLE)) == 0) { in utext_replace()
496 …int32_t i = ut->pFuncs->replace(ut, nativeStart, nativeLimit, replacementText, replacementLength, … in utext_replace()
501 utext_copy(UText *ut, in utext_copy() argument
510 if ((ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_WRITABLE)) == 0) { in utext_copy()
514 ut->pFuncs->copy(ut, nativeStart, nativeLimit, destIndex, move, status); in utext_copy()
569 UText ut; member
576 utext_setup(UText *ut, int32_t extraSpace, UErrorCode *status) { in utext_setup() argument
578 return ut; in utext_setup()
581 if (ut == NULL) { in utext_setup()
587 ut = (UText *)uprv_malloc(spaceRequired); in utext_setup()
588 if (ut == NULL) { in utext_setup()
592 *ut = emptyText; in utext_setup()
593 ut->flags |= UTEXT_HEAP_ALLOCATED; in utext_setup()
595 ut->extraSize = extraSpace; in utext_setup()
596 ut->pExtra = &((ExtendedUText *)ut)->extension; in utext_setup()
602 if (ut->magic != UTEXT_MAGIC) { in utext_setup()
604 return ut; in utext_setup()
608 if ((ut->flags & UTEXT_OPEN) && ut->pFuncs->close != NULL) { in utext_setup()
609 ut->pFuncs->close(ut); in utext_setup()
611 ut->flags &= ~UTEXT_OPEN; in utext_setup()
615 if (extraSpace > ut->extraSize) { in utext_setup()
618 if (ut->flags & UTEXT_EXTRA_HEAP_ALLOCATED) { in utext_setup()
619 uprv_free(ut->pExtra); in utext_setup()
620 ut->extraSize = 0; in utext_setup()
622 ut->pExtra = uprv_malloc(extraSpace); in utext_setup()
623 if (ut->pExtra == NULL) { in utext_setup()
626 ut->extraSize = extraSpace; in utext_setup()
627 ut->flags |= UTEXT_EXTRA_HEAP_ALLOCATED; in utext_setup()
632 ut->flags |= UTEXT_OPEN; in utext_setup()
636 ut->context = NULL; in utext_setup()
637 ut->chunkContents = NULL; in utext_setup()
638 ut->p = NULL; in utext_setup()
639 ut->q = NULL; in utext_setup()
640 ut->r = NULL; in utext_setup()
641 ut->a = 0; in utext_setup()
642 ut->b = 0; in utext_setup()
643 ut->c = 0; in utext_setup()
644 ut->chunkOffset = 0; in utext_setup()
645 ut->chunkLength = 0; in utext_setup()
646 ut->chunkNativeStart = 0; in utext_setup()
647 ut->chunkNativeLimit = 0; in utext_setup()
648 ut->nativeIndexingLimit = 0; in utext_setup()
649 ut->providerProperties = 0; in utext_setup()
650 ut->privA = 0; in utext_setup()
651 ut->privB = 0; in utext_setup()
652 ut->privC = 0; in utext_setup()
653 ut->privP = NULL; in utext_setup()
654 if (ut->pExtra!=NULL && ut->extraSize>0) in utext_setup()
655 uprv_memset(ut->pExtra, 0, ut->extraSize); in utext_setup()
658 return ut; in utext_setup()
663 utext_close(UText *ut) { in utext_close() argument
664 if (ut==NULL || in utext_close()
665 ut->magic != UTEXT_MAGIC || in utext_close()
666 (ut->flags & UTEXT_OPEN) == 0) in utext_close()
670 return ut; in utext_close()
675 if (ut->pFuncs->close != NULL) { in utext_close()
676 ut->pFuncs->close(ut); in utext_close()
678 ut->flags &= ~UTEXT_OPEN; in utext_close()
682 if (ut->flags & UTEXT_EXTRA_HEAP_ALLOCATED) { in utext_close()
683 uprv_free(ut->pExtra); in utext_close()
684 ut->pExtra = NULL; in utext_close()
685 ut->flags &= ~UTEXT_EXTRA_HEAP_ALLOCATED; in utext_close()
686 ut->extraSize = 0; in utext_close()
692 ut->pFuncs = NULL; in utext_close()
694 if (ut->flags & UTEXT_HEAP_ALLOCATED) { in utext_close()
698 ut->magic = 0; in utext_close()
699 uprv_free(ut); in utext_close()
700 ut = NULL; in utext_close()
702 return ut; in utext_close()
716 invalidateChunk(UText *ut) { in invalidateChunk() argument
717 ut->chunkLength = 0; in invalidateChunk()
718 ut->chunkNativeLimit = 0; in invalidateChunk()
719 ut->chunkNativeStart = 0; in invalidateChunk()
720 ut->chunkOffset = 0; in invalidateChunk()
721 ut->nativeIndexingLimit = 0; in invalidateChunk()
908 utf8TextLength(UText *ut) { in utf8TextLength() argument
909 if (ut->b < 0) { in utf8TextLength()
912 const char *r = (const char *)ut->context + ut->c; in utf8TextLength()
916 if ((r - (const char *)ut->context) < 0x7fffffff) { in utf8TextLength()
917 ut->b = (int32_t)(r - (const char *)ut->context); in utf8TextLength()
921 ut->b = 0x7fffffff; in utf8TextLength()
923 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utf8TextLength()
925 return ut->b; in utf8TextLength()
934 utf8TextAccess(UText *ut, int64_t index, UBool forward) { in utf8TextAccess() argument
941 const uint8_t *s8=(const uint8_t *)ut->context; in utf8TextAccess()
943 int32_t length = ut->b; // Length of original utf-8 in utf8TextAccess()
957 } else if (ix>=ut->c) { in utf8TextAccess()
962 while (ut->c<ix && s8[ut->c]!=0) { in utf8TextAccess()
963 ut->c++; in utf8TextAccess()
966 if (s8[ut->c] == 0) { in utf8TextAccess()
969 ix = ut->c; in utf8TextAccess()
970 ut->b = ut->c; in utf8TextAccess()
971 length = ut->c; in utf8TextAccess()
972 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utf8TextAccess()
981 if (ix==ut->chunkNativeLimit) { in utf8TextAccess()
987 ut->chunkOffset = ut->chunkLength; in utf8TextAccess()
992 UTF8Buf *altB = (UTF8Buf *)ut->q; in utf8TextAccess()
1004 u8b = (UTF8Buf *)ut->q; // the alternate buffer in utf8TextAccess()
1013 if (ix == ut->chunkNativeLimit) { in utf8TextAccess()
1016 ut->chunkOffset = ut->chunkLength; in utf8TextAccess()
1029 if (ix<ut->chunkNativeStart || ix>=ut->chunkNativeLimit) { in utf8TextAccess()
1035 u8b = (UTF8Buf *)ut->p; // the current buffer in utf8TextAccess()
1038 ut->chunkOffset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx; in utf8TextAccess()
1049 if (ix==ut->chunkNativeStart) { in utf8TextAccess()
1055 ut->chunkOffset = 0; in utf8TextAccess()
1060 UTF8Buf *altB = (UTF8Buf *)ut->q; in utf8TextAccess()
1072 u8b = (UTF8Buf *)ut->q; // the alternate buffer in utf8TextAccess()
1093 if (ix<=ut->chunkNativeStart || ix>ut->chunkNativeLimit) { in utf8TextAccess()
1100 u8b = (UTF8Buf *)ut->p; in utf8TextAccess()
1102 ut->chunkOffset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx; in utf8TextAccess()
1103 if (ut->chunkOffset==0) { in utf8TextAccess()
1121 u8b = (UTF8Buf *)ut->q; in utf8TextAccess()
1122 ut->q = ut->p; in utf8TextAccess()
1123 ut->p = u8b; in utf8TextAccess()
1124 ut->chunkContents = &u8b->buf[u8b->bufStartIdx]; in utf8TextAccess()
1125 ut->chunkLength = u8b->bufLimitIdx - u8b->bufStartIdx; in utf8TextAccess()
1126 ut->chunkNativeStart = u8b->bufNativeStart; in utf8TextAccess()
1127 ut->chunkNativeLimit = u8b->bufNativeLimit; in utf8TextAccess()
1128 ut->nativeIndexingLimit = u8b->bufNILimit; in utf8TextAccess()
1138 ut->chunkOffset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx; in utf8TextAccess()
1153 u8b = (UTF8Buf *)ut->q; in utf8TextAccess()
1154 ut->q = ut->p; in utf8TextAccess()
1155 ut->p = u8b; in utf8TextAccess()
1156 ut->chunkContents = &u8b->buf[u8b->bufStartIdx]; in utf8TextAccess()
1157 ut->chunkLength = u8b->bufLimitIdx - u8b->bufStartIdx; in utf8TextAccess()
1158 ut->chunkNativeStart = u8b->bufNativeStart; in utf8TextAccess()
1159 ut->chunkNativeLimit = u8b->bufNativeLimit; in utf8TextAccess()
1160 ut->nativeIndexingLimit = u8b->bufNILimit; in utf8TextAccess()
1166 ut->chunkOffset = ut->chunkLength; in utf8TextAccess()
1168 ut->chunkOffset = 0; in utf8TextAccess()
1178 u8b = (UTF8Buf *)ut->q; in utf8TextAccess()
1199 UTF8Buf *u8b_swap = (UTF8Buf *)ut->q; in utf8TextAccess()
1200 ut->q = ut->p; in utf8TextAccess()
1201 ut->p = u8b_swap; in utf8TextAccess()
1203 int32_t strLen = ut->b; in utf8TextAccess()
1276 ut->chunkContents = buf; in utf8TextAccess()
1277 ut->chunkOffset = 0; in utf8TextAccess()
1278 ut->chunkLength = u8b_swap->bufLimitIdx; in utf8TextAccess()
1279 ut->chunkNativeStart = u8b_swap->bufNativeStart; in utf8TextAccess()
1280 ut->chunkNativeLimit = u8b_swap->bufNativeLimit; in utf8TextAccess()
1281 ut->nativeIndexingLimit = u8b_swap->bufNILimit; in utf8TextAccess()
1285 if (nulTerminated && srcIx>ut->c) { in utf8TextAccess()
1286 ut->c = srcIx; in utf8TextAccess()
1290 ut->b = srcIx; in utf8TextAccess()
1291 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utf8TextAccess()
1303 if (ix != ut->b) { in utf8TextAccess()
1314 UTF8Buf *u8b_swap = (UTF8Buf *)ut->q; in utf8TextAccess()
1315 ut->q = ut->p; in utf8TextAccess()
1316 ut->p = u8b_swap; in utf8TextAccess()
1397 ut->chunkContents = &buf[u8b_swap->bufStartIdx]; in utf8TextAccess()
1398 ut->chunkLength = u8b_swap->bufLimitIdx - u8b_swap->bufStartIdx; in utf8TextAccess()
1399 ut->chunkOffset = ut->chunkLength; in utf8TextAccess()
1400 ut->chunkNativeStart = u8b_swap->bufNativeStart; in utf8TextAccess()
1401 ut->chunkNativeLimit = u8b_swap->bufNativeLimit; in utf8TextAccess()
1402 ut->nativeIndexingLimit = u8b_swap->bufNILimit; in utf8TextAccess()
1478 utf8TextExtract(UText *ut, in utf8TextExtract() argument
1489 int32_t length = ut->b; in utf8TextExtract()
1502 const uint8_t *buf = (const uint8_t *)ut->context; in utf8TextExtract()
1504 if (start32 < ut->chunkNativeLimit) { in utf8TextExtract()
1513 if (limit32 < ut->chunkNativeLimit) { in utf8TextExtract()
1525 (const char *)ut->context+start32, limit32-start32, in utf8TextExtract()
1527 utf8TextAccess(ut, limit32, TRUE); in utf8TextExtract()
1536 utf8TextMapOffsetToNative(const UText *ut) { in utf8TextMapOffsetToNative() argument
1538 UTF8Buf *u8b = (UTF8Buf *)ut->p; in utf8TextMapOffsetToNative()
1539 U_ASSERT(ut->chunkOffset>ut->nativeIndexingLimit && ut->chunkOffset<=ut->chunkLength); in utf8TextMapOffsetToNative()
1540 …int32_t nativeOffset = u8b->mapToNative[ut->chunkOffset + u8b->bufStartIdx] + u8b->toUCharsMapStar… in utf8TextMapOffsetToNative()
1541 U_ASSERT(nativeOffset >= ut->chunkNativeStart && nativeOffset <= ut->chunkNativeLimit); in utf8TextMapOffsetToNative()
1549 utf8TextMapIndexToUTF16(const UText *ut, int64_t index64) { in utf8TextMapIndexToUTF16() argument
1552 UTF8Buf *u8b = (UTF8Buf *)ut->p; in utf8TextMapIndexToUTF16()
1553 U_ASSERT(index>=ut->chunkNativeStart+ut->nativeIndexingLimit); in utf8TextMapIndexToUTF16()
1554 U_ASSERT(index<=ut->chunkNativeLimit); in utf8TextMapIndexToUTF16()
1558 U_ASSERT(offset>=0 && offset<=ut->chunkLength); in utf8TextMapIndexToUTF16()
1593 utf8TextClose(UText *ut) { in utf8TextClose() argument
1597 if (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT)) { in utf8TextClose()
1598 char *s = (char *)ut->context; in utf8TextClose()
1600 ut->context = NULL; in utf8TextClose()
1629 utext_openUTF8(UText *ut, const char *s, int64_t length, UErrorCode *status) { in utext_openUTF8() argument
1642 ut = utext_setup(ut, sizeof(UTF8Buf) * 2, status); in utext_openUTF8()
1644 return ut; in utext_openUTF8()
1647 ut->pFuncs = &utf8Funcs; in utext_openUTF8()
1648 ut->context = s; in utext_openUTF8()
1649 ut->b = (int32_t)length; in utext_openUTF8()
1650 ut->c = (int32_t)length; in utext_openUTF8()
1651 if (ut->c < 0) { in utext_openUTF8()
1652 ut->c = 0; in utext_openUTF8()
1653 ut->providerProperties |= I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utext_openUTF8()
1655 ut->p = ut->pExtra; in utext_openUTF8()
1656 ut->q = (char *)ut->pExtra + sizeof(UTF8Buf); in utext_openUTF8()
1657 return ut; in utext_openUTF8()
1718 repTextClose(UText *ut) { in repTextClose() argument
1722 if (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT)) { in repTextClose()
1723 Replaceable *rep = (Replaceable *)ut->context; in repTextClose()
1725 ut->context = NULL; in repTextClose()
1731 repTextLength(UText *ut) { in repTextLength() argument
1732 const Replaceable *replSrc = (const Replaceable *)ut->context; in repTextLength()
1739 repTextAccess(UText *ut, int64_t index, UBool forward) { in repTextAccess() argument
1740 const Replaceable *rep=(const Replaceable *)ut->context; in repTextAccess()
1758 if (index32>=ut->chunkNativeStart && index32<ut->chunkNativeLimit) { in repTextAccess()
1760 ut->chunkOffset = (int32_t)(index - ut->chunkNativeStart); in repTextAccess()
1763 if (index32>=length && ut->chunkNativeLimit==length) { in repTextAccess()
1766 ut->chunkOffset = length - (int32_t)ut->chunkNativeStart; in repTextAccess()
1770 ut->chunkNativeLimit = index + REP_TEXT_CHUNK_SIZE - 1; in repTextAccess()
1775 if(ut->chunkNativeLimit > length) { in repTextAccess()
1776 ut->chunkNativeLimit = length; in repTextAccess()
1779 ut->chunkNativeStart = ut->chunkNativeLimit - REP_TEXT_CHUNK_SIZE; in repTextAccess()
1780 if(ut->chunkNativeStart < 0) { in repTextAccess()
1781 ut->chunkNativeStart = 0; in repTextAccess()
1785 if (index32>ut->chunkNativeStart && index32<=ut->chunkNativeLimit) { in repTextAccess()
1787 ut->chunkOffset = index32 - (int32_t)ut->chunkNativeStart; in repTextAccess()
1790 if (index32==0 && ut->chunkNativeStart==0) { in repTextAccess()
1793 ut->chunkOffset = 0; in repTextAccess()
1803 ut->chunkNativeStart = index32 + 1 - REP_TEXT_CHUNK_SIZE; in repTextAccess()
1804 if (ut->chunkNativeStart < 0) { in repTextAccess()
1805 ut->chunkNativeStart = 0; in repTextAccess()
1808 ut->chunkNativeLimit = index32 + 1; in repTextAccess()
1809 if (ut->chunkNativeLimit > length) { in repTextAccess()
1810 ut->chunkNativeLimit = length; in repTextAccess()
1815 ReplExtra *ex = (ReplExtra *)ut->pExtra; in repTextAccess()
1818 rep->extractBetween((int32_t)ut->chunkNativeStart, (int32_t)ut->chunkNativeLimit, buffer); in repTextAccess()
1820 ut->chunkContents = ex->s; in repTextAccess()
1821 ut->chunkLength = (int32_t)(ut->chunkNativeLimit - ut->chunkNativeStart); in repTextAccess()
1822 ut->chunkOffset = (int32_t)(index32 - ut->chunkNativeStart); in repTextAccess()
1826 if (ut->chunkNativeLimit < length && in repTextAccess()
1827 U16_IS_LEAD(ex->s[ut->chunkLength-1])) { in repTextAccess()
1828 ut->chunkLength--; in repTextAccess()
1829 ut->chunkNativeLimit--; in repTextAccess()
1830 if (ut->chunkOffset > ut->chunkLength) { in repTextAccess()
1831 ut->chunkOffset = ut->chunkLength; in repTextAccess()
1837 if(ut->chunkNativeStart>0 && U16_IS_TRAIL(ex->s[0])) { in repTextAccess()
1838 ++(ut->chunkContents); in repTextAccess()
1839 ++(ut->chunkNativeStart); in repTextAccess()
1840 --(ut->chunkLength); in repTextAccess()
1841 --(ut->chunkOffset); in repTextAccess()
1845 U16_SET_CP_START(ut->chunkContents, 0, ut->chunkOffset); in repTextAccess()
1848 ut->nativeIndexingLimit = ut->chunkLength; in repTextAccess()
1856 repTextExtract(UText *ut, in repTextExtract() argument
1860 const Replaceable *rep=(const Replaceable *)ut->context; in repTextExtract()
1893 repTextAccess(ut, limit32, TRUE); in repTextExtract()
1899 repTextReplace(UText *ut, in repTextReplace() argument
1903 Replaceable *rep=(Replaceable *)ut->context; in repTextReplace()
1941 if (ut->chunkNativeLimit > start32) { in repTextReplace()
1944 invalidateChunk(ut); in repTextReplace()
1949 repTextAccess(ut, newIndexPos, TRUE); in repTextReplace()
1956 repTextCopy(UText *ut, in repTextCopy() argument
1962 Replaceable *rep=(Replaceable *)ut->context; in repTextCopy()
2000 if (firstAffectedIndex < ut->chunkNativeLimit) { in repTextCopy()
2002 invalidateChunk(ut); in repTextCopy()
2013 repTextAccess(ut, nativeIterIndex, TRUE); in repTextCopy()
2036 utext_openReplaceable(UText *ut, Replaceable *rep, UErrorCode *status) in utext_openReplaceable() argument
2045 ut = utext_setup(ut, sizeof(ReplExtra), status); in utext_openReplaceable()
2047 return ut; in utext_openReplaceable()
2050 ut->providerProperties = I32_FLAG(UTEXT_PROVIDER_WRITABLE); in utext_openReplaceable()
2052 ut->providerProperties |=I32_FLAG(UTEXT_PROVIDER_HAS_META_DATA); in utext_openReplaceable()
2055 ut->pFuncs = &repFuncs; in utext_openReplaceable()
2056 ut->context = rep; in utext_openReplaceable()
2057 return ut; in utext_openReplaceable()
2107 unistrTextClose(UText *ut) { in unistrTextClose() argument
2111 if (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT)) { in unistrTextClose()
2112 UnicodeString *str = (UnicodeString *)ut->context; in unistrTextClose()
2114 ut->context = NULL; in unistrTextClose()
2126 unistrTextAccess(UText *ut, int64_t index, UBool forward) { in unistrTextAccess() argument
2127 int32_t length = ut->chunkLength; in unistrTextAccess()
2128 ut->chunkOffset = pinIndex(index, length); in unistrTextAccess()
2175 unistrTextReplace(UText *ut, in unistrTextReplace() argument
2179 UnicodeString *us=(UnicodeString *)ut->context; in unistrTextReplace()
2207 ut->chunkContents = us->getBuffer(); in unistrTextReplace()
2208 ut->chunkLength = newLength; in unistrTextReplace()
2209 ut->chunkNativeLimit = newLength; in unistrTextReplace()
2210 ut->nativeIndexingLimit = newLength; in unistrTextReplace()
2214 ut->chunkOffset = limit32 + lengthDelta; in unistrTextReplace()
2220 unistrTextCopy(UText *ut, in unistrTextCopy() argument
2225 UnicodeString *us=(UnicodeString *)ut->context; in unistrTextCopy()
2254 ut->chunkContents = us->getBuffer(); in unistrTextCopy()
2257 ut->chunkLength += limit32-start32; in unistrTextCopy()
2258 ut->chunkNativeLimit = ut->chunkLength; in unistrTextCopy()
2259 ut->nativeIndexingLimit = ut->chunkLength; in unistrTextCopy()
2263 ut->chunkOffset = destIndex32+limit32-start32; in unistrTextCopy()
2265 ut->chunkOffset = destIndex32; in unistrTextCopy()
2294 utext_openUnicodeString(UText *ut, UnicodeString *s, UErrorCode *status) { in utext_openUnicodeString() argument
2295 ut = utext_openConstUnicodeString(ut, s, status); in utext_openUnicodeString()
2297 ut->providerProperties |= I32_FLAG(UTEXT_PROVIDER_WRITABLE); in utext_openUnicodeString()
2299 return ut; in utext_openUnicodeString()
2305 utext_openConstUnicodeString(UText *ut, const UnicodeString *s, UErrorCode *status) { in utext_openConstUnicodeString() argument
2309 utext_openUChars(ut, NULL, 0, status); in utext_openConstUnicodeString()
2311 return ut; in utext_openConstUnicodeString()
2313 ut = utext_setup(ut, 0, status); in utext_openConstUnicodeString()
2318 ut->pFuncs = &unistrFuncs; in utext_openConstUnicodeString()
2319 ut->context = s; in utext_openConstUnicodeString()
2320 ut->providerProperties = I32_FLAG(UTEXT_PROVIDER_STABLE_CHUNKS); in utext_openConstUnicodeString()
2321 ut->chunkContents = s->getBuffer(); in utext_openConstUnicodeString()
2322 ut->chunkLength = s->length(); in utext_openConstUnicodeString()
2323 ut->chunkNativeStart = 0; in utext_openConstUnicodeString()
2324 ut->chunkNativeLimit = ut->chunkLength; in utext_openConstUnicodeString()
2325 ut->nativeIndexingLimit = ut->chunkLength; in utext_openConstUnicodeString()
2327 return ut; in utext_openConstUnicodeString()
2379 ucstrTextClose(UText *ut) { in ucstrTextClose() argument
2383 if (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT)) { in ucstrTextClose()
2384 UChar *s = (UChar *)ut->context; in ucstrTextClose()
2386 ut->context = NULL; in ucstrTextClose()
2393 ucstrTextLength(UText *ut) { in ucstrTextLength() argument
2394 if (ut->a < 0) { in ucstrTextLength()
2398 const UChar *str = (const UChar *)ut->context; in ucstrTextLength()
2400 if (str[ut->chunkNativeLimit] == 0) { in ucstrTextLength()
2403 ut->chunkNativeLimit++; in ucstrTextLength()
2405 ut->a = ut->chunkNativeLimit; in ucstrTextLength()
2406 ut->chunkLength = (int32_t)ut->chunkNativeLimit; in ucstrTextLength()
2407 ut->nativeIndexingLimit = ut->chunkLength; in ucstrTextLength()
2408 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in ucstrTextLength()
2410 return ut->a; in ucstrTextLength()
2415 ucstrTextAccess(UText *ut, int64_t index, UBool forward) { in ucstrTextAccess() argument
2416 const UChar *str = (const UChar *)ut->context; in ucstrTextAccess()
2422 } else if (index < ut->chunkNativeLimit) { in ucstrTextAccess()
2426 } else if (ut->a >= 0) { in ucstrTextAccess()
2429 index = ut->a; in ucstrTextAccess()
2441 int32_t chunkLimit = (int32_t)ut->chunkNativeLimit; in ucstrTextAccess()
2446 ut->a = chunkLimit; in ucstrTextAccess()
2447 ut->chunkLength = chunkLimit; in ucstrTextAccess()
2448 ut->nativeIndexingLimit = chunkLimit; in ucstrTextAccess()
2455 ut->chunkNativeLimit = chunkLimit; in ucstrTextAccess()
2456 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in ucstrTextAccess()
2466 ut->a = chunkLimit; in ucstrTextAccess()
2467 ut->chunkLength = chunkLimit; in ucstrTextAccess()
2468 ut->nativeIndexingLimit = chunkLimit; in ucstrTextAccess()
2472 ut->chunkNativeLimit = chunkLimit; in ucstrTextAccess()
2473 ut->providerProperties &= ~I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in ucstrTextAccess()
2486 ut->chunkNativeLimit = chunkLimit; in ucstrTextAccess()
2487 ut->nativeIndexingLimit = chunkLimit; in ucstrTextAccess()
2488 ut->chunkLength = chunkLimit; in ucstrTextAccess()
2494 ut->chunkOffset = (int32_t)index; in ucstrTextAccess()
2497 UBool retVal = (forward && index<ut->chunkNativeLimit) || (!forward && index>0); in ucstrTextAccess()
2504 ucstrTextExtract(UText *ut, in ucstrTextExtract() argument
2526 ucstrTextAccess(ut, start, TRUE); in ucstrTextExtract()
2527 const UChar *s=ut->chunkContents; in ucstrTextExtract()
2528 start32 = ut->chunkOffset; in ucstrTextExtract()
2530 int32_t strLength=(int32_t)ut->a; in ucstrTextExtract()
2540 ut->a = si; // set string length for this UText in ucstrTextExtract()
2541 ut->chunkNativeLimit = si; in ucstrTextExtract()
2542 ut->chunkLength = si; in ucstrTextExtract()
2543 ut->nativeIndexingLimit = si; in ucstrTextExtract()
2577 if (si <= ut->chunkNativeLimit) { in ucstrTextExtract()
2578 ut->chunkOffset = si; in ucstrTextExtract()
2580 ucstrTextAccess(ut, si, TRUE); in ucstrTextExtract()
2612 utext_openUChars(UText *ut, const UChar *s, int64_t length, UErrorCode *status) { in utext_openUChars() argument
2623 ut = utext_setup(ut, 0, status); in utext_openUChars()
2625 ut->pFuncs = &ucstrFuncs; in utext_openUChars()
2626 ut->context = s; in utext_openUChars()
2627 ut->providerProperties = I32_FLAG(UTEXT_PROVIDER_STABLE_CHUNKS); in utext_openUChars()
2629 ut->providerProperties |= I32_FLAG(UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE); in utext_openUChars()
2631 ut->a = length; in utext_openUChars()
2632 ut->chunkContents = s; in utext_openUChars()
2633 ut->chunkNativeStart = 0; in utext_openUChars()
2634 ut->chunkNativeLimit = length>=0? length : 0; in utext_openUChars()
2635 ut->chunkLength = (int32_t)ut->chunkNativeLimit; in utext_openUChars()
2636 ut->chunkOffset = 0; in utext_openUChars()
2637 ut->nativeIndexingLimit = ut->chunkLength; in utext_openUChars()
2639 return ut; in utext_openUChars()
2662 charIterTextClose(UText *ut) { in charIterTextClose() argument
2666 CharacterIterator *ci = (CharacterIterator *)ut->r; in charIterTextClose()
2668 ut->r = NULL; in charIterTextClose()
2672 charIterTextLength(UText *ut) { in charIterTextLength() argument
2673 return (int32_t)ut->a; in charIterTextLength()
2677 charIterTextAccess(UText *ut, int64_t index, UBool forward) { in charIterTextAccess() argument
2678 CharacterIterator *ci = (CharacterIterator *)ut->context; in charIterTextAccess()
2683 } else if (clippedIndex>=ut->a) { in charIterTextAccess()
2684 clippedIndex=(int32_t)ut->a; in charIterTextAccess()
2690 } else if (forward && neededIndex==ut->a && neededIndex>0) { in charIterTextAccess()
2701 if (ut->chunkNativeStart == neededIndex) { in charIterTextAccess()
2704 } else if (ut->b == neededIndex) { in charIterTextAccess()
2706 buf = (UChar *)ut->p; in charIterTextAccess()
2707 } else if (ut->c == neededIndex) { in charIterTextAccess()
2709 buf = (UChar *)ut->q; in charIterTextAccess()
2714 buf = (UChar *)ut->p; in charIterTextAccess()
2715 if (ut->p == ut->chunkContents) { in charIterTextAccess()
2716 buf = (UChar *)ut->q; in charIterTextAccess()
2721 if (i+neededIndex > ut->a) { in charIterTextAccess()
2730 ut->chunkContents = buf; in charIterTextAccess()
2731 ut->chunkLength = CIBufSize; in charIterTextAccess()
2732 ut->chunkNativeStart = neededIndex; in charIterTextAccess()
2733 ut->chunkNativeLimit = neededIndex + CIBufSize; in charIterTextAccess()
2734 if (ut->chunkNativeLimit > ut->a) { in charIterTextAccess()
2735 ut->chunkNativeLimit = ut->a; in charIterTextAccess()
2736 ut->chunkLength = (int32_t)(ut->chunkNativeLimit)-(int32_t)(ut->chunkNativeStart); in charIterTextAccess()
2738 ut->nativeIndexingLimit = ut->chunkLength; in charIterTextAccess()
2739 U_ASSERT(ut->chunkOffset>=0 && ut->chunkOffset<=CIBufSize); in charIterTextAccess()
2741 ut->chunkOffset = clippedIndex - (int32_t)ut->chunkNativeStart; in charIterTextAccess()
2742 UBool success = (forward? ut->chunkOffset<ut->chunkLength : ut->chunkOffset>0); in charIterTextAccess()
2773 charIterTextExtract(UText *ut, in charIterTextExtract() argument
2785 int32_t length = (int32_t)ut->a; in charIterTextExtract()
2792 CharacterIterator *ci = (CharacterIterator *)ut->context; in charIterTextExtract()
2810 charIterTextAccess(ut, copyLimit, TRUE); in charIterTextExtract()
2837 utext_openCharacterIterator(UText *ut, CharacterIterator *ci, UErrorCode *status) { in utext_openCharacterIterator() argument
2850 ut = utext_setup(ut, extraSpace, status); in utext_openCharacterIterator()
2852 ut->pFuncs = &charIterFuncs; in utext_openCharacterIterator()
2853 ut->context = ci; in utext_openCharacterIterator()
2854 ut->providerProperties = 0; in utext_openCharacterIterator()
2855 ut->a = ci->endIndex(); // Length of text in utext_openCharacterIterator()
2856 ut->p = ut->pExtra; // First buffer in utext_openCharacterIterator()
2857 ut->b = -1; // Native index of first buffer contents in utext_openCharacterIterator()
2858 ut->q = (UChar*)ut->pExtra+CIBufSize; // Second buffer in utext_openCharacterIterator()
2859 ut->c = -1; // Native index of second buffer contents in utext_openCharacterIterator()
2867 ut->chunkContents = (UChar *)ut->p; in utext_openCharacterIterator()
2868 ut->chunkNativeStart = -1; in utext_openCharacterIterator()
2869 ut->chunkOffset = 1; in utext_openCharacterIterator()
2870 ut->chunkNativeLimit = 0; in utext_openCharacterIterator()
2871 ut->chunkLength = 0; in utext_openCharacterIterator()
2872 ut->nativeIndexingLimit = ut->chunkOffset; // enables native indexing in utext_openCharacterIterator()
2874 return ut; in utext_openCharacterIterator()