[Libreoffice-commits] .: Branch 'libreoffice-3-6' - 5 commits - l10ntools/source

Andras Timar timar at kemper.freedesktop.org
Sun Jul 15 09:41:01 PDT 2012


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

New commits:
commit 9865dbc7af9331ccb1a8e55a09dd821fb014a5a4
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jul 13 15:35:42 2012 +0200

    fdo#51954: More tools->rtl string conversion regressions
    
    Change-Id: If9c5b0a0876540e9546617faaa5dcb4ae1e5a2cb
    Signed-off-by: Andras Timar <atimar at suse.com>

diff --git a/l10ntools/source/gsicheck.cxx b/l10ntools/source/gsicheck.cxx
index 98e4b31..b2981a3 100644
--- a/l10ntools/source/gsicheck.cxx
+++ b/l10ntools/source/gsicheck.cxx
@@ -479,7 +479,7 @@ sal_Bool GSIBlock::HasSuspiciousChars( GSILine* pTestee, GSILine* pSource )
                 rtl::OStringToOUString(
                     pTestee->GetText().copy(0, nPos), RTL_TEXTENCODING_UTF8));
             sal_Int32 nErrorPos = aUTF8Tester.getLength();
-            rtl::OString aContext( pTestee->GetText().copy( nPos, 20 ) );
+            rtl::OString aContext( helper::abbreviate( pTestee->GetText(), nPos, 20 ) );
             PrintError(rtl::OStringBuffer(RTL_CONSTASCII_STRINGPARAM("Found double questionmark in translation only. Looks like an encoding problem at Position "))
                  .append(nErrorPos).getStr(),
                 "Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId());
commit 025c3122716ea363545e04329d0ebc8f7bb65bc9
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jul 11 19:09:44 2012 +0200

    Regression fix correction
    
    Change-Id: I03f020f474c198368aa3528870b0752752a3bd2c
    Signed-off-by: Andras Timar <atimar at suse.com>

diff --git a/l10ntools/source/tagtest.cxx b/l10ntools/source/tagtest.cxx
index 77b3be8..062c5c7 100644
--- a/l10ntools/source/tagtest.cxx
+++ b/l10ntools/source/tagtest.cxx
@@ -772,7 +772,10 @@ rtl::OUString SimpleParser::GetNextTokenString( ParserMessageList &rErrorList, s
     if (nStyle2StartPos == -1 && nStyle3StartPos == -1)
         return rtl::OUString();  // no more tokens
 
-    if ( nStyle4StartPos != -1 && nStyle4StartPos < nStyle2StartPos && nStyle4StartPos <= nStyle3StartPos )  // <= to make sure \\ is always handled first
+    if ( nStyle4StartPos != -1
+         && (nStyle2StartPos == -1 || nStyle4StartPos < nStyle2StartPos)
+         && (nStyle3StartPos == -1 || nStyle4StartPos < nStyle3StartPos ) )
+        // to make sure \\ is always handled first
     {   // Skip quoted Backslash
         nPos = nStyle4StartPos +2;
         return GetNextTokenString( rErrorList, rTagStartPos );
commit fd4129ef6116adfcda39acac7fb6d28211464a72
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Wed Jul 11 12:10:56 2012 +0100

    fix std::max mismatched type compile snafu
    
    Change-Id: Ia6572f8c648168053ae327fa995fc4f33029ab33
    Signed-off-by: Andras Timar <atimar at suse.com>

diff --git a/l10ntools/source/helper.hxx b/l10ntools/source/helper.hxx
index ee03eda..cc33b71 100644
--- a/l10ntools/source/helper.hxx
+++ b/l10ntools/source/helper.hxx
@@ -103,7 +103,7 @@ inline sal_Int32 indexOfAnyAsciiL(
 template< typename T > inline T abbreviate(
     T const & text, sal_Int32 start, sal_Int32 length)
 {
-    start = std::max(0, start);
+    start = std::max(sal_Int32(0), start);
     assert(start <= text.getLength());
     return text.copy(start, std::min(text.getLength() - start, length));
 }
commit 5085fb2b0a8e74e5cdc67487c05c605570e8c71b
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
    Signed-off-by: Andras Timar <atimar at suse.com>

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\"
commit 4bc3473be15e362108b687ee94ce748947e3aad9
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jul 10 19:10:49 2012 +0200

    fdo#51954: -1 is small while STRING_NOTFOUND was great
    
    ...after String -> rtl::OUString conversion in
    a4cbcf2fc567393cd954d0fcc8ea0ce7d859b59f.
    
    Change-Id: Ieb6dfce8c0cf7d8b5971d187b3b58b754c1cb02f
    Signed-off-by: Andras Timar <atimar at suse.com>

diff --git a/l10ntools/source/tagtest.cxx b/l10ntools/source/tagtest.cxx
index e31faa4..2a29c3f 100644
--- a/l10ntools/source/tagtest.cxx
+++ b/l10ntools/source/tagtest.cxx
@@ -772,13 +772,13 @@ rtl::OUString SimpleParser::GetNextTokenString( ParserMessageList &rErrorList, s
     if (nStyle2StartPos == -1 && nStyle3StartPos == -1)
         return rtl::OUString();  // no more tokens
 
-    if ( nStyle4StartPos < nStyle2StartPos && nStyle4StartPos <= nStyle3StartPos )  // <= to make sure \\ is always handled first
+    if ( nStyle4StartPos != -1 && nStyle4StartPos < nStyle2StartPos && nStyle4StartPos <= nStyle3StartPos )  // <= to make sure \\ is always handled first
     {   // Skip quoted Backslash
         nPos = nStyle4StartPos +2;
         return GetNextTokenString( rErrorList, rTagStartPos );
     }
 
-    if ( nStyle2StartPos < nStyle3StartPos )
+    if ( nStyle2StartPos != -1 && ( nStyle3StartPos == -1 || nStyle2StartPos < nStyle3StartPos ) )
     {   // test for $[ ... ] style tokens
         sal_Int32 nEndPos = aSource.indexOf(']', nStyle2StartPos);
         if (nEndPos == -1)


More information about the Libreoffice-commits mailing list