Kaydet (Commit) b514f0ce authored tarafından Herbert Dürr's avatar Herbert Dürr Kaydeden (comit) Eike Rathke

i#121482# fix backwards regexp search for matches overlapping search start

(cherry picked from commit 854f4ad6)

Additionally fixed unit test, searching backward shall not produce a
different result from searching forward. (erAck)

Change-Id: I952509276875441005e6a4036e6c3089be627dd9
üst 783d3928
...@@ -101,7 +101,7 @@ void TestTextSearch::testSearches() ...@@ -101,7 +101,7 @@ void TestTextSearch::testSearches()
sal_Int32 startPos = 2, endPos = 20 ; sal_Int32 startPos = 2, endPos = 20 ;
OUString searchStr( "(ab)*a(c|d)+" ); OUString searchStr( "(ab)*a(c|d)+" );
sal_Int32 fStartRes = 10, fEndRes = 18 ; sal_Int32 fStartRes = 10, fEndRes = 18 ;
sal_Int32 bStartRes = 18, bEndRes = 14 ; sal_Int32 bStartRes = 18, bEndRes = 10 ;
// set options // set options
util::SearchOptions aOptions; util::SearchOptions aOptions;
......
...@@ -774,9 +774,15 @@ SearchResult TextSearch::RESrchBkwrd( const OUString& searchStr, ...@@ -774,9 +774,15 @@ SearchResult TextSearch::RESrchBkwrd( const OUString& searchStr,
// find the last match // find the last match
int nLastPos = 0; int nLastPos = 0;
int nFoundEnd = 0;
do { do {
nLastPos = pRegexMatcher->start( nIcuErr); nLastPos = pRegexMatcher->start( nIcuErr);
} while( pRegexMatcher->find( nLastPos + 1, nIcuErr)); nFoundEnd = pRegexMatcher->end( nIcuErr);
if( nFoundEnd >= startPos)
break;
if( nFoundEnd == nLastPos)
++nFoundEnd;
} while( pRegexMatcher->find( nFoundEnd, nIcuErr));
// find last match again to get its details // find last match again to get its details
pRegexMatcher->find( nLastPos, nIcuErr); pRegexMatcher->find( nLastPos, nIcuErr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment