[Libreoffice-commits] .: l10ntools/source

Stephan Bergmann sbergmann at kemper.freedesktop.org
Wed Jul 11 03:17:50 PDT 2012


 l10ntools/source/gsicheck.cxx |    2 +-
 l10ntools/source/helper.hxx   |    9 +++++++++
 l10ntools/source/tagtest.cxx  |    4 ++--
 3 files changed, 12 insertions(+), 3 deletions(-)

New commits:
commit 63cb8d6bb21ad6bb401efa4eca479f89745c1cfe
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jul 11 12:16:13 2012 +0200

    fdo#51954: More tools->rtl string conversion regressions
    
    Change-Id: I490cc82b60663d30fdc8e09d9d6021c964656bec

diff --git a/l10ntools/source/gsicheck.cxx b/l10ntools/source/gsicheck.cxx
index bb0e116..98e4b31 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 59f8628..ee03eda 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 2a29c3f..77b3be8 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\"


More information about the Libreoffice-commits mailing list