Lines Matching refs:strsrch
147 inline int32_t getCE(const UStringSearch *strsrch, uint32_t sourcece) in getCE() argument
152 sourcece &= strsrch->ceMask; in getCE()
154 if (strsrch->toShift) { in getCE()
160 if (strsrch->variableTop > sourcece) { in getCE()
161 if (strsrch->strength >= UCOL_QUATERNARY) { in getCE()
168 } else if (strsrch->strength >= UCOL_QUATERNARY && sourcece == UCOL_IGNORABLE) { in getCE()
290 inline uint16_t initializePatternCETable(UStringSearch *strsrch, in initializePatternCETable() argument
293 UPattern *pattern = &(strsrch->pattern); in initializePatternCETable()
297 UCollationElements *coleiter = strsrch->utilIter; in initializePatternCETable()
300 coleiter = ucol_openElements(strsrch->collator, pattern->text, in initializePatternCETable()
305 strsrch->utilIter = coleiter; in initializePatternCETable()
324 uint32_t newce = getCE(strsrch, ce); in initializePatternCETable()
362 inline uint16_t initializePatternPCETable(UStringSearch *strsrch, in initializePatternPCETable() argument
365 UPattern *pattern = &(strsrch->pattern); in initializePatternPCETable()
369 UCollationElements *coleiter = strsrch->utilIter; in initializePatternPCETable()
372 coleiter = ucol_openElements(strsrch->collator, pattern->text, in initializePatternPCETable()
377 strsrch->utilIter = coleiter; in initializePatternPCETable()
435 inline int16_t initializePattern(UStringSearch *strsrch, UErrorCode *status) in initializePattern() argument
438 UPattern *pattern = &(strsrch->pattern); in initializePattern()
444 if (strsrch->strength == UCOL_PRIMARY) { in initializePattern()
457 if (strsrch->pattern.pces != NULL) { in initializePattern()
458 if (strsrch->pattern.pces != strsrch->pattern.pcesBuffer) { in initializePattern()
459 uprv_free(strsrch->pattern.pces); in initializePattern()
462 strsrch->pattern.pces = NULL; in initializePattern()
466 return initializePatternCETable(strsrch, status); in initializePattern()
546 inline void initialize(UStringSearch *strsrch, UErrorCode *status) in initialize() argument
548 int16_t expandlength = initializePattern(strsrch, status); in initialize()
549 if (U_SUCCESS(*status) && strsrch->pattern.cesLength > 0) { in initialize()
550 UPattern *pattern = &strsrch->pattern; in initialize()
560 strsrch->pattern.defaultShiftSize = 0; in initialize()
572 void checkBreakBoundary(const UStringSearch *strsrch, int32_t * /*start*/, in checkBreakBoundary() argument
576 UBreakIterator *breakiterator = strsrch->search->internalBreakIter; in checkBreakBoundary()
603 UBool isBreakUnit(const UStringSearch *strsrch, int32_t start, in isBreakUnit() argument
607 UBreakIterator *breakiterator = strsrch->search->breakIter; in isBreakUnit()
627 UCollationElements *coleiter = strsrch->utilIter; in isBreakUnit()
628 const UChar *text = strsrch->search->text + in isBreakUnit()
632 for (int32_t count = 0; count < strsrch->pattern.cesLength; in isBreakUnit()
634 int32_t ce = getCE(strsrch, ucol_next(coleiter, &status)); in isBreakUnit()
639 if (U_FAILURE(status) || ce != strsrch->pattern.ces[count]) { in isBreakUnit()
645 && getCE(strsrch, nextce) == UCOL_IGNORABLE) { in isBreakUnit()
701 inline int32_t getNextUStringSearchBaseOffset(UStringSearch *strsrch, in getNextUStringSearchBaseOffset() argument
704 int32_t textlength = strsrch->search->textLength; in getNextUStringSearchBaseOffset()
705 if (strsrch->pattern.hasSuffixAccents && in getNextUStringSearchBaseOffset()
708 const UChar *text = strsrch->search->text; in getNextUStringSearchBaseOffset()
730 inline int32_t shiftForward(UStringSearch *strsrch, in shiftForward() argument
735 UPattern *pattern = &(strsrch->pattern); in shiftForward()
750 textoffset = getNextUStringSearchBaseOffset(strsrch, textoffset); in shiftForward()
766 inline void setMatchNotFound(UStringSearch *strsrch) in setMatchNotFound() argument
769 strsrch->search->matchedIndex = USEARCH_DONE; in setMatchNotFound()
770 strsrch->search->matchedLength = 0; in setMatchNotFound()
771 if (strsrch->search->isForwardSearching) { in setMatchNotFound()
772 setColEIterOffset(strsrch->textIter, strsrch->search->textLength); in setMatchNotFound()
775 setColEIterOffset(strsrch->textIter, 0); in setMatchNotFound()
829 UBool checkExtraMatchAccents(const UStringSearch *strsrch, int32_t start, in checkExtraMatchAccents() argument
834 if (strsrch->pattern.hasPrefixAccents) { in checkExtraMatchAccents()
837 const UChar *text = strsrch->search->text + start; in checkExtraMatchAccents()
842 int32_t safeoffset = getNextSafeOffset(strsrch->collator, in checkExtraMatchAccents()
872 UCollationElements *coleiter = strsrch->utilIter; in checkExtraMatchAccents()
874 uint32_t firstce = strsrch->pattern.ces[0]; in checkExtraMatchAccents()
919 UBool hasAccentsBeforeMatch(const UStringSearch *strsrch, int32_t start, in hasAccentsBeforeMatch() argument
922 if (strsrch->pattern.hasPrefixAccents) { in hasAccentsBeforeMatch()
923 UCollationElements *coleiter = strsrch->textIter; in hasAccentsBeforeMatch()
927 int32_t firstce = strsrch->pattern.ces[0]; in hasAccentsBeforeMatch()
930 int32_t ce = getCE(strsrch, ucol_next(coleiter, &status)); in hasAccentsBeforeMatch()
938 ce = getCE(strsrch, ucol_next(coleiter, &status)); in hasAccentsBeforeMatch()
957 UBool accent = getFCD(strsrch->search->text, &temp, in hasAccentsBeforeMatch()
958 strsrch->search->textLength) > 0xFF; in hasAccentsBeforeMatch()
960 return checkExtraMatchAccents(strsrch, start, end, &status); in hasAccentsBeforeMatch()
967 U16_BACK_1(strsrch->search->text, 0, temp); in hasAccentsBeforeMatch()
968 if (getFCD(strsrch->search->text, &temp, in hasAccentsBeforeMatch()
969 strsrch->search->textLength) & LAST_BYTE_MASK_) { in hasAccentsBeforeMatch()
1000 UBool hasAccentsAfterMatch(const UStringSearch *strsrch, int32_t start, in hasAccentsAfterMatch() argument
1003 if (strsrch->pattern.hasSuffixAccents) { in hasAccentsAfterMatch()
1004 const UChar *text = strsrch->search->text; in hasAccentsAfterMatch()
1006 int32_t textlength = strsrch->search->textLength; in hasAccentsAfterMatch()
1009 int32_t firstce = strsrch->pattern.ces[0]; in hasAccentsAfterMatch()
1010 UCollationElements *coleiter = strsrch->textIter; in hasAccentsAfterMatch()
1014 while ((ce = getCE(strsrch, ucol_next(coleiter, &status))) != firstce) { in hasAccentsAfterMatch()
1020 while (count < strsrch->pattern.cesLength) { in hasAccentsAfterMatch()
1021 if (getCE(strsrch, ucol_next(coleiter, &status)) in hasAccentsAfterMatch()
1037 ce = getCE(strsrch, ce); in hasAccentsAfterMatch()
1073 inline UBool checkIdentical(const UStringSearch *strsrch, int32_t start, in checkIdentical() argument
1076 if (strsrch->strength != UCOL_IDENTICAL) { in checkIdentical()
1084 strsrch->nfd->normalize( in checkIdentical()
1085 UnicodeString(FALSE, strsrch->search->text + start, end - start), t2, status); in checkIdentical()
1086 strsrch->nfd->normalize( in checkIdentical()
1087 UnicodeString(FALSE, strsrch->pattern.text, strsrch->pattern.textLength), p2, status); in checkIdentical()
1101 inline UBool checkRepeatedMatch(UStringSearch *strsrch, in checkRepeatedMatch() argument
1105 int32_t lastmatchindex = strsrch->search->matchedIndex; in checkRepeatedMatch()
1110 if (strsrch->search->isForwardSearching) { in checkRepeatedMatch()
1116 if (!result && !strsrch->search->isOverlap) { in checkRepeatedMatch()
1117 if (strsrch->search->isForwardSearching) { in checkRepeatedMatch()
1118 result = start < lastmatchindex + strsrch->search->matchedLength; in checkRepeatedMatch()
1161 UBool checkNextExactContractionMatch(UStringSearch *strsrch, in checkNextExactContractionMatch() argument
1165 UCollationElements *coleiter = strsrch->textIter; in checkNextExactContractionMatch()
1166 int32_t textlength = strsrch->search->textLength; in checkNextExactContractionMatch()
1168 const UCollator *collator = strsrch->collator; in checkNextExactContractionMatch()
1169 const UChar *text = strsrch->search->text; in checkNextExactContractionMatch()
1204 int32_t *patternce = strsrch->pattern.ces; in checkNextExactContractionMatch()
1205 int32_t patterncelength = strsrch->pattern.cesLength; in checkNextExactContractionMatch()
1208 int32_t ce = getCE(strsrch, ucol_next(coleiter, status)); in checkNextExactContractionMatch()
1218 *end = getNextUStringSearchBaseOffset(strsrch, *end); in checkNextExactContractionMatch()
1248 inline UBool checkNextExactMatch(UStringSearch *strsrch, in checkNextExactMatch() argument
1251 UCollationElements *coleiter = strsrch->textIter; in checkNextExactMatch()
1254 if (!checkNextExactContractionMatch(strsrch, &start, textoffset, status)) { in checkNextExactMatch()
1259 if (!isBreakUnit(strsrch, start, *textoffset) || in checkNextExactMatch()
1260 checkRepeatedMatch(strsrch, start, *textoffset) || in checkNextExactMatch()
1261 hasAccentsBeforeMatch(strsrch, start, *textoffset) || in checkNextExactMatch()
1262 !checkIdentical(strsrch, start, *textoffset) || in checkNextExactMatch()
1263 hasAccentsAfterMatch(strsrch, start, *textoffset)) { in checkNextExactMatch()
1266 *textoffset = getNextUStringSearchBaseOffset(strsrch, *textoffset); in checkNextExactMatch()
1271 if (!strsrch->search->breakIter && strsrch->strength == UCOL_PRIMARY) { in checkNextExactMatch()
1272 checkBreakBoundary(strsrch, &start, textoffset); in checkNextExactMatch()
1276 strsrch->search->matchedIndex = start; in checkNextExactMatch()
1277 strsrch->search->matchedLength = *textoffset - start; in checkNextExactMatch()
1404 inline UBool checkCollationMatch(const UStringSearch *strsrch, in checkCollationMatch() argument
1407 int patternceindex = strsrch->pattern.cesLength; in checkCollationMatch()
1408 int32_t *patternce = strsrch->pattern.ces; in checkCollationMatch()
1411 int32_t ce = getCE(strsrch, ucol_next(coleiter, &status)); in checkCollationMatch()
1444 int32_t doNextCanonicalPrefixMatch(UStringSearch *strsrch, in doNextCanonicalPrefixMatch() argument
1449 const UChar *text = strsrch->search->text; in doNextCanonicalPrefixMatch()
1450 int32_t textlength = strsrch->search->textLength; in doNextCanonicalPrefixMatch()
1474 UCollationElements *coleiter = strsrch->utilIter; in doNextCanonicalPrefixMatch()
1476 UChar *rearrange = strsrch->canonicalPrefixAccents; in doNextCanonicalPrefixMatch()
1494 strsrch->canonicalPrefixAccents, in doNextCanonicalPrefixMatch()
1495 strsrch->search->text + offset, in doNextCanonicalPrefixMatch()
1497 strsrch->canonicalSuffixAccents, in doNextCanonicalPrefixMatch()
1504 if (checkCollationMatch(strsrch, coleiter)) { in doNextCanonicalPrefixMatch()
1550 inline void cleanUpSafeText(const UStringSearch *strsrch, UChar *safetext, in cleanUpSafeText() argument
1553 if (safetext != safebuffer && safetext != strsrch->canonicalSuffixAccents) in cleanUpSafeText()
1575 int32_t doNextCanonicalSuffixMatch(UStringSearch *strsrch, in doNextCanonicalSuffixMatch() argument
1579 const UChar *text = strsrch->search->text; in doNextCanonicalSuffixMatch()
1580 const UCollator *collator = strsrch->collator; in doNextCanonicalSuffixMatch()
1585 UCollationElements *coleiter = strsrch->utilIter; in doNextCanonicalSuffixMatch()
1588 if (textoffset != 0 && ucol_unsafeCP(strsrch->canonicalSuffixAccents[0], in doNextCanonicalSuffixMatch()
1595 strsrch->canonicalSuffixAccents, in doNextCanonicalSuffixMatch()
1599 safetextlength = u_strlen(strsrch->canonicalSuffixAccents); in doNextCanonicalSuffixMatch()
1600 safetext = strsrch->canonicalSuffixAccents; in doNextCanonicalSuffixMatch()
1607 int32_t *ce = strsrch->pattern.ces; in doNextCanonicalSuffixMatch()
1608 int32_t celength = strsrch->pattern.cesLength; in doNextCanonicalSuffixMatch()
1616 cleanUpSafeText(strsrch, safetext, safebuffer); in doNextCanonicalSuffixMatch()
1622 if (coleiter == strsrch->textIter) { in doNextCanonicalSuffixMatch()
1623 cleanUpSafeText(strsrch, safetext, safebuffer); in doNextCanonicalSuffixMatch()
1626 cleanUpSafeText(strsrch, safetext, safebuffer); in doNextCanonicalSuffixMatch()
1628 coleiter = strsrch->textIter; in doNextCanonicalSuffixMatch()
1634 textce = getCE(strsrch, textce); in doNextCanonicalSuffixMatch()
1640 cleanUpSafeText(strsrch, safetext, safebuffer); in doNextCanonicalSuffixMatch()
1646 cleanUpSafeText(strsrch, safetext, safebuffer); in doNextCanonicalSuffixMatch()
1650 int32_t result = doNextCanonicalPrefixMatch(strsrch, in doNextCanonicalSuffixMatch()
1654 setColEIterOffset(strsrch->textIter, result); in doNextCanonicalSuffixMatch()
1671 cleanUpSafeText(strsrch, safetext, safebuffer); in doNextCanonicalSuffixMatch()
1678 setColEIterOffset(strsrch->textIter, result); in doNextCanonicalSuffixMatch()
1679 strsrch->textIter->iteratordata_.toReturn = in doNextCanonicalSuffixMatch()
1680 setExpansionPrefix(strsrch->textIter, leftoverces); in doNextCanonicalSuffixMatch()
1708 UBool doNextCanonicalMatch(UStringSearch *strsrch, in doNextCanonicalMatch() argument
1712 const UChar *text = strsrch->search->text; in doNextCanonicalMatch()
1716 UCollationElements *coleiter = strsrch->textIter; in doNextCanonicalMatch()
1718 if (strsrch->pattern.hasPrefixAccents) { in doNextCanonicalMatch()
1719 offset = doNextCanonicalPrefixMatch(strsrch, offset, textoffset, in doNextCanonicalMatch()
1729 if (!strsrch->pattern.hasSuffixAccents) { in doNextCanonicalMatch()
1747 UChar *rearrange = strsrch->canonicalSuffixAccents; in doNextCanonicalMatch()
1763 int32_t offset = doNextCanonicalSuffixMatch(strsrch, baseoffset, in doNextCanonicalMatch()
1782 inline int32_t getPreviousUStringSearchBaseOffset(UStringSearch *strsrch, in getPreviousUStringSearchBaseOffset() argument
1785 if (strsrch->pattern.hasPrefixAccents && textoffset > 0) { in getPreviousUStringSearchBaseOffset()
1786 const UChar *text = strsrch->search->text; in getPreviousUStringSearchBaseOffset()
1788 if (getFCD(text, &offset, strsrch->search->textLength) >> in getPreviousUStringSearchBaseOffset()
1810 UBool checkNextCanonicalContractionMatch(UStringSearch *strsrch, in checkNextCanonicalContractionMatch() argument
1815 UCollationElements *coleiter = strsrch->textIter; in checkNextCanonicalContractionMatch()
1816 int32_t textlength = strsrch->search->textLength; in checkNextCanonicalContractionMatch()
1818 const UCollator *collator = strsrch->collator; in checkNextCanonicalContractionMatch()
1819 const UChar *text = strsrch->search->text; in checkNextCanonicalContractionMatch()
1847 int32_t *patternce = strsrch->pattern.ces; in checkNextCanonicalContractionMatch()
1848 int32_t patterncelength = strsrch->pattern.cesLength; in checkNextCanonicalContractionMatch()
1850 int32_t textlength = strsrch->search->textLength; in checkNextCanonicalContractionMatch()
1852 int32_t ce = getCE(strsrch, ucol_next(coleiter, status)); in checkNextCanonicalContractionMatch()
1869 ce = getCE(strsrch, ucol_next(coleiter, status)); in checkNextCanonicalContractionMatch()
1873 ce = getCE(strsrch, ucol_next(coleiter, status)); in checkNextCanonicalContractionMatch()
1879 *end = getNextUStringSearchBaseOffset(strsrch, *end); in checkNextCanonicalContractionMatch()
1908 inline UBool checkNextCanonicalMatch(UStringSearch *strsrch, in checkNextCanonicalMatch() argument
1913 UCollationElements *coleiter = strsrch->textIter; in checkNextCanonicalMatch()
1915 if ((strsrch->pattern.hasSuffixAccents && in checkNextCanonicalMatch()
1916 strsrch->canonicalSuffixAccents[0]) || in checkNextCanonicalMatch()
1917 (strsrch->pattern.hasPrefixAccents && in checkNextCanonicalMatch()
1918 strsrch->canonicalPrefixAccents[0])) { in checkNextCanonicalMatch()
1919 strsrch->search->matchedIndex = getPreviousUStringSearchBaseOffset( in checkNextCanonicalMatch()
1920 strsrch, in checkNextCanonicalMatch()
1922 strsrch->search->matchedLength = *textoffset - in checkNextCanonicalMatch()
1923 strsrch->search->matchedIndex; in checkNextCanonicalMatch()
1928 if (!checkNextCanonicalContractionMatch(strsrch, &start, textoffset, in checkNextCanonicalMatch()
1933 start = getPreviousUStringSearchBaseOffset(strsrch, start); in checkNextCanonicalMatch()
1935 if (checkRepeatedMatch(strsrch, start, *textoffset) || in checkNextCanonicalMatch()
1936 !isBreakUnit(strsrch, start, *textoffset) || in checkNextCanonicalMatch()
1937 !checkIdentical(strsrch, start, *textoffset)) { in checkNextCanonicalMatch()
1939 *textoffset = getNextBaseOffset(strsrch->search->text, *textoffset, in checkNextCanonicalMatch()
1940 strsrch->search->textLength); in checkNextCanonicalMatch()
1944 strsrch->search->matchedIndex = start; in checkNextCanonicalMatch()
1945 strsrch->search->matchedLength = *textoffset - start; in checkNextCanonicalMatch()
1963 inline int32_t reverseShift(UStringSearch *strsrch, in reverseShift() argument
1968 if (strsrch->search->isOverlap) { in reverseShift()
1969 if (textoffset != strsrch->search->textLength) { in reverseShift()
1973 textoffset -= strsrch->pattern.defaultShiftSize; in reverseShift()
1978 int32_t shift = strsrch->pattern.backShift[hashFromCE32(ce)]; in reverseShift()
1989 textoffset -= strsrch->pattern.defaultShiftSize; in reverseShift()
1992 textoffset = getPreviousUStringSearchBaseOffset(strsrch, textoffset); in reverseShift()
2008 UBool checkPreviousExactContractionMatch(UStringSearch *strsrch, in checkPreviousExactContractionMatch() argument
2012 UCollationElements *coleiter = strsrch->textIter; in checkPreviousExactContractionMatch()
2013 int32_t textlength = strsrch->search->textLength; in checkPreviousExactContractionMatch()
2015 const UCollator *collator = strsrch->collator; in checkPreviousExactContractionMatch()
2016 const UChar *text = strsrch->search->text; in checkPreviousExactContractionMatch()
2045 int32_t *patternce = strsrch->pattern.ces; in checkPreviousExactContractionMatch()
2046 int32_t patterncelength = strsrch->pattern.cesLength; in checkPreviousExactContractionMatch()
2049 int32_t ce = getCE(strsrch, ucol_previous(coleiter, status)); in checkPreviousExactContractionMatch()
2094 inline UBool checkPreviousExactMatch(UStringSearch *strsrch, in checkPreviousExactMatch() argument
2099 int32_t end = ucol_getOffset(strsrch->textIter); in checkPreviousExactMatch()
2100 if (!checkPreviousExactContractionMatch(strsrch, textoffset, &end, status) in checkPreviousExactMatch()
2107 if (checkRepeatedMatch(strsrch, *textoffset, end) || in checkPreviousExactMatch()
2108 !isBreakUnit(strsrch, *textoffset, end) || in checkPreviousExactMatch()
2109 hasAccentsBeforeMatch(strsrch, *textoffset, end) || in checkPreviousExactMatch()
2110 !checkIdentical(strsrch, *textoffset, end) || in checkPreviousExactMatch()
2111 hasAccentsAfterMatch(strsrch, *textoffset, end)) { in checkPreviousExactMatch()
2113 *textoffset = getPreviousBaseOffset(strsrch->search->text, in checkPreviousExactMatch()
2119 if (!strsrch->search->breakIter && strsrch->strength == UCOL_PRIMARY) { in checkPreviousExactMatch()
2120 checkBreakBoundary(strsrch, textoffset, &end); in checkPreviousExactMatch()
2123 strsrch->search->matchedIndex = *textoffset; in checkPreviousExactMatch()
2124 strsrch->search->matchedLength = end - *textoffset; in checkPreviousExactMatch()
2148 int32_t doPreviousCanonicalSuffixMatch(UStringSearch *strsrch, in doPreviousCanonicalSuffixMatch() argument
2153 const UChar *text = strsrch->search->text; in doPreviousCanonicalSuffixMatch()
2157 if (!(getFCD(text, &tempend, strsrch->search->textLength) & in doPreviousCanonicalSuffixMatch()
2162 end = getNextBaseOffset(text, end, strsrch->search->textLength); in doPreviousCanonicalSuffixMatch()
2176 UCollationElements *coleiter = strsrch->utilIter; in doPreviousCanonicalSuffixMatch()
2178 UChar *rearrange = strsrch->canonicalSuffixAccents; in doPreviousCanonicalSuffixMatch()
2196 strsrch->canonicalPrefixAccents, in doPreviousCanonicalSuffixMatch()
2197 strsrch->search->text + start, in doPreviousCanonicalSuffixMatch()
2199 strsrch->canonicalSuffixAccents, in doPreviousCanonicalSuffixMatch()
2206 if (checkCollationMatch(strsrch, coleiter)) { in doPreviousCanonicalSuffixMatch()
2235 int32_t doPreviousCanonicalPrefixMatch(UStringSearch *strsrch, in doPreviousCanonicalPrefixMatch() argument
2239 const UChar *text = strsrch->search->text; in doPreviousCanonicalPrefixMatch()
2240 const UCollator *collator = strsrch->collator; in doPreviousCanonicalPrefixMatch()
2248 ucol_unsafeCP(strsrch->canonicalPrefixAccents[ in doPreviousCanonicalPrefixMatch()
2249 u_strlen(strsrch->canonicalPrefixAccents) - 1 in doPreviousCanonicalPrefixMatch()
2252 strsrch->search->textLength); in doPreviousCanonicalPrefixMatch()
2256 strsrch->canonicalPrefixAccents, in doPreviousCanonicalPrefixMatch()
2261 safetextlength = u_strlen(strsrch->canonicalPrefixAccents); in doPreviousCanonicalPrefixMatch()
2262 safetext = strsrch->canonicalPrefixAccents; in doPreviousCanonicalPrefixMatch()
2265 UCollationElements *coleiter = strsrch->utilIter; in doPreviousCanonicalPrefixMatch()
2270 int32_t *ce = strsrch->pattern.ces; in doPreviousCanonicalPrefixMatch()
2271 int32_t celength = strsrch->pattern.cesLength; in doPreviousCanonicalPrefixMatch()
2274 int32_t prefixlength = u_strlen(strsrch->canonicalPrefixAccents); in doPreviousCanonicalPrefixMatch()
2280 cleanUpSafeText(strsrch, safetext, safebuffer); in doPreviousCanonicalPrefixMatch()
2286 if (coleiter == strsrch->textIter) { in doPreviousCanonicalPrefixMatch()
2287 cleanUpSafeText(strsrch, safetext, safebuffer); in doPreviousCanonicalPrefixMatch()
2290 cleanUpSafeText(strsrch, safetext, safebuffer); in doPreviousCanonicalPrefixMatch()
2292 coleiter = strsrch->textIter; in doPreviousCanonicalPrefixMatch()
2298 textce = getCE(strsrch, textce); in doPreviousCanonicalPrefixMatch()
2304 cleanUpSafeText(strsrch, safetext, safebuffer); in doPreviousCanonicalPrefixMatch()
2310 cleanUpSafeText(strsrch, safetext, safebuffer); in doPreviousCanonicalPrefixMatch()
2314 int32_t result = doPreviousCanonicalSuffixMatch(strsrch, in doPreviousCanonicalPrefixMatch()
2318 setColEIterOffset(strsrch->textIter, result); in doPreviousCanonicalPrefixMatch()
2335 cleanUpSafeText(strsrch, safetext, safebuffer); in doPreviousCanonicalPrefixMatch()
2342 setColEIterOffset(strsrch->textIter, result); in doPreviousCanonicalPrefixMatch()
2343 setExpansionSuffix(strsrch->textIter, leftoverces); in doPreviousCanonicalPrefixMatch()
2371 UBool doPreviousCanonicalMatch(UStringSearch *strsrch, in doPreviousCanonicalMatch() argument
2375 const UChar *text = strsrch->search->text; in doPreviousCanonicalMatch()
2377 int32_t textlength = strsrch->search->textLength; in doPreviousCanonicalMatch()
2379 UCollationElements *coleiter = strsrch->textIter; in doPreviousCanonicalMatch()
2381 if (strsrch->pattern.hasSuffixAccents) { in doPreviousCanonicalMatch()
2382 offset = doPreviousCanonicalSuffixMatch(strsrch, textoffset, in doPreviousCanonicalMatch()
2392 if (!strsrch->pattern.hasPrefixAccents) { in doPreviousCanonicalMatch()
2410 UChar *rearrange = strsrch->canonicalPrefixAccents; in doPreviousCanonicalMatch()
2426 int32_t offset = doPreviousCanonicalPrefixMatch(strsrch, in doPreviousCanonicalMatch()
2448 UBool checkPreviousCanonicalContractionMatch(UStringSearch *strsrch, in checkPreviousCanonicalContractionMatch() argument
2452 UCollationElements *coleiter = strsrch->textIter; in checkPreviousCanonicalContractionMatch()
2453 int32_t textlength = strsrch->search->textLength; in checkPreviousCanonicalContractionMatch()
2455 const UCollator *collator = strsrch->collator; in checkPreviousCanonicalContractionMatch()
2456 const UChar *text = strsrch->search->text; in checkPreviousCanonicalContractionMatch()
2485 int32_t *patternce = strsrch->pattern.ces; in checkPreviousCanonicalContractionMatch()
2486 int32_t patterncelength = strsrch->pattern.cesLength; in checkPreviousCanonicalContractionMatch()
2489 int32_t ce = getCE(strsrch, ucol_previous(coleiter, status)); in checkPreviousCanonicalContractionMatch()
2507 ce = getCE(strsrch, ucol_previous(coleiter, status)); in checkPreviousCanonicalContractionMatch()
2511 ce = getCE(strsrch, ucol_previous(coleiter, status)); in checkPreviousCanonicalContractionMatch()
2546 inline UBool checkPreviousCanonicalMatch(UStringSearch *strsrch, in checkPreviousCanonicalMatch() argument
2551 UCollationElements *coleiter = strsrch->textIter; in checkPreviousCanonicalMatch()
2553 if ((strsrch->pattern.hasSuffixAccents && in checkPreviousCanonicalMatch()
2554 strsrch->canonicalSuffixAccents[0]) || in checkPreviousCanonicalMatch()
2555 (strsrch->pattern.hasPrefixAccents && in checkPreviousCanonicalMatch()
2556 strsrch->canonicalPrefixAccents[0])) { in checkPreviousCanonicalMatch()
2557 strsrch->search->matchedIndex = *textoffset; in checkPreviousCanonicalMatch()
2558 strsrch->search->matchedLength = in checkPreviousCanonicalMatch()
2559 getNextUStringSearchBaseOffset(strsrch, in checkPreviousCanonicalMatch()
2566 if (!checkPreviousCanonicalContractionMatch(strsrch, textoffset, &end, in checkPreviousCanonicalMatch()
2572 end = getNextUStringSearchBaseOffset(strsrch, end); in checkPreviousCanonicalMatch()
2574 if (checkRepeatedMatch(strsrch, *textoffset, end) || in checkPreviousCanonicalMatch()
2575 !isBreakUnit(strsrch, *textoffset, end) || in checkPreviousCanonicalMatch()
2576 !checkIdentical(strsrch, *textoffset, end)) { in checkPreviousCanonicalMatch()
2578 *textoffset = getPreviousBaseOffset(strsrch->search->text, in checkPreviousCanonicalMatch()
2583 strsrch->search->matchedIndex = *textoffset; in checkPreviousCanonicalMatch()
2584 strsrch->search->matchedLength = end - *textoffset; in checkPreviousCanonicalMatch()
2752 U_CAPI void U_EXPORT2 usearch_close(UStringSearch *strsrch) in usearch_close() argument
2754 if (strsrch) { in usearch_close()
2755 if (strsrch->pattern.ces != strsrch->pattern.cesBuffer && in usearch_close()
2756 strsrch->pattern.ces) { in usearch_close()
2757 uprv_free(strsrch->pattern.ces); in usearch_close()
2760 if (strsrch->pattern.pces != NULL && in usearch_close()
2761 strsrch->pattern.pces != strsrch->pattern.pcesBuffer) { in usearch_close()
2762 uprv_free(strsrch->pattern.pces); in usearch_close()
2765 delete strsrch->textProcessedIter; in usearch_close()
2766 ucol_closeElements(strsrch->textIter); in usearch_close()
2767 ucol_closeElements(strsrch->utilIter); in usearch_close()
2769 if (strsrch->ownCollator && strsrch->collator) { in usearch_close()
2770 ucol_close((UCollator *)strsrch->collator); in usearch_close()
2774 if (strsrch->search->internalBreakIter) { in usearch_close()
2775 ubrk_close(strsrch->search->internalBreakIter); in usearch_close()
2779 uprv_free(strsrch->search); in usearch_close()
2780 uprv_free(strsrch); in usearch_close()
2786 UBool initTextProcessedIter(UStringSearch *strsrch, UErrorCode *status) { in initTextProcessedIter() argument
2788 if (strsrch->textProcessedIter == NULL) { in initTextProcessedIter()
2789 strsrch->textProcessedIter = new icu::UCollationPCE(strsrch->textIter); in initTextProcessedIter()
2790 if (strsrch->textProcessedIter == NULL) { in initTextProcessedIter()
2795 strsrch->textProcessedIter->init(strsrch->textIter); in initTextProcessedIter()
2804 U_CAPI void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch, in usearch_setOffset() argument
2808 if (U_SUCCESS(*status) && strsrch) { in usearch_setOffset()
2809 if (isOutOfBounds(strsrch->search->textLength, position)) { in usearch_setOffset()
2813 setColEIterOffset(strsrch->textIter, position); in usearch_setOffset()
2815 strsrch->search->matchedIndex = USEARCH_DONE; in usearch_setOffset()
2816 strsrch->search->matchedLength = 0; in usearch_setOffset()
2817 strsrch->search->reset = FALSE; in usearch_setOffset()
2821 U_CAPI int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch) in usearch_getOffset() argument
2823 if (strsrch) { in usearch_getOffset()
2824 int32_t result = ucol_getOffset(strsrch->textIter); in usearch_getOffset()
2825 if (isOutOfBounds(strsrch->search->textLength, result)) { in usearch_getOffset()
2833 U_CAPI void U_EXPORT2 usearch_setAttribute(UStringSearch *strsrch, in usearch_setAttribute() argument
2838 if (U_SUCCESS(*status) && strsrch) { in usearch_setAttribute()
2842 strsrch->search->isOverlap = (value == USEARCH_ON ? TRUE : FALSE); in usearch_setAttribute()
2845 strsrch->search->isCanonicalMatch = (value == USEARCH_ON ? TRUE : in usearch_setAttribute()
2850 strsrch->search->elementComparisonType = (int16_t)value; in usearch_setAttribute()
2852 strsrch->search->elementComparisonType = 0; in usearch_setAttribute()
2866 const UStringSearch *strsrch, in usearch_getAttribute() argument
2869 if (strsrch) { in usearch_getAttribute()
2872 return (strsrch->search->isOverlap == TRUE ? USEARCH_ON : in usearch_getAttribute()
2875 return (strsrch->search->isCanonicalMatch == TRUE ? USEARCH_ON : in usearch_getAttribute()
2879 int16_t value = strsrch->search->elementComparisonType; in usearch_getAttribute()
2894 const UStringSearch *strsrch) in usearch_getMatchedStart() argument
2896 if (strsrch == NULL) { in usearch_getMatchedStart()
2899 return strsrch->search->matchedIndex; in usearch_getMatchedStart()
2903 U_CAPI int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch, in usearch_getMatchedText() argument
2911 if (strsrch == NULL || resultCapacity < 0 || (resultCapacity > 0 && in usearch_getMatchedText()
2917 int32_t copylength = strsrch->search->matchedLength; in usearch_getMatchedText()
2918 int32_t copyindex = strsrch->search->matchedIndex; in usearch_getMatchedText()
2928 uprv_memcpy(result, strsrch->search->text + copyindex, in usearch_getMatchedText()
2932 strsrch->search->matchedLength, status); in usearch_getMatchedText()
2936 const UStringSearch *strsrch) in usearch_getMatchedLength() argument
2938 if (strsrch) { in usearch_getMatchedLength()
2939 return strsrch->search->matchedLength; in usearch_getMatchedLength()
2946 U_CAPI void U_EXPORT2 usearch_setBreakIterator(UStringSearch *strsrch, in usearch_setBreakIterator() argument
2950 if (U_SUCCESS(*status) && strsrch) { in usearch_setBreakIterator()
2951 strsrch->search->breakIter = breakiter; in usearch_setBreakIterator()
2953 ubrk_setText(breakiter, strsrch->search->text, in usearch_setBreakIterator()
2954 strsrch->search->textLength, status); in usearch_setBreakIterator()
2960 usearch_getBreakIterator(const UStringSearch *strsrch) in usearch_getBreakIterator() argument
2962 if (strsrch) { in usearch_getBreakIterator()
2963 return strsrch->search->breakIter; in usearch_getBreakIterator()
2970 U_CAPI void U_EXPORT2 usearch_setText( UStringSearch *strsrch, in usearch_setText() argument
2976 if (strsrch == NULL || text == NULL || textlength < -1 || in usearch_setText()
2984 strsrch->search->text = text; in usearch_setText()
2985 strsrch->search->textLength = textlength; in usearch_setText()
2986 ucol_setText(strsrch->textIter, text, textlength, status); in usearch_setText()
2987 strsrch->search->matchedIndex = USEARCH_DONE; in usearch_setText()
2988 strsrch->search->matchedLength = 0; in usearch_setText()
2989 strsrch->search->reset = TRUE; in usearch_setText()
2991 if (strsrch->search->breakIter != NULL) { in usearch_setText()
2992 ubrk_setText(strsrch->search->breakIter, text, in usearch_setText()
2995 ubrk_setText(strsrch->search->internalBreakIter, text, textlength, status); in usearch_setText()
3001 U_CAPI const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch, in usearch_getText() argument
3004 if (strsrch) { in usearch_getText()
3005 *length = strsrch->search->textLength; in usearch_getText()
3006 return strsrch->search->text; in usearch_getText()
3011 U_CAPI void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch, in usearch_setCollator() argument
3021 if (strsrch) { in usearch_setCollator()
3022 delete strsrch->textProcessedIter; in usearch_setCollator()
3023 strsrch->textProcessedIter = NULL; in usearch_setCollator()
3024 ucol_closeElements(strsrch->textIter); in usearch_setCollator()
3025 ucol_closeElements(strsrch->utilIter); in usearch_setCollator()
3026 strsrch->textIter = strsrch->utilIter = NULL; in usearch_setCollator()
3027 if (strsrch->ownCollator && (strsrch->collator != collator)) { in usearch_setCollator()
3028 ucol_close((UCollator *)strsrch->collator); in usearch_setCollator()
3029 strsrch->ownCollator = FALSE; in usearch_setCollator()
3031 strsrch->collator = collator; in usearch_setCollator()
3032 strsrch->strength = ucol_getStrength(collator); in usearch_setCollator()
3033 strsrch->ceMask = getMask(strsrch->strength); in usearch_setCollator()
3035 ubrk_close(strsrch->search->internalBreakIter); in usearch_setCollator()
3036 …strsrch->search->internalBreakIter = ubrk_open(UBRK_CHARACTER, ucol_getLocaleByType(collator, ULOC… in usearch_setCollator()
3037 … strsrch->search->text, strsrch->search->textLength, status); in usearch_setCollator()
3040 strsrch->toShift = in usearch_setCollator()
3044 strsrch->variableTop = ucol_getVariableTop(collator, status); in usearch_setCollator()
3045 strsrch->textIter = ucol_openElements(collator, in usearch_setCollator()
3046 strsrch->search->text, in usearch_setCollator()
3047 strsrch->search->textLength, in usearch_setCollator()
3049 strsrch->utilIter = ucol_openElements( in usearch_setCollator()
3050 collator, strsrch->pattern.text, strsrch->pattern.textLength, status); in usearch_setCollator()
3052 initialize(strsrch, status); in usearch_setCollator()
3059 uprv_init_pce(strsrch->textIter); in usearch_setCollator()
3060 uprv_init_pce(strsrch->utilIter); in usearch_setCollator()
3065 U_CAPI UCollator * U_EXPORT2 usearch_getCollator(const UStringSearch *strsrch) in usearch_getCollator() argument
3067 if (strsrch) { in usearch_getCollator()
3068 return (UCollator *)strsrch->collator; in usearch_getCollator()
3073 U_CAPI void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch, in usearch_setPattern() argument
3079 if (strsrch == NULL || pattern == NULL) { in usearch_setPattern()
3090 strsrch->pattern.text = pattern; in usearch_setPattern()
3091 strsrch->pattern.textLength = patternlength; in usearch_setPattern()
3092 initialize(strsrch, status); in usearch_setPattern()
3098 usearch_getPattern(const UStringSearch *strsrch, in usearch_getPattern() argument
3101 if (strsrch) { in usearch_getPattern()
3102 *length = strsrch->pattern.textLength; in usearch_getPattern()
3103 return strsrch->pattern.text; in usearch_getPattern()
3110 U_CAPI int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch, in usearch_first() argument
3113 if (strsrch && U_SUCCESS(*status)) { in usearch_first()
3114 strsrch->search->isForwardSearching = TRUE; in usearch_first()
3115 usearch_setOffset(strsrch, 0, status); in usearch_first()
3117 return usearch_next(strsrch, status); in usearch_first()
3123 U_CAPI int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch, in usearch_following() argument
3127 if (strsrch && U_SUCCESS(*status)) { in usearch_following()
3128 strsrch->search->isForwardSearching = TRUE; in usearch_following()
3130 usearch_setOffset(strsrch, position, status); in usearch_following()
3132 return usearch_next(strsrch, status); in usearch_following()
3138 U_CAPI int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch, in usearch_last() argument
3141 if (strsrch && U_SUCCESS(*status)) { in usearch_last()
3142 strsrch->search->isForwardSearching = FALSE; in usearch_last()
3143 usearch_setOffset(strsrch, strsrch->search->textLength, status); in usearch_last()
3145 return usearch_previous(strsrch, status); in usearch_last()
3151 U_CAPI int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch, in usearch_preceding() argument
3155 if (strsrch && U_SUCCESS(*status)) { in usearch_preceding()
3156 strsrch->search->isForwardSearching = FALSE; in usearch_preceding()
3158 usearch_setOffset(strsrch, position, status); in usearch_preceding()
3160 return usearch_previous(strsrch, status); in usearch_preceding()
3188 U_CAPI int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch, in usearch_next() argument
3191 if (U_SUCCESS(*status) && strsrch) { in usearch_next()
3194 int32_t offset = usearch_getOffset(strsrch); in usearch_next()
3195 USearch *search = strsrch->search; in usearch_next()
3202 (offset + strsrch->pattern.defaultShiftSize > textlength || in usearch_next()
3206 setMatchNotFound(strsrch); in usearch_next()
3215 setMatchNotFound(strsrch); in usearch_next()
3235 if (strsrch->pattern.cesLength == 0) { in usearch_next()
3244 setColEIterOffset(strsrch->textIter, search->matchedIndex); in usearch_next()
3254 ucol_setOffset(strsrch->textIter, offset + 1, status); in usearch_next()
3257 ucol_setOffset(strsrch->textIter, in usearch_next()
3271 usearch_handleNextCanonical(strsrch, status); in usearch_next()
3274 usearch_handleNextExact(strsrch, status); in usearch_next()
3284 ucol_setOffset(strsrch->textIter, search->textLength, status); in usearch_next()
3286 ucol_setOffset(strsrch->textIter, search->matchedIndex, status); in usearch_next()
3296 U_CAPI int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch, in usearch_previous() argument
3299 if (U_SUCCESS(*status) && strsrch) { in usearch_previous()
3301 USearch *search = strsrch->search; in usearch_previous()
3306 setColEIterOffset(strsrch->textIter, offset); in usearch_previous()
3309 offset = usearch_getOffset(strsrch); in usearch_previous()
3328 (offset < strsrch->pattern.defaultShiftSize || in usearch_previous()
3330 matchedindex < strsrch->pattern.defaultShiftSize)))) { in usearch_previous()
3332 setMatchNotFound(strsrch); in usearch_previous()
3339 setMatchNotFound(strsrch); in usearch_previous()
3346 if (strsrch->pattern.cesLength == 0) { in usearch_previous()
3350 setMatchNotFound(strsrch); in usearch_previous()
3355 setColEIterOffset(strsrch->textIter, search->matchedIndex); in usearch_previous()
3361 if (strsrch->search->isCanonicalMatch) { in usearch_previous()
3363 usearch_handlePreviousCanonical(strsrch, status); in usearch_previous()
3367 usearch_handlePreviousExact(strsrch, status); in usearch_previous()
3384 U_CAPI void U_EXPORT2 usearch_reset(UStringSearch *strsrch) in usearch_reset() argument
3391 if (strsrch) { in usearch_reset()
3399 UCollationStrength newStrength = ucol_getStrength(strsrch->collator); in usearch_reset()
3400 if ((strsrch->strength < UCOL_QUATERNARY && newStrength >= UCOL_QUATERNARY) || in usearch_reset()
3401 (strsrch->strength >= UCOL_QUATERNARY && newStrength < UCOL_QUATERNARY)) { in usearch_reset()
3405 strsrch->strength = ucol_getStrength(strsrch->collator); in usearch_reset()
3406 ceMask = getMask(strsrch->strength); in usearch_reset()
3407 if (strsrch->ceMask != ceMask) { in usearch_reset()
3408 strsrch->ceMask = ceMask; in usearch_reset()
3413 shift = ucol_getAttribute(strsrch->collator, UCOL_ALTERNATE_HANDLING, in usearch_reset()
3415 if (strsrch->toShift != shift) { in usearch_reset()
3416 strsrch->toShift = shift; in usearch_reset()
3421 varTop = ucol_getVariableTop(strsrch->collator, &status); in usearch_reset()
3422 if (strsrch->variableTop != varTop) { in usearch_reset()
3423 strsrch->variableTop = varTop; in usearch_reset()
3427 initialize(strsrch, &status); in usearch_reset()
3429 ucol_setText(strsrch->textIter, strsrch->search->text, in usearch_reset()
3430 strsrch->search->textLength, in usearch_reset()
3432 strsrch->search->matchedLength = 0; in usearch_reset()
3433 strsrch->search->matchedIndex = USEARCH_DONE; in usearch_reset()
3434 strsrch->search->isOverlap = FALSE; in usearch_reset()
3435 strsrch->search->isCanonicalMatch = FALSE; in usearch_reset()
3436 strsrch->search->elementComparisonType = 0; in usearch_reset()
3437 strsrch->search->isForwardSearching = TRUE; in usearch_reset()
3438 strsrch->search->reset = TRUE; in usearch_reset()
3621 static int32_t nextBoundaryAfter(UStringSearch *strsrch, int32_t startIndex) { in nextBoundaryAfter() argument
3623 const UChar *text = strsrch->search->text; in nextBoundaryAfter()
3624 int32_t textLen = strsrch->search->textLength; in nextBoundaryAfter()
3660 UBreakIterator *breakiterator = strsrch->search->breakIter; in nextBoundaryAfter()
3663 breakiterator = strsrch->search->internalBreakIter; in nextBoundaryAfter()
3683 static UBool isBreakBoundary(UStringSearch *strsrch, int32_t index) { in isBreakBoundary() argument
3685 const UChar *text = strsrch->search->text; in isBreakBoundary()
3686 int32_t textLen = strsrch->search->textLength; in isBreakBoundary()
3711 UBreakIterator *breakiterator = strsrch->search->breakIter; in isBreakBoundary()
3714 breakiterator = strsrch->search->internalBreakIter; in isBreakBoundary()
3725 static UBool onBreakBoundaries(const UStringSearch *strsrch, int32_t start, int32_t end)
3728 UBreakIterator *breakiterator = strsrch->search->breakIter;
3834 U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch, in usearch_search() argument
3849 for (int ii=0; ii<strsrch->pattern.cesLength; ii++) { in usearch_search()
3850 printf(" %8x", strsrch->pattern.ces[ii]); in usearch_search()
3859 if(strsrch->pattern.cesLength == 0 || in usearch_search()
3861 startIdx > strsrch->search->textLength || in usearch_search()
3862 strsrch->pattern.ces == NULL) { in usearch_search()
3867 if (strsrch->pattern.pces == NULL) { in usearch_search()
3868 initializePatternPCETable(strsrch, status); in usearch_search()
3871 ucol_setOffset(strsrch->textIter, startIdx, status); in usearch_search()
3872 CEIBuffer ceb(strsrch, status); in usearch_search()
3918 for (patIx=0; patIx<strsrch->pattern.pcesLength; patIx++) { in usearch_search()
3919 patCE = strsrch->pattern.pces[patIx]; in usearch_search()
3924 …UCompareCEsResult ceMatch = compareCE64s(targetCEI->ce, patCE, strsrch->search->elementComparisonT… in usearch_search()
3939 …targetIxOffset += strsrch->pattern.pcesLength; // this is now the offset in target CE space to end… in usearch_search()
3971 if (strsrch->search->elementComparisonType == 0) { in usearch_search()
3989 …UCompareCEsResult ceMatch = compareCE64s(nextCEI->ce, patCE, strsrch->search->elementComparisonTyp… in usearch_search()
4013 if (!isBreakBoundary(strsrch, mStart)) { in usearch_search()
4039 if (strsrch->search->text != NULL && strsrch->search->textLength > maxLimit) { in usearch_search()
4041 strsrch->search->breakIter == NULL && in usearch_search()
4044 (strsrch->nfd->hasBoundaryBefore(codePointAt(*strsrch->search, maxLimit)) || in usearch_search()
4045 … strsrch->nfd->hasBoundaryAfter(codePointBefore(*strsrch->search, maxLimit))); in usearch_search()
4065 if (minLimit == lastCEI->highIndex && isBreakBoundary(strsrch, minLimit)) { in usearch_search()
4068 int32_t nba = nextBoundaryAfter(strsrch, minLimit); in usearch_search()
4091 if (!isBreakBoundary(strsrch, mLimit)) { in usearch_search()
4096 if (! checkIdentical(strsrch, mStart, mLimit)) { in usearch_search()
4134 U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch, in usearch_searchBackwards() argument
4149 for (int ii=0; ii<strsrch->pattern.cesLength; ii++) { in usearch_searchBackwards()
4150 printf(" %8x", strsrch->pattern.ces[ii]); in usearch_searchBackwards()
4159 if(strsrch->pattern.cesLength == 0 || in usearch_searchBackwards()
4161 startIdx > strsrch->search->textLength || in usearch_searchBackwards()
4162 strsrch->pattern.ces == NULL) { in usearch_searchBackwards()
4167 if (strsrch->pattern.pces == NULL) { in usearch_searchBackwards()
4168 initializePatternPCETable(strsrch, status); in usearch_searchBackwards()
4171 CEIBuffer ceb(strsrch, status); in usearch_searchBackwards()
4183 if (startIdx < strsrch->search->textLength) { in usearch_searchBackwards()
4184 UBreakIterator *bi = strsrch->search->internalBreakIter; in usearch_searchBackwards()
4187 ucol_setOffset(strsrch->textIter, next, status); in usearch_searchBackwards()
4195 ucol_setOffset(strsrch->textIter, startIdx, status); in usearch_searchBackwards()
4232 for (patIx = strsrch->pattern.pcesLength - 1; patIx >= 0; patIx -= 1) { in usearch_searchBackwards()
4233 int64_t patCE = strsrch->pattern.pces[patIx]; in usearch_searchBackwards()
4235 … targetCEI = ceb.getPrevious(targetIx + strsrch->pattern.pcesLength - 1 - patIx + targetIxOffset); in usearch_searchBackwards()
4239 …UCompareCEsResult ceMatch = compareCE64s(targetCEI->ce, patCE, strsrch->search->elementComparisonT… in usearch_searchBackwards()
4271 …const CEI *firstCEI = ceb.getPrevious(targetIx + strsrch->pattern.pcesLength - 1 + targetIxOffset); in usearch_searchBackwards()
4280 if (!isBreakBoundary(strsrch, mStart)) { in usearch_searchBackwards()
4322 if (strsrch->search->text != NULL && strsrch->search->textLength > maxLimit) { in usearch_searchBackwards()
4324 strsrch->search->breakIter == NULL && in usearch_searchBackwards()
4327 (strsrch->nfd->hasBoundaryBefore(codePointAt(*strsrch->search, maxLimit)) || in usearch_searchBackwards()
4328 … strsrch->nfd->hasBoundaryAfter(codePointBefore(*strsrch->search, maxLimit))); in usearch_searchBackwards()
4341 int32_t nba = nextBoundaryAfter(strsrch, minLimit); in usearch_searchBackwards()
4358 if (!isBreakBoundary(strsrch, mLimit)) { in usearch_searchBackwards()
4368 int32_t nba = nextBoundaryAfter(strsrch, minLimit); in usearch_searchBackwards()
4379 if (! checkIdentical(strsrch, mStart, mLimit)) { in usearch_searchBackwards()
4419 UBool usearch_handleNextExact(UStringSearch *strsrch, UErrorCode *status) in usearch_handleNextExact() argument
4422 setMatchNotFound(strsrch); in usearch_handleNextExact()
4427 UCollationElements *coleiter = strsrch->textIter; in usearch_handleNextExact()
4428 int32_t textlength = strsrch->search->textLength; in usearch_handleNextExact()
4429 int32_t *patternce = strsrch->pattern.ces; in usearch_handleNextExact()
4430 int32_t patterncelength = strsrch->pattern.cesLength; in usearch_handleNextExact()
4436 textoffset = shiftForward(strsrch, textoffset, UCOL_NULLORDER, in usearch_handleNextExact()
4456 targetce = getCE(strsrch, targetce); in usearch_handleNextExact()
4486 targetce = getCE(strsrch, targetce); in usearch_handleNextExact()
4502 textoffset = shiftForward(strsrch, textoffset, lastce, in usearch_handleNextExact()
4509 if (checkNextExactMatch(strsrch, &textoffset, status)) { in usearch_handleNextExact()
4511 setColEIterOffset(coleiter, strsrch->search->matchedIndex); in usearch_handleNextExact()
4515 setMatchNotFound(strsrch); in usearch_handleNextExact()
4518 int32_t textOffset = ucol_getOffset(strsrch->textIter); in usearch_handleNextExact()
4522 if (usearch_search(strsrch, textOffset, &start, &end, status)) { in usearch_handleNextExact()
4523 strsrch->search->matchedIndex = start; in usearch_handleNextExact()
4524 strsrch->search->matchedLength = end - start; in usearch_handleNextExact()
4527 setMatchNotFound(strsrch); in usearch_handleNextExact()
4533 UBool usearch_handleNextCanonical(UStringSearch *strsrch, UErrorCode *status) in usearch_handleNextCanonical() argument
4536 setMatchNotFound(strsrch); in usearch_handleNextCanonical()
4541 UCollationElements *coleiter = strsrch->textIter; in usearch_handleNextCanonical()
4542 int32_t textlength = strsrch->search->textLength; in usearch_handleNextCanonical()
4543 int32_t *patternce = strsrch->pattern.ces; in usearch_handleNextCanonical()
4544 int32_t patterncelength = strsrch->pattern.cesLength; in usearch_handleNextCanonical()
4547 strsrch->pattern.hasSuffixAccents || strsrch->pattern.hasPrefixAccents; in usearch_handleNextCanonical()
4549 textoffset = shiftForward(strsrch, textoffset, UCOL_NULLORDER, in usearch_handleNextCanonical()
4551 strsrch->canonicalPrefixAccents[0] = 0; in usearch_handleNextCanonical()
4552 strsrch->canonicalSuffixAccents[0] = 0; in usearch_handleNextCanonical()
4572 targetce = getCE(strsrch, targetce); in usearch_handleNextCanonical()
4594 targetce = getCE(strsrch, targetce); in usearch_handleNextCanonical()
4606 strsrch->canonicalPrefixAccents[0] = 0; in usearch_handleNextCanonical()
4607 strsrch->canonicalSuffixAccents[0] = 0; in usearch_handleNextCanonical()
4611 found = doNextCanonicalMatch(strsrch, textoffset, status); in usearch_handleNextCanonical()
4618 textoffset = shiftForward(strsrch, textoffset, lastce, in usearch_handleNextCanonical()
4625 if (checkNextCanonicalMatch(strsrch, &textoffset, status)) { in usearch_handleNextCanonical()
4626 setColEIterOffset(coleiter, strsrch->search->matchedIndex); in usearch_handleNextCanonical()
4630 setMatchNotFound(strsrch); in usearch_handleNextCanonical()
4633 int32_t textOffset = ucol_getOffset(strsrch->textIter); in usearch_handleNextCanonical()
4637 if (usearch_search(strsrch, textOffset, &start, &end, status)) { in usearch_handleNextCanonical()
4638 strsrch->search->matchedIndex = start; in usearch_handleNextCanonical()
4639 strsrch->search->matchedLength = end - start; in usearch_handleNextCanonical()
4642 setMatchNotFound(strsrch); in usearch_handleNextCanonical()
4648 UBool usearch_handlePreviousExact(UStringSearch *strsrch, UErrorCode *status) in usearch_handlePreviousExact() argument
4651 setMatchNotFound(strsrch); in usearch_handlePreviousExact()
4656 UCollationElements *coleiter = strsrch->textIter; in usearch_handlePreviousExact()
4657 int32_t *patternce = strsrch->pattern.ces; in usearch_handlePreviousExact()
4658 int32_t patterncelength = strsrch->pattern.cesLength; in usearch_handlePreviousExact()
4664 if (strsrch->search->matchedIndex != USEARCH_DONE) { in usearch_handlePreviousExact()
4665 textoffset = strsrch->search->matchedIndex; in usearch_handlePreviousExact()
4668 textoffset = reverseShift(strsrch, textoffset, UCOL_NULLORDER, in usearch_handlePreviousExact()
4691 targetce = getCE(strsrch, targetce); in usearch_handlePreviousExact()
4695 if (targetce == UCOL_IGNORABLE && strsrch->strength != UCOL_PRIMARY) { in usearch_handlePreviousExact()
4719 targetce = getCE(strsrch, targetce); in usearch_handlePreviousExact()
4736 textoffset = reverseShift(strsrch, textoffset, targetce, in usearch_handlePreviousExact()
4742 if (checkPreviousExactMatch(strsrch, &textoffset, status)) { in usearch_handlePreviousExact()
4747 setMatchNotFound(strsrch); in usearch_handlePreviousExact()
4752 if (strsrch->search->isOverlap) { in usearch_handlePreviousExact()
4753 if (strsrch->search->matchedIndex != USEARCH_DONE) { in usearch_handlePreviousExact()
4754 textOffset = strsrch->search->matchedIndex + strsrch->search->matchedLength - 1; in usearch_handlePreviousExact()
4757 initializePatternPCETable(strsrch, status); in usearch_handlePreviousExact()
4758 if (!initTextProcessedIter(strsrch, status)) { in usearch_handlePreviousExact()
4759 setMatchNotFound(strsrch); in usearch_handlePreviousExact()
4762 for (int32_t nPCEs = 0; nPCEs < strsrch->pattern.pcesLength - 1; nPCEs++) { in usearch_handlePreviousExact()
4763 int64_t pce = strsrch->textProcessedIter->nextProcessed(NULL, NULL, status); in usearch_handlePreviousExact()
4770 setMatchNotFound(strsrch); in usearch_handlePreviousExact()
4773 textOffset = ucol_getOffset(strsrch->textIter); in usearch_handlePreviousExact()
4776 textOffset = ucol_getOffset(strsrch->textIter); in usearch_handlePreviousExact()
4782 if (usearch_searchBackwards(strsrch, textOffset, &start, &end, status)) { in usearch_handlePreviousExact()
4783 strsrch->search->matchedIndex = start; in usearch_handlePreviousExact()
4784 strsrch->search->matchedLength = end - start; in usearch_handlePreviousExact()
4787 setMatchNotFound(strsrch); in usearch_handlePreviousExact()
4793 UBool usearch_handlePreviousCanonical(UStringSearch *strsrch, in usearch_handlePreviousCanonical() argument
4797 setMatchNotFound(strsrch); in usearch_handlePreviousCanonical()
4802 UCollationElements *coleiter = strsrch->textIter; in usearch_handlePreviousCanonical()
4803 int32_t *patternce = strsrch->pattern.ces; in usearch_handlePreviousCanonical()
4804 int32_t patterncelength = strsrch->pattern.cesLength; in usearch_handlePreviousCanonical()
4807 strsrch->pattern.hasSuffixAccents || strsrch->pattern.hasPrefixAccents; in usearch_handlePreviousCanonical()
4812 if (strsrch->search->matchedIndex != USEARCH_DONE) { in usearch_handlePreviousCanonical()
4813 textoffset = strsrch->search->matchedIndex; in usearch_handlePreviousCanonical()
4816 textoffset = reverseShift(strsrch, textoffset, UCOL_NULLORDER, in usearch_handlePreviousCanonical()
4818 strsrch->canonicalPrefixAccents[0] = 0; in usearch_handlePreviousCanonical()
4819 strsrch->canonicalSuffixAccents[0] = 0; in usearch_handlePreviousCanonical()
4839 targetce = getCE(strsrch, targetce); in usearch_handlePreviousCanonical()
4865 targetce = getCE(strsrch, targetce); in usearch_handlePreviousCanonical()
4877 strsrch->canonicalPrefixAccents[0] = 0; in usearch_handlePreviousCanonical()
4878 strsrch->canonicalSuffixAccents[0] = 0; in usearch_handlePreviousCanonical()
4882 found = doPreviousCanonicalMatch(strsrch, textoffset, status); in usearch_handlePreviousCanonical()
4889 textoffset = reverseShift(strsrch, textoffset, targetce, in usearch_handlePreviousCanonical()
4895 if (checkPreviousCanonicalMatch(strsrch, &textoffset, status)) { in usearch_handlePreviousCanonical()
4900 setMatchNotFound(strsrch); in usearch_handlePreviousCanonical()
4905 if (strsrch->search->isOverlap) { in usearch_handlePreviousCanonical()
4906 if (strsrch->search->matchedIndex != USEARCH_DONE) { in usearch_handlePreviousCanonical()
4907 textOffset = strsrch->search->matchedIndex + strsrch->search->matchedLength - 1; in usearch_handlePreviousCanonical()
4910 initializePatternPCETable(strsrch, status); in usearch_handlePreviousCanonical()
4911 if (!initTextProcessedIter(strsrch, status)) { in usearch_handlePreviousCanonical()
4912 setMatchNotFound(strsrch); in usearch_handlePreviousCanonical()
4915 for (int32_t nPCEs = 0; nPCEs < strsrch->pattern.pcesLength - 1; nPCEs++) { in usearch_handlePreviousCanonical()
4916 int64_t pce = strsrch->textProcessedIter->nextProcessed(NULL, NULL, status); in usearch_handlePreviousCanonical()
4923 setMatchNotFound(strsrch); in usearch_handlePreviousCanonical()
4926 textOffset = ucol_getOffset(strsrch->textIter); in usearch_handlePreviousCanonical()
4929 textOffset = ucol_getOffset(strsrch->textIter); in usearch_handlePreviousCanonical()
4935 if (usearch_searchBackwards(strsrch, textOffset, &start, &end, status)) { in usearch_handlePreviousCanonical()
4936 strsrch->search->matchedIndex = start; in usearch_handlePreviousCanonical()
4937 strsrch->search->matchedLength = end - start; in usearch_handlePreviousCanonical()
4940 setMatchNotFound(strsrch); in usearch_handlePreviousCanonical()