summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-11-26 01:07:38 +0100
committerEike Rathke <erack@redhat.com>2013-11-26 01:08:48 +0100
commitb32651febdaad5939250fb04f721d88952f54732 (patch)
tree8dca643c41308f243fb7bf91ba0196e86d3d0fae /i18npool
parentd838ea200e7d6060d4a759616f9e1fcbf3c36c8e (diff)
encapsulate pRegexMatcher->find() to be able to monitor UErrorCode
Change-Id: I73359a4e2c36ffeca71210971ba9be670e0a12ae
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/source/search/textsearch.cxx24
1 files changed, 20 insertions, 4 deletions
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index ec7ce3cdc215..593483cd131e 100644
--- a/i18npool/source/search/textsearch.cxx
+++ b/i18npool/source/search/textsearch.cxx
@@ -766,6 +766,7 @@ void TextSearch::RESrchPrepare( const ::com::sun::star::util::SearchOptions& rOp
pRegexMatcher = new RegexMatcher( aIcuSearchPatStr, nIcuSearchFlags, nIcuErr);
if (nIcuErr)
{
+ SAL_INFO( "i18npool", "TextSearch::RESrchPrepare UErrorCode " << nIcuErr);
delete pRegexMatcher;
pRegexMatcher = NULL;
}
@@ -792,6 +793,21 @@ void TextSearch::RESrchPrepare( const ::com::sun::star::util::SearchOptions& rOp
//---------------------------------------------------------------------------
+static bool lcl_findRegex( RegexMatcher * pRegexMatcher, sal_Int32 nStartPos, UErrorCode & rIcuErr )
+{
+ if (!pRegexMatcher->find( nStartPos, rIcuErr))
+ {
+ /* TODO: future versions could pass the UErrorCode or translations
+ * thereof to the caller, for example to inform the user of
+ * U_REGEX_TIME_OUT. The strange thing though is that an error is set
+ * only after the second call that returns immediately and not if
+ * timeout occurred on the first call?!? */
+ SAL_INFO( "i18npool", "lcl_findRegex UErrorCode " << rIcuErr);
+ return false;
+ }
+ return true;
+}
+
SearchResult TextSearch::RESrchFrwrd( const OUString& searchStr,
sal_Int32 startPos, sal_Int32 endPos )
throw(RuntimeException)
@@ -811,7 +827,7 @@ SearchResult TextSearch::RESrchFrwrd( const OUString& searchStr,
// search until there is a valid match
for(;;)
{
- if( !pRegexMatcher->find( startPos, nIcuErr))
+ if (!lcl_findRegex( pRegexMatcher, startPos, nIcuErr))
return aRet;
// #i118887# ignore zero-length matches e.g. "a*" in "bc"
@@ -863,7 +879,7 @@ SearchResult TextSearch::RESrchBkwrd( const OUString& searchStr,
UErrorCode nIcuErr = U_ZERO_ERROR;
const IcuUniString aSearchTargetStr( (const UChar*)searchStr.getStr(), startPos);
pRegexMatcher->reset( aSearchTargetStr);
- if( !pRegexMatcher->find( endPos, nIcuErr))
+ if (!lcl_findRegex( pRegexMatcher, endPos, nIcuErr))
return aRet;
// find the last match
@@ -885,7 +901,7 @@ SearchResult TextSearch::RESrchBkwrd( const OUString& searchStr,
bFirst = false;
if( nFoundEnd == nLastPos)
++nFoundEnd;
- } while( pRegexMatcher->find( nFoundEnd, nIcuErr));
+ } while( lcl_findRegex( pRegexMatcher, nFoundEnd, nIcuErr));
// Ignore all zero-length matches except "$" anchor on first match.
if (nGoodPos == nGoodEnd)
@@ -897,7 +913,7 @@ SearchResult TextSearch::RESrchBkwrd( const OUString& searchStr,
}
// find last match again to get its details
- pRegexMatcher->find( nGoodPos, nIcuErr);
+ lcl_findRegex( pRegexMatcher, nGoodPos, nIcuErr);
// fill in the details of the last match
const int nGroupCount = pRegexMatcher->groupCount();