summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-12-19 11:37:59 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2019-12-19 10:59:01 +0100
commit0cd3b7926cafc01d06b589124215e9cb7c148f19 (patch)
tree5b33e179bf7ec020ca0b99d0618fa997e44c543c /i18npool
parentfe17fd7b0fe2bb4a0db44fb46297ecafb2886366 (diff)
tdf#65038: use trailing string characters for look-ahead assertions
... like commit eb973a46ba0e34026db2d2929f2aa10505623872 did for look-behind assertions Change-Id: I86ece5d3ee49b0c5d86f2cfab5fed2830d5ad777 Reviewed-on: https://gerrit.libreoffice.org/85487 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/source/search/textsearch.cxx14
1 files changed, 11 insertions, 3 deletions
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index b0361bee89a3..c74e158780f4 100644
--- a/i18npool/source/search/textsearch.cxx
+++ b/i18npool/source/search/textsearch.cxx
@@ -323,9 +323,16 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta
const sal_Int32 nMaxLeadingLen = aSrchPara.searchString.startsWith("(?") ? 100 : 3;
nInStartPos -= std::min(nMaxLeadingLen, startPos);
}
+ sal_Int32 nInEndPos = endPos;
+ if (pRegexMatcher && endPos < searchStr.getLength())
+ {
+ // tdf#65038: ditto for look-ahead assertions
+ const sal_Int32 nMaxTrailingLen = aSrchPara.searchString.endsWith(")") ? 100 : 3;
+ nInEndPos += std::min(nMaxTrailingLen, searchStr.getLength() - endPos);
+ }
- css::uno::Sequence<sal_Int32> offset(endPos - nInStartPos);
- in_str = xTranslit->transliterate( searchStr, nInStartPos, endPos - nInStartPos, offset );
+ css::uno::Sequence<sal_Int32> offset(nInEndPos - nInStartPos);
+ in_str = xTranslit->transliterate(searchStr, nInStartPos, nInEndPos - nInStartPos, offset);
// JP 20.6.2001: also the start and end positions must be corrected!
sal_Int32 newStartPos =
@@ -907,7 +914,8 @@ SearchResult TextSearch::RESrchFrwrd( const OUString& searchStr,
// use the ICU RegexMatcher to find the matches
UErrorCode nIcuErr = U_ZERO_ERROR;
- const IcuUniString aSearchTargetStr( reinterpret_cast<const UChar*>(searchStr.getStr()), endPos);
+ const IcuUniString aSearchTargetStr(reinterpret_cast<const UChar*>(searchStr.getStr()),
+ searchStr.getLength());
pRegexMatcher->reset( aSearchTargetStr);
// search until there is a valid match
for(;;)