summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-07-11 12:16:13 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-07-11 12:17:40 +0200
commit63cb8d6bb21ad6bb401efa4eca479f89745c1cfe (patch)
tree1a8fb9c46601a830796ce8eb9f91ac545164ced6 /l10ntools
parent089fad5c46e0cc5727658b26d4a9b375fd40ecf2 (diff)
fdo#51954: More tools->rtl string conversion regressions
Change-Id: I490cc82b60663d30fdc8e09d9d6021c964656bec
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/source/gsicheck.cxx2
-rw-r--r--l10ntools/source/helper.hxx9
-rw-r--r--l10ntools/source/tagtest.cxx4
3 files changed, 12 insertions, 3 deletions
diff --git a/l10ntools/source/gsicheck.cxx b/l10ntools/source/gsicheck.cxx
index bb0e11601340..98e4b310f01b 100644
--- a/l10ntools/source/gsicheck.cxx
+++ b/l10ntools/source/gsicheck.cxx
@@ -362,7 +362,7 @@ void GSIBlock::PrintList( ParserMessageList *pList, rtl::OString const & aPrefix
if ( pMsg->GetTagBegin() == -1 )
aContext = pLine->GetText().copy( 0, 300 );
else
- aContext = pLine->data_.copy( pMsg->GetTagBegin()-150, 300 );
+ aContext = helper::abbreviate( pLine->data_, pMsg->GetTagBegin()-150, 300 );
aContext = aContext.trim();
}
diff --git a/l10ntools/source/helper.hxx b/l10ntools/source/helper.hxx
index 59f86287fd72..ee03eda3a162 100644
--- a/l10ntools/source/helper.hxx
+++ b/l10ntools/source/helper.hxx
@@ -32,6 +32,7 @@
#include "sal/config.h"
+#include <algorithm>
#include <cassert>
#include "rtl/string.hxx"
@@ -99,6 +100,14 @@ inline sal_Int32 indexOfAnyAsciiL(
return -1;
}
+template< typename T > inline T abbreviate(
+ T const & text, sal_Int32 start, sal_Int32 length)
+{
+ start = std::max(0, start);
+ assert(start <= text.getLength());
+ return text.copy(start, std::min(text.getLength() - start, length));
+}
+
}
#endif
diff --git a/l10ntools/source/tagtest.cxx b/l10ntools/source/tagtest.cxx
index 2a29c3f59e6f..77b3be82ee67 100644
--- a/l10ntools/source/tagtest.cxx
+++ b/l10ntools/source/tagtest.cxx
@@ -707,7 +707,7 @@ TokenInfo SimpleParser::GetNextToken( ParserMessageList &rErrorList )
// this is only to kick out quoted backslashes
while (nQuotedQuotesPos != -1)
{
- if ( nQuotedBackPos <= nQuotedQuotesPos )
+ if ( nQuotedBackPos != -1 && nQuotedBackPos <= nQuotedQuotesPos )
nQuotePos = nQuotedBackPos+2;
else
{
@@ -808,7 +808,7 @@ rtl::OUString SimpleParser::GetNextTokenString( ParserMessageList &rErrorList, s
if (nEndPos == -1)
{ // Token is incomplete. Skip start and search for better ones
nPos = nStyle3StartPos +2;
- rErrorList.AddError( 24, "Tag Start '\\<' without Tag End '\\>'", TokenInfo( TAG_UNKNOWN_TAG, nStyle3StartPos, aSource.copy(nStyle3StartPos - 10, 20) ) );
+ rErrorList.AddError( 24, "Tag Start '\\<' without Tag End '\\>'", TokenInfo( TAG_UNKNOWN_TAG, nStyle3StartPos, helper::abbreviate(aSource, nStyle3StartPos - 10, 20) ) );
return GetNextTokenString( rErrorList, rTagStartPos );
}
// check for paired quoted " --> \"sometext\"