[Libreoffice-commits] core.git: i18npool/qa i18npool/source

Herbert Dürr hdu at apache.org
Thu Mar 7 12:00:57 PST 2013


 i18npool/qa/cppunit/test_textsearch.cxx |    2 +-
 i18npool/source/search/textsearch.cxx   |    8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

New commits:
commit b514f0ce86e85d9be269ddf2e797befbbf3423f1
Author: Herbert Dürr <hdu at apache.org>
Date:   Mon Jan 14 09:50:06 2013 +0000

    i#121482# fix backwards regexp search for matches overlapping search start
    
    (cherry picked from commit 854f4ad6c57be62bd922df08f603d8bfb7b918a5)
    
    Additionally fixed unit test, searching backward shall not produce a
    different result from searching forward. (erAck)
    
    Change-Id: I952509276875441005e6a4036e6c3089be627dd9

diff --git a/i18npool/qa/cppunit/test_textsearch.cxx b/i18npool/qa/cppunit/test_textsearch.cxx
index c26550b..d7a6c33 100644
--- a/i18npool/qa/cppunit/test_textsearch.cxx
+++ b/i18npool/qa/cppunit/test_textsearch.cxx
@@ -101,7 +101,7 @@ void TestTextSearch::testSearches()
     sal_Int32 startPos = 2, endPos = 20 ;
     OUString searchStr( "(ab)*a(c|d)+" );
     sal_Int32 fStartRes = 10, fEndRes = 18 ;
-    sal_Int32 bStartRes = 18, bEndRes = 14 ;
+    sal_Int32 bStartRes = 18, bEndRes = 10 ;
 
     // set options
     util::SearchOptions aOptions;
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index 2df126e..65ab5e4 100644
--- a/i18npool/source/search/textsearch.cxx
+++ b/i18npool/source/search/textsearch.cxx
@@ -774,9 +774,15 @@ SearchResult TextSearch::RESrchBkwrd( const OUString& searchStr,
 
     // find the last match
     int nLastPos = 0;
+    int nFoundEnd = 0;
     do {
         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
     pRegexMatcher->find( nLastPos, nIcuErr);


More information about the Libreoffice-commits mailing list