summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i18npool/qa/cppunit/test_textsearch.cxx11
-rw-r--r--i18npool/source/search/textsearch.cxx9
2 files changed, 17 insertions, 3 deletions
diff --git a/i18npool/qa/cppunit/test_textsearch.cxx b/i18npool/qa/cppunit/test_textsearch.cxx
index a5713d00da70..50bab9a0036c 100644
--- a/i18npool/qa/cppunit/test_textsearch.cxx
+++ b/i18npool/qa/cppunit/test_textsearch.cxx
@@ -23,6 +23,7 @@
#include <com/sun/star/util/SearchOptions.hpp>
#include <com/sun/star/util/SearchAlgorithms.hpp>
#include <com/sun/star/util/XTextSearch.hpp>
+#include <com/sun/star/i18n/Transliteration.hpp>
#include <unotest/bootstrapfixturebase.hxx>
#include <unicode/regex.h>
@@ -122,6 +123,16 @@ void TestTextSearch::testSearches()
CPPUNIT_ASSERT( aRes.subRegExpressions > 0 );
CPPUNIT_ASSERT( aRes.startOffset[0] == bStartRes );
CPPUNIT_ASSERT( aRes.endOffset[0] == bEndRes );
+
+ aOptions.transliterateFlags = ::css::i18n::TransliterationModules::TransliterationModules_IGNORE_CASE
+ | ::css::i18n::TransliterationModules::TransliterationModules_IGNORE_WIDTH;
+ aOptions.searchString = "([^ ]*)[ ]*([^ ]*)";
+ m_xSearch->setOptions(aOptions);
+ aRes = m_xSearch->searchForward("11 22 33", 2, 7);
+ CPPUNIT_ASSERT(aRes.subRegExpressions == 3);
+ CPPUNIT_ASSERT((aRes.startOffset[0] == 2) && (aRes.endOffset[0] == 5));
+ CPPUNIT_ASSERT((aRes.startOffset[1] == 2) && (aRes.endOffset[1] == 2));
+ CPPUNIT_ASSERT((aRes.startOffset[2] == 3) && (aRes.endOffset[2] == 5));
}
void TestTextSearch::setUp()
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index e4804376cc9f..fa4cdba4a049 100644
--- a/i18npool/source/search/textsearch.cxx
+++ b/i18npool/source/search/textsearch.cxx
@@ -301,15 +301,18 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta
for ( sal_Int32 k = 0; k < nGroups; k++ )
{
const sal_Int32 nStart = sres.startOffset[k] - nExtraOffset;
- if (startPos > 0 || nStart > 0)
- sres.startOffset[k] = (nStart < nOffsets ? offset[nStart] : (offset[nOffsets - 1] + 1));
+ assert(nStart >= 0); // if not (e.g. searching for $ with ICU regex engine), then what?
+ sres.startOffset[k] = (nStart < nOffsets ? offset[nStart] : (offset[nOffsets - 1] + 1));
// JP 20.6.2001: end is ever exclusive and then don't return
// the position of the next character - return the
// next position behind the last found character!
// "a b c" find "b" must return 2,3 and not 2,4!!!
const sal_Int32 nStop = sres.endOffset[k] - nExtraOffset;
- if (startPos > 0 || nStop > 0)
+ assert(nStop >= 0);
+ if (nStop > 0)
sres.endOffset[k] = offset[(nStop <= nOffsets ? nStop : nOffsets) - 1] + 1;
+ else
+ sres.endOffset[k] = offset[0];
}
}
}