Lines Matching refs:strsrch
149 inline int32_t getCE(const UStringSearch *strsrch, uint32_t sourcece) in getCE() argument
154 sourcece &= strsrch->ceMask; in getCE()
156 if (strsrch->toShift) { in getCE()
162 if (strsrch->variableTop > sourcece) { in getCE()
163 if (strsrch->strength >= UCOL_QUATERNARY) { in getCE()
170 } else if (strsrch->strength >= UCOL_QUATERNARY && sourcece == UCOL_IGNORABLE) { in getCE()
292 inline uint16_t initializePatternCETable(UStringSearch *strsrch, in initializePatternCETable() argument
295 UPattern *pattern = &(strsrch->pattern); in initializePatternCETable()
299 UCollationElements *coleiter = strsrch->utilIter; in initializePatternCETable()
302 coleiter = ucol_openElements(strsrch->collator, pattern->text, in initializePatternCETable()
307 strsrch->utilIter = coleiter; in initializePatternCETable()
326 uint32_t newce = getCE(strsrch, ce); in initializePatternCETable()
364 inline uint16_t initializePatternPCETable(UStringSearch *strsrch, in initializePatternPCETable() argument
367 UPattern *pattern = &(strsrch->pattern); in initializePatternPCETable()
371 UCollationElements *coleiter = strsrch->utilIter; in initializePatternPCETable()
374 coleiter = ucol_openElements(strsrch->collator, pattern->text, in initializePatternPCETable()
379 strsrch->utilIter = coleiter; in initializePatternPCETable()
437 inline int16_t initializePattern(UStringSearch *strsrch, UErrorCode *status) in initializePattern() argument
440 UPattern *pattern = &(strsrch->pattern); in initializePattern()
446 if (strsrch->strength == UCOL_PRIMARY) { in initializePattern()
459 if (strsrch->pattern.pces != NULL) { in initializePattern()
460 if (strsrch->pattern.pces != strsrch->pattern.pcesBuffer) { in initializePattern()
461 uprv_free(strsrch->pattern.pces); in initializePattern()
464 strsrch->pattern.pces = NULL; in initializePattern()
468 return initializePatternCETable(strsrch, status); in initializePattern()
548 inline void initialize(UStringSearch *strsrch, UErrorCode *status) in initialize() argument
550 int16_t expandlength = initializePattern(strsrch, status); in initialize()
551 if (U_SUCCESS(*status) && strsrch->pattern.cesLength > 0) { in initialize()
552 UPattern *pattern = &strsrch->pattern; in initialize()
562 strsrch->pattern.defaultShiftSize = 0; in initialize()
574 void checkBreakBoundary(const UStringSearch *strsrch, int32_t * /*start*/, in checkBreakBoundary() argument
578 UBreakIterator *breakiterator = strsrch->search->internalBreakIter; in checkBreakBoundary()
605 UBool isBreakUnit(const UStringSearch *strsrch, int32_t start, in isBreakUnit() argument
609 UBreakIterator *breakiterator = strsrch->search->breakIter; in isBreakUnit()
629 UCollationElements *coleiter = strsrch->utilIter; in isBreakUnit()
630 const UChar *text = strsrch->search->text + in isBreakUnit()
634 for (int32_t count = 0; count < strsrch->pattern.cesLength; in isBreakUnit()
636 int32_t ce = getCE(strsrch, ucol_next(coleiter, &status)); in isBreakUnit()
641 if (U_FAILURE(status) || ce != strsrch->pattern.ces[count]) { in isBreakUnit()
647 && getCE(strsrch, nextce) == UCOL_IGNORABLE) { in isBreakUnit()
703 inline int32_t getNextUStringSearchBaseOffset(UStringSearch *strsrch, in getNextUStringSearchBaseOffset() argument
706 int32_t textlength = strsrch->search->textLength; in getNextUStringSearchBaseOffset()
707 if (strsrch->pattern.hasSuffixAccents && in getNextUStringSearchBaseOffset()
710 const UChar *text = strsrch->search->text; in getNextUStringSearchBaseOffset()
732 inline int32_t shiftForward(UStringSearch *strsrch, in shiftForward() argument
737 UPattern *pattern = &(strsrch->pattern); in shiftForward()
752 textoffset = getNextUStringSearchBaseOffset(strsrch, textoffset); in shiftForward()
768 inline void setMatchNotFound(UStringSearch *strsrch) in setMatchNotFound() argument
771 strsrch->search->matchedIndex = USEARCH_DONE; in setMatchNotFound()
772 strsrch->search->matchedLength = 0; in setMatchNotFound()
773 if (strsrch->search->isForwardSearching) { in setMatchNotFound()
774 setColEIterOffset(strsrch->textIter, strsrch->search->textLength); in setMatchNotFound()
777 setColEIterOffset(strsrch->textIter, 0); in setMatchNotFound()
831 UBool checkExtraMatchAccents(const UStringSearch *strsrch, int32_t start, in checkExtraMatchAccents() argument
836 if (strsrch->pattern.hasPrefixAccents) { in checkExtraMatchAccents()
839 const UChar *text = strsrch->search->text + start; in checkExtraMatchAccents()
844 int32_t safeoffset = getNextSafeOffset(strsrch->collator, in checkExtraMatchAccents()
874 UCollationElements *coleiter = strsrch->utilIter; in checkExtraMatchAccents()
876 uint32_t firstce = strsrch->pattern.ces[0]; in checkExtraMatchAccents()
921 UBool hasAccentsBeforeMatch(const UStringSearch *strsrch, int32_t start, in hasAccentsBeforeMatch() argument
924 if (strsrch->pattern.hasPrefixAccents) { in hasAccentsBeforeMatch()
925 UCollationElements *coleiter = strsrch->textIter; in hasAccentsBeforeMatch()
929 int32_t firstce = strsrch->pattern.ces[0]; in hasAccentsBeforeMatch()
932 int32_t ce = getCE(strsrch, ucol_next(coleiter, &status)); in hasAccentsBeforeMatch()
940 ce = getCE(strsrch, ucol_next(coleiter, &status)); in hasAccentsBeforeMatch()
959 UBool accent = getFCD(strsrch->search->text, &temp, in hasAccentsBeforeMatch()
960 strsrch->search->textLength) > 0xFF; in hasAccentsBeforeMatch()
962 return checkExtraMatchAccents(strsrch, start, end, &status); in hasAccentsBeforeMatch()
969 U16_BACK_1(strsrch->search->text, 0, temp); in hasAccentsBeforeMatch()
970 if (getFCD(strsrch->search->text, &temp, in hasAccentsBeforeMatch()
971 strsrch->search->textLength) & LAST_BYTE_MASK_) { in hasAccentsBeforeMatch()
1002 UBool hasAccentsAfterMatch(const UStringSearch *strsrch, int32_t start, in hasAccentsAfterMatch() argument
1005 if (strsrch->pattern.hasSuffixAccents) { in hasAccentsAfterMatch()
1006 const UChar *text = strsrch->search->text; in hasAccentsAfterMatch()
1008 int32_t textlength = strsrch->search->textLength; in hasAccentsAfterMatch()
1011 int32_t firstce = strsrch->pattern.ces[0]; in hasAccentsAfterMatch()
1012 UCollationElements *coleiter = strsrch->textIter; in hasAccentsAfterMatch()
1016 while ((ce = getCE(strsrch, ucol_next(coleiter, &status))) != firstce) { in hasAccentsAfterMatch()
1022 while (count < strsrch->pattern.cesLength) { in hasAccentsAfterMatch()
1023 if (getCE(strsrch, ucol_next(coleiter, &status)) in hasAccentsAfterMatch()
1039 ce = getCE(strsrch, ce); in hasAccentsAfterMatch()
1075 inline UBool checkIdentical(const UStringSearch *strsrch, int32_t start, in checkIdentical() argument
1078 if (strsrch->strength != UCOL_IDENTICAL) { in checkIdentical()
1086 strsrch->nfd->normalize( in checkIdentical()
1087 UnicodeString(FALSE, strsrch->search->text + start, end - start), t2, status); in checkIdentical()
1088 strsrch->nfd->normalize( in checkIdentical()
1089 UnicodeString(FALSE, strsrch->pattern.text, strsrch->pattern.textLength), p2, status); in checkIdentical()
1103 inline UBool checkRepeatedMatch(UStringSearch *strsrch, in checkRepeatedMatch() argument
1107 int32_t lastmatchindex = strsrch->search->matchedIndex; in checkRepeatedMatch()
1112 if (strsrch->search->isForwardSearching) { in checkRepeatedMatch()
1118 if (!result && !strsrch->search->isOverlap) { in checkRepeatedMatch()
1119 if (strsrch->search->isForwardSearching) { in checkRepeatedMatch()
1120 result = start < lastmatchindex + strsrch->search->matchedLength; in checkRepeatedMatch()
1163 UBool checkNextExactContractionMatch(UStringSearch *strsrch, in checkNextExactContractionMatch() argument
1167 UCollationElements *coleiter = strsrch->textIter; in checkNextExactContractionMatch()
1168 int32_t textlength = strsrch->search->textLength; in checkNextExactContractionMatch()
1170 const UCollator *collator = strsrch->collator; in checkNextExactContractionMatch()
1171 const UChar *text = strsrch->search->text; in checkNextExactContractionMatch()
1206 int32_t *patternce = strsrch->pattern.ces; in checkNextExactContractionMatch()
1207 int32_t patterncelength = strsrch->pattern.cesLength; in checkNextExactContractionMatch()
1210 int32_t ce = getCE(strsrch, ucol_next(coleiter, status)); in checkNextExactContractionMatch()
1220 *end = getNextUStringSearchBaseOffset(strsrch, *end); in checkNextExactContractionMatch()
1250 inline UBool checkNextExactMatch(UStringSearch *strsrch, in checkNextExactMatch() argument
1253 UCollationElements *coleiter = strsrch->textIter; in checkNextExactMatch()
1256 if (!checkNextExactContractionMatch(strsrch, &start, textoffset, status)) { in checkNextExactMatch()
1261 if (!isBreakUnit(strsrch, start, *textoffset) || in checkNextExactMatch()
1262 checkRepeatedMatch(strsrch, start, *textoffset) || in checkNextExactMatch()
1263 hasAccentsBeforeMatch(strsrch, start, *textoffset) || in checkNextExactMatch()
1264 !checkIdentical(strsrch, start, *textoffset) || in checkNextExactMatch()
1265 hasAccentsAfterMatch(strsrch, start, *textoffset)) { in checkNextExactMatch()
1268 *textoffset = getNextUStringSearchBaseOffset(strsrch, *textoffset); in checkNextExactMatch()
1273 if (!strsrch->search->breakIter && strsrch->strength == UCOL_PRIMARY) { in checkNextExactMatch()
1274 checkBreakBoundary(strsrch, &start, textoffset); in checkNextExactMatch()
1278 strsrch->search->matchedIndex = start; in checkNextExactMatch()
1279 strsrch->search->matchedLength = *textoffset - start; in checkNextExactMatch()
1406 inline UBool checkCollationMatch(const UStringSearch *strsrch, in checkCollationMatch() argument
1409 int patternceindex = strsrch->pattern.cesLength; in checkCollationMatch()
1410 int32_t *patternce = strsrch->pattern.ces; in checkCollationMatch()
1413 int32_t ce = getCE(strsrch, ucol_next(coleiter, &status)); in checkCollationMatch()
1446 int32_t doNextCanonicalPrefixMatch(UStringSearch *strsrch, in doNextCanonicalPrefixMatch() argument
1451 const UChar *text = strsrch->search->text; in doNextCanonicalPrefixMatch()
1452 int32_t textlength = strsrch->search->textLength; in doNextCanonicalPrefixMatch()
1476 UCollationElements *coleiter = strsrch->utilIter; in doNextCanonicalPrefixMatch()
1478 UChar *rearrange = strsrch->canonicalPrefixAccents; in doNextCanonicalPrefixMatch()
1496 strsrch->canonicalPrefixAccents, in doNextCanonicalPrefixMatch()
1497 strsrch->search->text + offset, in doNextCanonicalPrefixMatch()
1499 strsrch->canonicalSuffixAccents, in doNextCanonicalPrefixMatch()
1506 if (checkCollationMatch(strsrch, coleiter)) { in doNextCanonicalPrefixMatch()
1552 inline void cleanUpSafeText(const UStringSearch *strsrch, UChar *safetext, in cleanUpSafeText() argument
1555 if (safetext != safebuffer && safetext != strsrch->canonicalSuffixAccents) in cleanUpSafeText()
1577 int32_t doNextCanonicalSuffixMatch(UStringSearch *strsrch, in doNextCanonicalSuffixMatch() argument
1581 const UChar *text = strsrch->search->text; in doNextCanonicalSuffixMatch()
1582 const UCollator *collator = strsrch->collator; in doNextCanonicalSuffixMatch()
1587 UCollationElements *coleiter = strsrch->utilIter; in doNextCanonicalSuffixMatch()
1590 if (textoffset != 0 && ucol_unsafeCP(strsrch->canonicalSuffixAccents[0], in doNextCanonicalSuffixMatch()
1597 strsrch->canonicalSuffixAccents, in doNextCanonicalSuffixMatch()
1601 safetextlength = u_strlen(strsrch->canonicalSuffixAccents); in doNextCanonicalSuffixMatch()
1602 safetext = strsrch->canonicalSuffixAccents; in doNextCanonicalSuffixMatch()
1609 int32_t *ce = strsrch->pattern.ces; in doNextCanonicalSuffixMatch()
1610 int32_t celength = strsrch->pattern.cesLength; in doNextCanonicalSuffixMatch()
1618 cleanUpSafeText(strsrch, safetext, safebuffer); in doNextCanonicalSuffixMatch()
1624 if (coleiter == strsrch->textIter) { in doNextCanonicalSuffixMatch()
1625 cleanUpSafeText(strsrch, safetext, safebuffer); in doNextCanonicalSuffixMatch()
1628 cleanUpSafeText(strsrch, safetext, safebuffer); in doNextCanonicalSuffixMatch()
1630 coleiter = strsrch->textIter; in doNextCanonicalSuffixMatch()
1636 textce = getCE(strsrch, textce); in doNextCanonicalSuffixMatch()
1642 cleanUpSafeText(strsrch, safetext, safebuffer); in doNextCanonicalSuffixMatch()
1648 cleanUpSafeText(strsrch, safetext, safebuffer); in doNextCanonicalSuffixMatch()
1652 int32_t result = doNextCanonicalPrefixMatch(strsrch, in doNextCanonicalSuffixMatch()
1656 setColEIterOffset(strsrch->textIter, result); in doNextCanonicalSuffixMatch()
1673 cleanUpSafeText(strsrch, safetext, safebuffer); in doNextCanonicalSuffixMatch()
1680 setColEIterOffset(strsrch->textIter, result); in doNextCanonicalSuffixMatch()
1681 strsrch->textIter->iteratordata_.toReturn = in doNextCanonicalSuffixMatch()
1682 setExpansionPrefix(strsrch->textIter, leftoverces); in doNextCanonicalSuffixMatch()
1710 UBool doNextCanonicalMatch(UStringSearch *strsrch, in doNextCanonicalMatch() argument
1714 const UChar *text = strsrch->search->text; in doNextCanonicalMatch()
1718 UCollationElements *coleiter = strsrch->textIter; in doNextCanonicalMatch()
1720 if (strsrch->pattern.hasPrefixAccents) { in doNextCanonicalMatch()
1721 offset = doNextCanonicalPrefixMatch(strsrch, offset, textoffset, in doNextCanonicalMatch()
1731 if (!strsrch->pattern.hasSuffixAccents) { in doNextCanonicalMatch()
1749 UChar *rearrange = strsrch->canonicalSuffixAccents; in doNextCanonicalMatch()
1765 int32_t offset = doNextCanonicalSuffixMatch(strsrch, baseoffset, in doNextCanonicalMatch()
1784 inline int32_t getPreviousUStringSearchBaseOffset(UStringSearch *strsrch, in getPreviousUStringSearchBaseOffset() argument
1787 if (strsrch->pattern.hasPrefixAccents && textoffset > 0) { in getPreviousUStringSearchBaseOffset()
1788 const UChar *text = strsrch->search->text; in getPreviousUStringSearchBaseOffset()
1790 if (getFCD(text, &offset, strsrch->search->textLength) >> in getPreviousUStringSearchBaseOffset()
1812 UBool checkNextCanonicalContractionMatch(UStringSearch *strsrch, in checkNextCanonicalContractionMatch() argument
1817 UCollationElements *coleiter = strsrch->textIter; in checkNextCanonicalContractionMatch()
1818 int32_t textlength = strsrch->search->textLength; in checkNextCanonicalContractionMatch()
1820 const UCollator *collator = strsrch->collator; in checkNextCanonicalContractionMatch()
1821 const UChar *text = strsrch->search->text; in checkNextCanonicalContractionMatch()
1849 int32_t *patternce = strsrch->pattern.ces; in checkNextCanonicalContractionMatch()
1850 int32_t patterncelength = strsrch->pattern.cesLength; in checkNextCanonicalContractionMatch()
1852 int32_t textlength = strsrch->search->textLength; in checkNextCanonicalContractionMatch()
1854 int32_t ce = getCE(strsrch, ucol_next(coleiter, status)); in checkNextCanonicalContractionMatch()
1871 ce = getCE(strsrch, ucol_next(coleiter, status)); in checkNextCanonicalContractionMatch()
1875 ce = getCE(strsrch, ucol_next(coleiter, status)); in checkNextCanonicalContractionMatch()
1881 *end = getNextUStringSearchBaseOffset(strsrch, *end); in checkNextCanonicalContractionMatch()
1910 inline UBool checkNextCanonicalMatch(UStringSearch *strsrch, in checkNextCanonicalMatch() argument
1915 UCollationElements *coleiter = strsrch->textIter; in checkNextCanonicalMatch()
1917 if ((strsrch->pattern.hasSuffixAccents && in checkNextCanonicalMatch()
1918 strsrch->canonicalSuffixAccents[0]) || in checkNextCanonicalMatch()
1919 (strsrch->pattern.hasPrefixAccents && in checkNextCanonicalMatch()
1920 strsrch->canonicalPrefixAccents[0])) { in checkNextCanonicalMatch()
1921 strsrch->search->matchedIndex = getPreviousUStringSearchBaseOffset( in checkNextCanonicalMatch()
1922 strsrch, in checkNextCanonicalMatch()
1924 strsrch->search->matchedLength = *textoffset - in checkNextCanonicalMatch()
1925 strsrch->search->matchedIndex; in checkNextCanonicalMatch()
1930 if (!checkNextCanonicalContractionMatch(strsrch, &start, textoffset, in checkNextCanonicalMatch()
1935 start = getPreviousUStringSearchBaseOffset(strsrch, start); in checkNextCanonicalMatch()
1937 if (checkRepeatedMatch(strsrch, start, *textoffset) || in checkNextCanonicalMatch()
1938 !isBreakUnit(strsrch, start, *textoffset) || in checkNextCanonicalMatch()
1939 !checkIdentical(strsrch, start, *textoffset)) { in checkNextCanonicalMatch()
1941 *textoffset = getNextBaseOffset(strsrch->search->text, *textoffset, in checkNextCanonicalMatch()
1942 strsrch->search->textLength); in checkNextCanonicalMatch()
1946 strsrch->search->matchedIndex = start; in checkNextCanonicalMatch()
1947 strsrch->search->matchedLength = *textoffset - start; in checkNextCanonicalMatch()
1965 inline int32_t reverseShift(UStringSearch *strsrch, in reverseShift() argument
1970 if (strsrch->search->isOverlap) { in reverseShift()
1971 if (textoffset != strsrch->search->textLength) { in reverseShift()
1975 textoffset -= strsrch->pattern.defaultShiftSize; in reverseShift()
1980 int32_t shift = strsrch->pattern.backShift[hashFromCE32(ce)]; in reverseShift()
1991 textoffset -= strsrch->pattern.defaultShiftSize; in reverseShift()
1994 textoffset = getPreviousUStringSearchBaseOffset(strsrch, textoffset); in reverseShift()
2010 UBool checkPreviousExactContractionMatch(UStringSearch *strsrch, in checkPreviousExactContractionMatch() argument
2014 UCollationElements *coleiter = strsrch->textIter; in checkPreviousExactContractionMatch()
2015 int32_t textlength = strsrch->search->textLength; in checkPreviousExactContractionMatch()
2017 const UCollator *collator = strsrch->collator; in checkPreviousExactContractionMatch()
2018 const UChar *text = strsrch->search->text; in checkPreviousExactContractionMatch()
2047 int32_t *patternce = strsrch->pattern.ces; in checkPreviousExactContractionMatch()
2048 int32_t patterncelength = strsrch->pattern.cesLength; in checkPreviousExactContractionMatch()
2051 int32_t ce = getCE(strsrch, ucol_previous(coleiter, status)); in checkPreviousExactContractionMatch()
2096 inline UBool checkPreviousExactMatch(UStringSearch *strsrch, in checkPreviousExactMatch() argument
2101 int32_t end = ucol_getOffset(strsrch->textIter); in checkPreviousExactMatch()
2102 if (!checkPreviousExactContractionMatch(strsrch, textoffset, &end, status) in checkPreviousExactMatch()
2109 if (checkRepeatedMatch(strsrch, *textoffset, end) || in checkPreviousExactMatch()
2110 !isBreakUnit(strsrch, *textoffset, end) || in checkPreviousExactMatch()
2111 hasAccentsBeforeMatch(strsrch, *textoffset, end) || in checkPreviousExactMatch()
2112 !checkIdentical(strsrch, *textoffset, end) || in checkPreviousExactMatch()
2113 hasAccentsAfterMatch(strsrch, *textoffset, end)) { in checkPreviousExactMatch()
2115 *textoffset = getPreviousBaseOffset(strsrch->search->text, in checkPreviousExactMatch()
2121 if (!strsrch->search->breakIter && strsrch->strength == UCOL_PRIMARY) { in checkPreviousExactMatch()
2122 checkBreakBoundary(strsrch, textoffset, &end); in checkPreviousExactMatch()
2125 strsrch->search->matchedIndex = *textoffset; in checkPreviousExactMatch()
2126 strsrch->search->matchedLength = end - *textoffset; in checkPreviousExactMatch()
2150 int32_t doPreviousCanonicalSuffixMatch(UStringSearch *strsrch, in doPreviousCanonicalSuffixMatch() argument
2155 const UChar *text = strsrch->search->text; in doPreviousCanonicalSuffixMatch()
2159 if (!(getFCD(text, &tempend, strsrch->search->textLength) & in doPreviousCanonicalSuffixMatch()
2164 end = getNextBaseOffset(text, end, strsrch->search->textLength); in doPreviousCanonicalSuffixMatch()
2178 UCollationElements *coleiter = strsrch->utilIter; in doPreviousCanonicalSuffixMatch()
2180 UChar *rearrange = strsrch->canonicalSuffixAccents; in doPreviousCanonicalSuffixMatch()
2198 strsrch->canonicalPrefixAccents, in doPreviousCanonicalSuffixMatch()
2199 strsrch->search->text + start, in doPreviousCanonicalSuffixMatch()
2201 strsrch->canonicalSuffixAccents, in doPreviousCanonicalSuffixMatch()
2208 if (checkCollationMatch(strsrch, coleiter)) { in doPreviousCanonicalSuffixMatch()
2237 int32_t doPreviousCanonicalPrefixMatch(UStringSearch *strsrch, in doPreviousCanonicalPrefixMatch() argument
2241 const UChar *text = strsrch->search->text; in doPreviousCanonicalPrefixMatch()
2242 const UCollator *collator = strsrch->collator; in doPreviousCanonicalPrefixMatch()
2250 ucol_unsafeCP(strsrch->canonicalPrefixAccents[ in doPreviousCanonicalPrefixMatch()
2251 u_strlen(strsrch->canonicalPrefixAccents) - 1 in doPreviousCanonicalPrefixMatch()
2254 strsrch->search->textLength); in doPreviousCanonicalPrefixMatch()
2258 strsrch->canonicalPrefixAccents, in doPreviousCanonicalPrefixMatch()
2263 safetextlength = u_strlen(strsrch->canonicalPrefixAccents); in doPreviousCanonicalPrefixMatch()
2264 safetext = strsrch->canonicalPrefixAccents; in doPreviousCanonicalPrefixMatch()
2267 UCollationElements *coleiter = strsrch->utilIter; in doPreviousCanonicalPrefixMatch()
2272 int32_t *ce = strsrch->pattern.ces; in doPreviousCanonicalPrefixMatch()
2273 int32_t celength = strsrch->pattern.cesLength; in doPreviousCanonicalPrefixMatch()
2276 int32_t prefixlength = u_strlen(strsrch->canonicalPrefixAccents); in doPreviousCanonicalPrefixMatch()
2282 cleanUpSafeText(strsrch, safetext, safebuffer); in doPreviousCanonicalPrefixMatch()
2288 if (coleiter == strsrch->textIter) { in doPreviousCanonicalPrefixMatch()
2289 cleanUpSafeText(strsrch, safetext, safebuffer); in doPreviousCanonicalPrefixMatch()
2292 cleanUpSafeText(strsrch, safetext, safebuffer); in doPreviousCanonicalPrefixMatch()
2294 coleiter = strsrch->textIter; in doPreviousCanonicalPrefixMatch()
2300 textce = getCE(strsrch, textce); in doPreviousCanonicalPrefixMatch()
2306 cleanUpSafeText(strsrch, safetext, safebuffer); in doPreviousCanonicalPrefixMatch()
2312 cleanUpSafeText(strsrch, safetext, safebuffer); in doPreviousCanonicalPrefixMatch()
2316 int32_t result = doPreviousCanonicalSuffixMatch(strsrch, in doPreviousCanonicalPrefixMatch()
2320 setColEIterOffset(strsrch->textIter, result); in doPreviousCanonicalPrefixMatch()
2337 cleanUpSafeText(strsrch, safetext, safebuffer); in doPreviousCanonicalPrefixMatch()
2344 setColEIterOffset(strsrch->textIter, result); in doPreviousCanonicalPrefixMatch()
2345 setExpansionSuffix(strsrch->textIter, leftoverces); in doPreviousCanonicalPrefixMatch()
2373 UBool doPreviousCanonicalMatch(UStringSearch *strsrch, in doPreviousCanonicalMatch() argument
2377 const UChar *text = strsrch->search->text; in doPreviousCanonicalMatch()
2379 int32_t textlength = strsrch->search->textLength; in doPreviousCanonicalMatch()
2381 UCollationElements *coleiter = strsrch->textIter; in doPreviousCanonicalMatch()
2383 if (strsrch->pattern.hasSuffixAccents) { in doPreviousCanonicalMatch()
2384 offset = doPreviousCanonicalSuffixMatch(strsrch, textoffset, in doPreviousCanonicalMatch()
2394 if (!strsrch->pattern.hasPrefixAccents) { in doPreviousCanonicalMatch()
2412 UChar *rearrange = strsrch->canonicalPrefixAccents; in doPreviousCanonicalMatch()
2428 int32_t offset = doPreviousCanonicalPrefixMatch(strsrch, in doPreviousCanonicalMatch()
2450 UBool checkPreviousCanonicalContractionMatch(UStringSearch *strsrch, in checkPreviousCanonicalContractionMatch() argument
2454 UCollationElements *coleiter = strsrch->textIter; in checkPreviousCanonicalContractionMatch()
2455 int32_t textlength = strsrch->search->textLength; in checkPreviousCanonicalContractionMatch()
2457 const UCollator *collator = strsrch->collator; in checkPreviousCanonicalContractionMatch()
2458 const UChar *text = strsrch->search->text; in checkPreviousCanonicalContractionMatch()
2487 int32_t *patternce = strsrch->pattern.ces; in checkPreviousCanonicalContractionMatch()
2488 int32_t patterncelength = strsrch->pattern.cesLength; in checkPreviousCanonicalContractionMatch()
2491 int32_t ce = getCE(strsrch, ucol_previous(coleiter, status)); in checkPreviousCanonicalContractionMatch()
2509 ce = getCE(strsrch, ucol_previous(coleiter, status)); in checkPreviousCanonicalContractionMatch()
2513 ce = getCE(strsrch, ucol_previous(coleiter, status)); in checkPreviousCanonicalContractionMatch()
2548 inline UBool checkPreviousCanonicalMatch(UStringSearch *strsrch, in checkPreviousCanonicalMatch() argument
2553 UCollationElements *coleiter = strsrch->textIter; in checkPreviousCanonicalMatch()
2555 if ((strsrch->pattern.hasSuffixAccents && in checkPreviousCanonicalMatch()
2556 strsrch->canonicalSuffixAccents[0]) || in checkPreviousCanonicalMatch()
2557 (strsrch->pattern.hasPrefixAccents && in checkPreviousCanonicalMatch()
2558 strsrch->canonicalPrefixAccents[0])) { in checkPreviousCanonicalMatch()
2559 strsrch->search->matchedIndex = *textoffset; in checkPreviousCanonicalMatch()
2560 strsrch->search->matchedLength = in checkPreviousCanonicalMatch()
2561 getNextUStringSearchBaseOffset(strsrch, in checkPreviousCanonicalMatch()
2568 if (!checkPreviousCanonicalContractionMatch(strsrch, textoffset, &end, in checkPreviousCanonicalMatch()
2574 end = getNextUStringSearchBaseOffset(strsrch, end); in checkPreviousCanonicalMatch()
2576 if (checkRepeatedMatch(strsrch, *textoffset, end) || in checkPreviousCanonicalMatch()
2577 !isBreakUnit(strsrch, *textoffset, end) || in checkPreviousCanonicalMatch()
2578 !checkIdentical(strsrch, *textoffset, end)) { in checkPreviousCanonicalMatch()
2580 *textoffset = getPreviousBaseOffset(strsrch->search->text, in checkPreviousCanonicalMatch()
2585 strsrch->search->matchedIndex = *textoffset; in checkPreviousCanonicalMatch()
2586 strsrch->search->matchedLength = end - *textoffset; in checkPreviousCanonicalMatch()
2754 U_CAPI void U_EXPORT2 usearch_close(UStringSearch *strsrch) in usearch_close() argument
2756 if (strsrch) { in usearch_close()
2757 if (strsrch->pattern.ces != strsrch->pattern.cesBuffer && in usearch_close()
2758 strsrch->pattern.ces) { in usearch_close()
2759 uprv_free(strsrch->pattern.ces); in usearch_close()
2762 if (strsrch->pattern.pces != NULL && in usearch_close()
2763 strsrch->pattern.pces != strsrch->pattern.pcesBuffer) { in usearch_close()
2764 uprv_free(strsrch->pattern.pces); in usearch_close()
2767 delete strsrch->textProcessedIter; in usearch_close()
2768 ucol_closeElements(strsrch->textIter); in usearch_close()
2769 ucol_closeElements(strsrch->utilIter); in usearch_close()
2771 if (strsrch->ownCollator && strsrch->collator) { in usearch_close()
2772 ucol_close((UCollator *)strsrch->collator); in usearch_close()
2776 if (strsrch->search->internalBreakIter) { in usearch_close()
2777 ubrk_close(strsrch->search->internalBreakIter); in usearch_close()
2781 uprv_free(strsrch->search); in usearch_close()
2782 uprv_free(strsrch); in usearch_close()
2788 UBool initTextProcessedIter(UStringSearch *strsrch, UErrorCode *status) { in initTextProcessedIter() argument
2790 if (strsrch->textProcessedIter == NULL) { in initTextProcessedIter()
2791 strsrch->textProcessedIter = new icu::UCollationPCE(strsrch->textIter); in initTextProcessedIter()
2792 if (strsrch->textProcessedIter == NULL) { in initTextProcessedIter()
2797 strsrch->textProcessedIter->init(strsrch->textIter); in initTextProcessedIter()
2806 U_CAPI void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch, in usearch_setOffset() argument
2810 if (U_SUCCESS(*status) && strsrch) { in usearch_setOffset()
2811 if (isOutOfBounds(strsrch->search->textLength, position)) { in usearch_setOffset()
2815 setColEIterOffset(strsrch->textIter, position); in usearch_setOffset()
2817 strsrch->search->matchedIndex = USEARCH_DONE; in usearch_setOffset()
2818 strsrch->search->matchedLength = 0; in usearch_setOffset()
2819 strsrch->search->reset = FALSE; in usearch_setOffset()
2823 U_CAPI int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch) in usearch_getOffset() argument
2825 if (strsrch) { in usearch_getOffset()
2826 int32_t result = ucol_getOffset(strsrch->textIter); in usearch_getOffset()
2827 if (isOutOfBounds(strsrch->search->textLength, result)) { in usearch_getOffset()
2835 U_CAPI void U_EXPORT2 usearch_setAttribute(UStringSearch *strsrch, in usearch_setAttribute() argument
2840 if (U_SUCCESS(*status) && strsrch) { in usearch_setAttribute()
2844 strsrch->search->isOverlap = (value == USEARCH_ON ? TRUE : FALSE); in usearch_setAttribute()
2847 strsrch->search->isCanonicalMatch = (value == USEARCH_ON ? TRUE : in usearch_setAttribute()
2852 strsrch->search->elementComparisonType = (int16_t)value; in usearch_setAttribute()
2854 strsrch->search->elementComparisonType = 0; in usearch_setAttribute()
2868 const UStringSearch *strsrch, in usearch_getAttribute() argument
2871 if (strsrch) { in usearch_getAttribute()
2874 return (strsrch->search->isOverlap == TRUE ? USEARCH_ON : in usearch_getAttribute()
2877 return (strsrch->search->isCanonicalMatch == TRUE ? USEARCH_ON : in usearch_getAttribute()
2881 int16_t value = strsrch->search->elementComparisonType; in usearch_getAttribute()
2896 const UStringSearch *strsrch) in usearch_getMatchedStart() argument
2898 if (strsrch == NULL) { in usearch_getMatchedStart()
2901 return strsrch->search->matchedIndex; in usearch_getMatchedStart()
2905 U_CAPI int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch, in usearch_getMatchedText() argument
2913 if (strsrch == NULL || resultCapacity < 0 || (resultCapacity > 0 && in usearch_getMatchedText()
2919 int32_t copylength = strsrch->search->matchedLength; in usearch_getMatchedText()
2920 int32_t copyindex = strsrch->search->matchedIndex; in usearch_getMatchedText()
2930 uprv_memcpy(result, strsrch->search->text + copyindex, in usearch_getMatchedText()
2934 strsrch->search->matchedLength, status); in usearch_getMatchedText()
2938 const UStringSearch *strsrch) in usearch_getMatchedLength() argument
2940 if (strsrch) { in usearch_getMatchedLength()
2941 return strsrch->search->matchedLength; in usearch_getMatchedLength()
2948 U_CAPI void U_EXPORT2 usearch_setBreakIterator(UStringSearch *strsrch, in usearch_setBreakIterator() argument
2952 if (U_SUCCESS(*status) && strsrch) { in usearch_setBreakIterator()
2953 strsrch->search->breakIter = breakiter; in usearch_setBreakIterator()
2955 ubrk_setText(breakiter, strsrch->search->text, in usearch_setBreakIterator()
2956 strsrch->search->textLength, status); in usearch_setBreakIterator()
2962 usearch_getBreakIterator(const UStringSearch *strsrch) in usearch_getBreakIterator() argument
2964 if (strsrch) { in usearch_getBreakIterator()
2965 return strsrch->search->breakIter; in usearch_getBreakIterator()
2972 U_CAPI void U_EXPORT2 usearch_setText( UStringSearch *strsrch, in usearch_setText() argument
2978 if (strsrch == NULL || text == NULL || textlength < -1 || in usearch_setText()
2986 strsrch->search->text = text; in usearch_setText()
2987 strsrch->search->textLength = textlength; in usearch_setText()
2988 ucol_setText(strsrch->textIter, text, textlength, status); in usearch_setText()
2989 strsrch->search->matchedIndex = USEARCH_DONE; in usearch_setText()
2990 strsrch->search->matchedLength = 0; in usearch_setText()
2991 strsrch->search->reset = TRUE; in usearch_setText()
2993 if (strsrch->search->breakIter != NULL) { in usearch_setText()
2994 ubrk_setText(strsrch->search->breakIter, text, in usearch_setText()
2997 ubrk_setText(strsrch->search->internalBreakIter, text, textlength, status); in usearch_setText()
3003 U_CAPI const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch, in usearch_getText() argument
3006 if (strsrch) { in usearch_getText()
3007 *length = strsrch->search->textLength; in usearch_getText()
3008 return strsrch->search->text; in usearch_getText()
3013 U_CAPI void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch, in usearch_setCollator() argument
3023 if (strsrch) { in usearch_setCollator()
3024 delete strsrch->textProcessedIter; in usearch_setCollator()
3025 strsrch->textProcessedIter = NULL; in usearch_setCollator()
3026 ucol_closeElements(strsrch->textIter); in usearch_setCollator()
3027 ucol_closeElements(strsrch->utilIter); in usearch_setCollator()
3028 strsrch->textIter = strsrch->utilIter = NULL; in usearch_setCollator()
3029 if (strsrch->ownCollator && (strsrch->collator != collator)) { in usearch_setCollator()
3030 ucol_close((UCollator *)strsrch->collator); in usearch_setCollator()
3031 strsrch->ownCollator = FALSE; in usearch_setCollator()
3033 strsrch->collator = collator; in usearch_setCollator()
3034 strsrch->strength = ucol_getStrength(collator); in usearch_setCollator()
3035 strsrch->ceMask = getMask(strsrch->strength); in usearch_setCollator()
3037 ubrk_close(strsrch->search->internalBreakIter); in usearch_setCollator()
3038 …strsrch->search->internalBreakIter = ubrk_open(UBRK_CHARACTER, ucol_getLocaleByType(collator, ULOC… in usearch_setCollator()
3039 … strsrch->search->text, strsrch->search->textLength, status); in usearch_setCollator()
3042 strsrch->toShift = in usearch_setCollator()
3046 strsrch->variableTop = ucol_getVariableTop(collator, status); in usearch_setCollator()
3047 strsrch->textIter = ucol_openElements(collator, in usearch_setCollator()
3048 strsrch->search->text, in usearch_setCollator()
3049 strsrch->search->textLength, in usearch_setCollator()
3051 strsrch->utilIter = ucol_openElements( in usearch_setCollator()
3052 collator, strsrch->pattern.text, strsrch->pattern.textLength, status); in usearch_setCollator()
3054 initialize(strsrch, status); in usearch_setCollator()
3061 uprv_init_pce(strsrch->textIter); in usearch_setCollator()
3062 uprv_init_pce(strsrch->utilIter); in usearch_setCollator()
3067 U_CAPI UCollator * U_EXPORT2 usearch_getCollator(const UStringSearch *strsrch) in usearch_getCollator() argument
3069 if (strsrch) { in usearch_getCollator()
3070 return (UCollator *)strsrch->collator; in usearch_getCollator()
3075 U_CAPI void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch, in usearch_setPattern() argument
3081 if (strsrch == NULL || pattern == NULL) { in usearch_setPattern()
3092 strsrch->pattern.text = pattern; in usearch_setPattern()
3093 strsrch->pattern.textLength = patternlength; in usearch_setPattern()
3094 initialize(strsrch, status); in usearch_setPattern()
3100 usearch_getPattern(const UStringSearch *strsrch, in usearch_getPattern() argument
3103 if (strsrch) { in usearch_getPattern()
3104 *length = strsrch->pattern.textLength; in usearch_getPattern()
3105 return strsrch->pattern.text; in usearch_getPattern()
3112 U_CAPI int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch, in usearch_first() argument
3115 if (strsrch && U_SUCCESS(*status)) { in usearch_first()
3116 strsrch->search->isForwardSearching = TRUE; in usearch_first()
3117 usearch_setOffset(strsrch, 0, status); in usearch_first()
3119 return usearch_next(strsrch, status); in usearch_first()
3125 U_CAPI int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch, in usearch_following() argument
3129 if (strsrch && U_SUCCESS(*status)) { in usearch_following()
3130 strsrch->search->isForwardSearching = TRUE; in usearch_following()
3132 usearch_setOffset(strsrch, position, status); in usearch_following()
3134 return usearch_next(strsrch, status); in usearch_following()
3140 U_CAPI int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch, in usearch_last() argument
3143 if (strsrch && U_SUCCESS(*status)) { in usearch_last()
3144 strsrch->search->isForwardSearching = FALSE; in usearch_last()
3145 usearch_setOffset(strsrch, strsrch->search->textLength, status); in usearch_last()
3147 return usearch_previous(strsrch, status); in usearch_last()
3153 U_CAPI int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch, in usearch_preceding() argument
3157 if (strsrch && U_SUCCESS(*status)) { in usearch_preceding()
3158 strsrch->search->isForwardSearching = FALSE; in usearch_preceding()
3160 usearch_setOffset(strsrch, position, status); in usearch_preceding()
3162 return usearch_previous(strsrch, status); in usearch_preceding()
3190 U_CAPI int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch, in usearch_next() argument
3193 if (U_SUCCESS(*status) && strsrch) { in usearch_next()
3196 int32_t offset = usearch_getOffset(strsrch); in usearch_next()
3197 USearch *search = strsrch->search; in usearch_next()
3204 (offset + strsrch->pattern.defaultShiftSize > textlength || in usearch_next()
3208 setMatchNotFound(strsrch); in usearch_next()
3217 setMatchNotFound(strsrch); in usearch_next()
3237 if (strsrch->pattern.cesLength == 0) { in usearch_next()
3246 setColEIterOffset(strsrch->textIter, search->matchedIndex); in usearch_next()
3256 ucol_setOffset(strsrch->textIter, offset + 1, status); in usearch_next()
3259 ucol_setOffset(strsrch->textIter, in usearch_next()
3273 usearch_handleNextCanonical(strsrch, status); in usearch_next()
3276 usearch_handleNextExact(strsrch, status); in usearch_next()
3286 ucol_setOffset(strsrch->textIter, search->textLength, status); in usearch_next()
3288 ucol_setOffset(strsrch->textIter, search->matchedIndex, status); in usearch_next()
3298 U_CAPI int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch, in usearch_previous() argument
3301 if (U_SUCCESS(*status) && strsrch) { in usearch_previous()
3303 USearch *search = strsrch->search; in usearch_previous()
3308 setColEIterOffset(strsrch->textIter, offset); in usearch_previous()
3311 offset = usearch_getOffset(strsrch); in usearch_previous()
3330 (offset < strsrch->pattern.defaultShiftSize || in usearch_previous()
3332 matchedindex < strsrch->pattern.defaultShiftSize)))) { in usearch_previous()
3334 setMatchNotFound(strsrch); in usearch_previous()
3341 setMatchNotFound(strsrch); in usearch_previous()
3348 if (strsrch->pattern.cesLength == 0) { in usearch_previous()
3352 setMatchNotFound(strsrch); in usearch_previous()
3357 setColEIterOffset(strsrch->textIter, search->matchedIndex); in usearch_previous()
3363 if (strsrch->search->isCanonicalMatch) { in usearch_previous()
3365 usearch_handlePreviousCanonical(strsrch, status); in usearch_previous()
3369 usearch_handlePreviousExact(strsrch, status); in usearch_previous()
3386 U_CAPI void U_EXPORT2 usearch_reset(UStringSearch *strsrch) in usearch_reset() argument
3393 if (strsrch) { in usearch_reset()
3401 UCollationStrength newStrength = ucol_getStrength(strsrch->collator); in usearch_reset()
3402 if ((strsrch->strength < UCOL_QUATERNARY && newStrength >= UCOL_QUATERNARY) || in usearch_reset()
3403 (strsrch->strength >= UCOL_QUATERNARY && newStrength < UCOL_QUATERNARY)) { in usearch_reset()
3407 strsrch->strength = ucol_getStrength(strsrch->collator); in usearch_reset()
3408 ceMask = getMask(strsrch->strength); in usearch_reset()
3409 if (strsrch->ceMask != ceMask) { in usearch_reset()
3410 strsrch->ceMask = ceMask; in usearch_reset()
3415 shift = ucol_getAttribute(strsrch->collator, UCOL_ALTERNATE_HANDLING, in usearch_reset()
3417 if (strsrch->toShift != shift) { in usearch_reset()
3418 strsrch->toShift = shift; in usearch_reset()
3423 varTop = ucol_getVariableTop(strsrch->collator, &status); in usearch_reset()
3424 if (strsrch->variableTop != varTop) { in usearch_reset()
3425 strsrch->variableTop = varTop; in usearch_reset()
3429 initialize(strsrch, &status); in usearch_reset()
3431 ucol_setText(strsrch->textIter, strsrch->search->text, in usearch_reset()
3432 strsrch->search->textLength, in usearch_reset()
3434 strsrch->search->matchedLength = 0; in usearch_reset()
3435 strsrch->search->matchedIndex = USEARCH_DONE; in usearch_reset()
3436 strsrch->search->isOverlap = FALSE; in usearch_reset()
3437 strsrch->search->isCanonicalMatch = FALSE; in usearch_reset()
3438 strsrch->search->elementComparisonType = 0; in usearch_reset()
3439 strsrch->search->isForwardSearching = TRUE; in usearch_reset()
3440 strsrch->search->reset = TRUE; in usearch_reset()
3629 static int32_t nextBoundaryAfter(UStringSearch *strsrch, int32_t startIndex) { in nextBoundaryAfter() argument
3631 const UChar *text = strsrch->search->text; in nextBoundaryAfter()
3632 int32_t textLen = strsrch->search->textLength; in nextBoundaryAfter()
3668 UBreakIterator *breakiterator = strsrch->search->breakIter; in nextBoundaryAfter()
3671 breakiterator = strsrch->search->internalBreakIter; in nextBoundaryAfter()
3691 static UBool isBreakBoundary(UStringSearch *strsrch, int32_t index) { in isBreakBoundary() argument
3693 const UChar *text = strsrch->search->text; in isBreakBoundary()
3694 int32_t textLen = strsrch->search->textLength; in isBreakBoundary()
3719 UBreakIterator *breakiterator = strsrch->search->breakIter; in isBreakBoundary()
3722 breakiterator = strsrch->search->internalBreakIter; in isBreakBoundary()
3733 static UBool onBreakBoundaries(const UStringSearch *strsrch, int32_t start, int32_t end)
3736 UBreakIterator *breakiterator = strsrch->search->breakIter;
3842 U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch, in usearch_search() argument
3857 for (int ii=0; ii<strsrch->pattern.cesLength; ii++) { in usearch_search()
3858 printf(" %8x", strsrch->pattern.ces[ii]); in usearch_search()
3867 if(strsrch->pattern.cesLength == 0 || in usearch_search()
3869 startIdx > strsrch->search->textLength || in usearch_search()
3870 strsrch->pattern.ces == NULL) { in usearch_search()
3875 if (strsrch->pattern.pces == NULL) { in usearch_search()
3876 initializePatternPCETable(strsrch, status); in usearch_search()
3879 ucol_setOffset(strsrch->textIter, startIdx, status); in usearch_search()
3880 CEIBuffer ceb(strsrch, status); in usearch_search()
3926 for (patIx=0; patIx<strsrch->pattern.pcesLength; patIx++) { in usearch_search()
3927 patCE = strsrch->pattern.pces[patIx]; in usearch_search()
3932 …UCompareCEsResult ceMatch = compareCE64s(targetCEI->ce, patCE, strsrch->search->elementComparisonT… in usearch_search()
3947 …targetIxOffset += strsrch->pattern.pcesLength; // this is now the offset in target CE space to end… in usearch_search()
3979 if (strsrch->search->elementComparisonType == 0) { in usearch_search()
3997 …UCompareCEsResult ceMatch = compareCE64s(nextCEI->ce, patCE, strsrch->search->elementComparisonTyp… in usearch_search()
4021 if (!isBreakBoundary(strsrch, mStart)) { in usearch_search()
4047 if (strsrch->search->text != NULL && strsrch->search->textLength > maxLimit) { in usearch_search()
4049 strsrch->search->breakIter == NULL && in usearch_search()
4052 (strsrch->nfd->hasBoundaryBefore(codePointAt(*strsrch->search, maxLimit)) || in usearch_search()
4053 … strsrch->nfd->hasBoundaryAfter(codePointBefore(*strsrch->search, maxLimit))); in usearch_search()
4073 if (minLimit == lastCEI->highIndex && isBreakBoundary(strsrch, minLimit)) { in usearch_search()
4076 int32_t nba = nextBoundaryAfter(strsrch, minLimit); in usearch_search()
4099 if (!isBreakBoundary(strsrch, mLimit)) { in usearch_search()
4104 if (! checkIdentical(strsrch, mStart, mLimit)) { in usearch_search()
4142 U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch, in usearch_searchBackwards() argument
4157 for (int ii=0; ii<strsrch->pattern.cesLength; ii++) { in usearch_searchBackwards()
4158 printf(" %8x", strsrch->pattern.ces[ii]); in usearch_searchBackwards()
4167 if(strsrch->pattern.cesLength == 0 || in usearch_searchBackwards()
4169 startIdx > strsrch->search->textLength || in usearch_searchBackwards()
4170 strsrch->pattern.ces == NULL) { in usearch_searchBackwards()
4175 if (strsrch->pattern.pces == NULL) { in usearch_searchBackwards()
4176 initializePatternPCETable(strsrch, status); in usearch_searchBackwards()
4179 CEIBuffer ceb(strsrch, status); in usearch_searchBackwards()
4191 if (startIdx < strsrch->search->textLength) { in usearch_searchBackwards()
4192 UBreakIterator *bi = strsrch->search->internalBreakIter; in usearch_searchBackwards()
4195 ucol_setOffset(strsrch->textIter, next, status); in usearch_searchBackwards()
4203 ucol_setOffset(strsrch->textIter, startIdx, status); in usearch_searchBackwards()
4240 for (patIx = strsrch->pattern.pcesLength - 1; patIx >= 0; patIx -= 1) { in usearch_searchBackwards()
4241 int64_t patCE = strsrch->pattern.pces[patIx]; in usearch_searchBackwards()
4243 … targetCEI = ceb.getPrevious(targetIx + strsrch->pattern.pcesLength - 1 - patIx + targetIxOffset); in usearch_searchBackwards()
4247 …UCompareCEsResult ceMatch = compareCE64s(targetCEI->ce, patCE, strsrch->search->elementComparisonT… in usearch_searchBackwards()
4279 …const CEI *firstCEI = ceb.getPrevious(targetIx + strsrch->pattern.pcesLength - 1 + targetIxOffset); in usearch_searchBackwards()
4288 if (!isBreakBoundary(strsrch, mStart)) { in usearch_searchBackwards()
4330 if (strsrch->search->text != NULL && strsrch->search->textLength > maxLimit) { in usearch_searchBackwards()
4332 strsrch->search->breakIter == NULL && in usearch_searchBackwards()
4335 (strsrch->nfd->hasBoundaryBefore(codePointAt(*strsrch->search, maxLimit)) || in usearch_searchBackwards()
4336 … strsrch->nfd->hasBoundaryAfter(codePointBefore(*strsrch->search, maxLimit))); in usearch_searchBackwards()
4349 int32_t nba = nextBoundaryAfter(strsrch, minLimit); in usearch_searchBackwards()
4366 if (!isBreakBoundary(strsrch, mLimit)) { in usearch_searchBackwards()
4376 int32_t nba = nextBoundaryAfter(strsrch, minLimit); in usearch_searchBackwards()
4387 if (! checkIdentical(strsrch, mStart, mLimit)) { in usearch_searchBackwards()
4427 UBool usearch_handleNextExact(UStringSearch *strsrch, UErrorCode *status) in usearch_handleNextExact() argument
4430 setMatchNotFound(strsrch); in usearch_handleNextExact()
4435 UCollationElements *coleiter = strsrch->textIter; in usearch_handleNextExact()
4436 int32_t textlength = strsrch->search->textLength; in usearch_handleNextExact()
4437 int32_t *patternce = strsrch->pattern.ces; in usearch_handleNextExact()
4438 int32_t patterncelength = strsrch->pattern.cesLength; in usearch_handleNextExact()
4444 textoffset = shiftForward(strsrch, textoffset, UCOL_NULLORDER, in usearch_handleNextExact()
4464 targetce = getCE(strsrch, targetce); in usearch_handleNextExact()
4494 targetce = getCE(strsrch, targetce); in usearch_handleNextExact()
4510 textoffset = shiftForward(strsrch, textoffset, lastce, in usearch_handleNextExact()
4517 if (checkNextExactMatch(strsrch, &textoffset, status)) { in usearch_handleNextExact()
4519 setColEIterOffset(coleiter, strsrch->search->matchedIndex); in usearch_handleNextExact()
4523 setMatchNotFound(strsrch); in usearch_handleNextExact()
4526 int32_t textOffset = ucol_getOffset(strsrch->textIter); in usearch_handleNextExact()
4530 if (usearch_search(strsrch, textOffset, &start, &end, status)) { in usearch_handleNextExact()
4531 strsrch->search->matchedIndex = start; in usearch_handleNextExact()
4532 strsrch->search->matchedLength = end - start; in usearch_handleNextExact()
4535 setMatchNotFound(strsrch); in usearch_handleNextExact()
4541 UBool usearch_handleNextCanonical(UStringSearch *strsrch, UErrorCode *status) in usearch_handleNextCanonical() argument
4544 setMatchNotFound(strsrch); in usearch_handleNextCanonical()
4549 UCollationElements *coleiter = strsrch->textIter; in usearch_handleNextCanonical()
4550 int32_t textlength = strsrch->search->textLength; in usearch_handleNextCanonical()
4551 int32_t *patternce = strsrch->pattern.ces; in usearch_handleNextCanonical()
4552 int32_t patterncelength = strsrch->pattern.cesLength; in usearch_handleNextCanonical()
4555 strsrch->pattern.hasSuffixAccents || strsrch->pattern.hasPrefixAccents; in usearch_handleNextCanonical()
4557 textoffset = shiftForward(strsrch, textoffset, UCOL_NULLORDER, in usearch_handleNextCanonical()
4559 strsrch->canonicalPrefixAccents[0] = 0; in usearch_handleNextCanonical()
4560 strsrch->canonicalSuffixAccents[0] = 0; in usearch_handleNextCanonical()
4580 targetce = getCE(strsrch, targetce); in usearch_handleNextCanonical()
4602 targetce = getCE(strsrch, targetce); in usearch_handleNextCanonical()
4614 strsrch->canonicalPrefixAccents[0] = 0; in usearch_handleNextCanonical()
4615 strsrch->canonicalSuffixAccents[0] = 0; in usearch_handleNextCanonical()
4619 found = doNextCanonicalMatch(strsrch, textoffset, status); in usearch_handleNextCanonical()
4626 textoffset = shiftForward(strsrch, textoffset, lastce, in usearch_handleNextCanonical()
4633 if (checkNextCanonicalMatch(strsrch, &textoffset, status)) { in usearch_handleNextCanonical()
4634 setColEIterOffset(coleiter, strsrch->search->matchedIndex); in usearch_handleNextCanonical()
4638 setMatchNotFound(strsrch); in usearch_handleNextCanonical()
4641 int32_t textOffset = ucol_getOffset(strsrch->textIter); in usearch_handleNextCanonical()
4645 if (usearch_search(strsrch, textOffset, &start, &end, status)) { in usearch_handleNextCanonical()
4646 strsrch->search->matchedIndex = start; in usearch_handleNextCanonical()
4647 strsrch->search->matchedLength = end - start; in usearch_handleNextCanonical()
4650 setMatchNotFound(strsrch); in usearch_handleNextCanonical()
4656 UBool usearch_handlePreviousExact(UStringSearch *strsrch, UErrorCode *status) in usearch_handlePreviousExact() argument
4659 setMatchNotFound(strsrch); in usearch_handlePreviousExact()
4664 UCollationElements *coleiter = strsrch->textIter; in usearch_handlePreviousExact()
4665 int32_t *patternce = strsrch->pattern.ces; in usearch_handlePreviousExact()
4666 int32_t patterncelength = strsrch->pattern.cesLength; in usearch_handlePreviousExact()
4672 if (strsrch->search->matchedIndex != USEARCH_DONE) { in usearch_handlePreviousExact()
4673 textoffset = strsrch->search->matchedIndex; in usearch_handlePreviousExact()
4676 textoffset = reverseShift(strsrch, textoffset, UCOL_NULLORDER, in usearch_handlePreviousExact()
4699 targetce = getCE(strsrch, targetce); in usearch_handlePreviousExact()
4703 if (targetce == UCOL_IGNORABLE && strsrch->strength != UCOL_PRIMARY) { in usearch_handlePreviousExact()
4727 targetce = getCE(strsrch, targetce); in usearch_handlePreviousExact()
4744 textoffset = reverseShift(strsrch, textoffset, targetce, in usearch_handlePreviousExact()
4750 if (checkPreviousExactMatch(strsrch, &textoffset, status)) { in usearch_handlePreviousExact()
4755 setMatchNotFound(strsrch); in usearch_handlePreviousExact()
4760 if (strsrch->search->isOverlap) { in usearch_handlePreviousExact()
4761 if (strsrch->search->matchedIndex != USEARCH_DONE) { in usearch_handlePreviousExact()
4762 textOffset = strsrch->search->matchedIndex + strsrch->search->matchedLength - 1; in usearch_handlePreviousExact()
4765 initializePatternPCETable(strsrch, status); in usearch_handlePreviousExact()
4766 if (!initTextProcessedIter(strsrch, status)) { in usearch_handlePreviousExact()
4767 setMatchNotFound(strsrch); in usearch_handlePreviousExact()
4770 for (int32_t nPCEs = 0; nPCEs < strsrch->pattern.pcesLength - 1; nPCEs++) { in usearch_handlePreviousExact()
4771 int64_t pce = strsrch->textProcessedIter->nextProcessed(NULL, NULL, status); in usearch_handlePreviousExact()
4778 setMatchNotFound(strsrch); in usearch_handlePreviousExact()
4781 textOffset = ucol_getOffset(strsrch->textIter); in usearch_handlePreviousExact()
4784 textOffset = ucol_getOffset(strsrch->textIter); in usearch_handlePreviousExact()
4790 if (usearch_searchBackwards(strsrch, textOffset, &start, &end, status)) { in usearch_handlePreviousExact()
4791 strsrch->search->matchedIndex = start; in usearch_handlePreviousExact()
4792 strsrch->search->matchedLength = end - start; in usearch_handlePreviousExact()
4795 setMatchNotFound(strsrch); in usearch_handlePreviousExact()
4801 UBool usearch_handlePreviousCanonical(UStringSearch *strsrch, in usearch_handlePreviousCanonical() argument
4805 setMatchNotFound(strsrch); in usearch_handlePreviousCanonical()
4810 UCollationElements *coleiter = strsrch->textIter; in usearch_handlePreviousCanonical()
4811 int32_t *patternce = strsrch->pattern.ces; in usearch_handlePreviousCanonical()
4812 int32_t patterncelength = strsrch->pattern.cesLength; in usearch_handlePreviousCanonical()
4815 strsrch->pattern.hasSuffixAccents || strsrch->pattern.hasPrefixAccents; in usearch_handlePreviousCanonical()
4820 if (strsrch->search->matchedIndex != USEARCH_DONE) { in usearch_handlePreviousCanonical()
4821 textoffset = strsrch->search->matchedIndex; in usearch_handlePreviousCanonical()
4824 textoffset = reverseShift(strsrch, textoffset, UCOL_NULLORDER, in usearch_handlePreviousCanonical()
4826 strsrch->canonicalPrefixAccents[0] = 0; in usearch_handlePreviousCanonical()
4827 strsrch->canonicalSuffixAccents[0] = 0; in usearch_handlePreviousCanonical()
4847 targetce = getCE(strsrch, targetce); in usearch_handlePreviousCanonical()
4873 targetce = getCE(strsrch, targetce); in usearch_handlePreviousCanonical()
4885 strsrch->canonicalPrefixAccents[0] = 0; in usearch_handlePreviousCanonical()
4886 strsrch->canonicalSuffixAccents[0] = 0; in usearch_handlePreviousCanonical()
4890 found = doPreviousCanonicalMatch(strsrch, textoffset, status); in usearch_handlePreviousCanonical()
4897 textoffset = reverseShift(strsrch, textoffset, targetce, in usearch_handlePreviousCanonical()
4903 if (checkPreviousCanonicalMatch(strsrch, &textoffset, status)) { in usearch_handlePreviousCanonical()
4908 setMatchNotFound(strsrch); in usearch_handlePreviousCanonical()
4913 if (strsrch->search->isOverlap) { in usearch_handlePreviousCanonical()
4914 if (strsrch->search->matchedIndex != USEARCH_DONE) { in usearch_handlePreviousCanonical()
4915 textOffset = strsrch->search->matchedIndex + strsrch->search->matchedLength - 1; in usearch_handlePreviousCanonical()
4918 initializePatternPCETable(strsrch, status); in usearch_handlePreviousCanonical()
4919 if (!initTextProcessedIter(strsrch, status)) { in usearch_handlePreviousCanonical()
4920 setMatchNotFound(strsrch); in usearch_handlePreviousCanonical()
4923 for (int32_t nPCEs = 0; nPCEs < strsrch->pattern.pcesLength - 1; nPCEs++) { in usearch_handlePreviousCanonical()
4924 int64_t pce = strsrch->textProcessedIter->nextProcessed(NULL, NULL, status); in usearch_handlePreviousCanonical()
4931 setMatchNotFound(strsrch); in usearch_handlePreviousCanonical()
4934 textOffset = ucol_getOffset(strsrch->textIter); in usearch_handlePreviousCanonical()
4937 textOffset = ucol_getOffset(strsrch->textIter); in usearch_handlePreviousCanonical()
4943 if (usearch_searchBackwards(strsrch, textOffset, &start, &end, status)) { in usearch_handlePreviousCanonical()
4944 strsrch->search->matchedIndex = start; in usearch_handlePreviousCanonical()
4945 strsrch->search->matchedLength = end - start; in usearch_handlePreviousCanonical()
4948 setMatchNotFound(strsrch); in usearch_handlePreviousCanonical()