[Libreoffice-commits] core.git: l10ntools/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Mar 5 21:37:43 UTC 2019


 l10ntools/source/lngmerge.cxx |   35 ++++++++++++-----------------------
 1 file changed, 12 insertions(+), 23 deletions(-)

New commits:
commit 78404432ed784b3570cb4c223e6311c3e9859b60
Author:     Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Thu Feb 21 18:27:58 2019 +0100
Commit:     Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Tue Mar 5 22:37:14 2019 +0100

    Group some more common code
    
    Change-Id: I2bf3e8afd9f330e8d7377300163a3224ed4db05c
    Reviewed-on: https://gerrit.libreoffice.org/68179
    Tested-by: Jenkins
    Reviewed-by: Matteo Casalin <matteo.casalin at yahoo.com>

diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx
index f6939458c588..fdb0cf90b176 100644
--- a/l10ntools/source/lngmerge.cxx
+++ b/l10ntools/source/lngmerge.cxx
@@ -30,8 +30,14 @@
 
 namespace {
 
-OString getBracketedContent(const OString& text) {
-    return text.getToken(1, '[').getToken(0, ']');
+bool lcl_isNextGroup(OString &sGroup_out, const OString &sLineTrim)
+{
+    if (sLineTrim.startsWith("[") && sLineTrim.endsWith("]"))
+    {
+        sGroup_out = sLineTrim.getToken(1, '[').getToken(0, ']').trim();
+        return true;
+    }
+    return false;
 }
 
 void lcl_RemoveUTF8ByteOrderMarker( OString &rString )
@@ -122,13 +128,7 @@ void LngParser::WritePO(PoOfstream &aPOStream,
 
 bool LngParser::isNextGroup(OString &sGroup_out, const OString &sLine_in)
 {
-    const OString sLineTrim = sLine_in.trim();
-    if (sLineTrim.startsWith("[") && sLineTrim.endsWith("]"))
-    {
-        sGroup_out = getBracketedContent(sLineTrim).trim();
-        return true;
-    }
-    return false;
+    return lcl_isNextGroup(sGroup_out, sLine_in.trim());
 }
 
 void LngParser::ReadLine(const OString &rLine_in,
@@ -162,16 +162,7 @@ void LngParser::Merge(
 
     // seek to next group
     while ( nPos < mvLines.size() && !bGroup )
-    {
-        OString sLine( mvLines[ nPos ] );
-        sLine = sLine.trim();
-        if ( sLine.startsWith("[") && sLine.endsWith("]") )
-        {
-            sGroup = getBracketedContent(sLine).trim();
-            bGroup = true;
-        }
-        nPos ++;
-    }
+        bGroup = lcl_isNextGroup(sGroup, mvLines[nPos++].trim());
 
     while ( nPos < mvLines.size()) {
         OStringHashMap Text;
@@ -188,11 +179,9 @@ void LngParser::Merge(
 
         while ( nPos < mvLines.size() && !bGroup )
         {
-            OString sLine( mvLines[ nPos ] );
-            sLine = sLine.trim();
-            if ( sLine.startsWith("[") && sLine.endsWith("]") )
+            const OString sLine{ mvLines[nPos].trim() };
+            if ( lcl_isNextGroup(sGroup, sLine) )
             {
-                sGroup = getBracketedContent(sLine).trim();
                 bGroup = true;
                 nPos ++;
                 sLanguagesDone = "";


More information about the Libreoffice-commits mailing list