[Libreoffice-commits] .: Branch 'feature/killsdf' - l10ntools/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Oct 7 02:56:37 PDT 2012


 l10ntools/source/export2.cxx |   12 +++++++++++-
 l10ntools/source/helpex.cxx  |   28 ++++++++++++----------------
 l10ntools/source/lngex.cxx   |   15 ++++++---------
 3 files changed, 29 insertions(+), 26 deletions(-)

New commits:
commit f9e4d3bfe8eedd49afc2d2161f47a8825a02eec8
Author: Zolnai Tamás <zolnaitamas2000 at gmail.com>
Date:   Sun Oct 7 11:42:37 2012 +0200

    Make Export::handleArguments method safer
    
    -Check wheather input and output file are given
    -Return with "empty" HandledArgs when input is
    invalid
    -Delete plus conditions from helpex and lngex
    
    Change-Id: I418b1ecaab5f0c78197845448ab062aa5d3ba4de

diff --git a/l10ntools/source/export2.cxx b/l10ntools/source/export2.cxx
index e2be3f3..64a5b1b 100644
--- a/l10ntools/source/export2.cxx
+++ b/l10ntools/source/export2.cxx
@@ -94,6 +94,7 @@ rtl::OString Export::sForcedLanguages;
 bool Export::handleArguments(
     int argc, char * argv[], HandledArgs& o_aHandledArgs)
 {
+    o_aHandledArgs = HandledArgs();
     if ( argc <= 1  )
     {
         return false;
@@ -169,7 +170,16 @@ bool Export::handleArguments(
             }
         }
     }
-    return true;
+    if( !o_aHandledArgs.m_sInputFile.isEmpty() &&
+        !o_aHandledArgs.m_sOutputFile.isEmpty() )
+    {
+        return true;
+    }
+    else
+    {
+        o_aHandledArgs = HandledArgs();
+        return false;
+    }
 }
 
 void Export::writeUsage(const OString& rName, const OString& rFileType)
diff --git a/l10ntools/source/helpex.cxx b/l10ntools/source/helpex.cxx
index 574987e..8dca205 100644
--- a/l10ntools/source/helpex.cxx
+++ b/l10ntools/source/helpex.cxx
@@ -39,24 +39,20 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
     //sal_uInt32 startfull = Export::startMessure();
     bool hasNoError = true;
 
-    if ( !aArgs.m_sOutputFile.isEmpty() ){
-        HelpParser aParser( aArgs.m_sInputFile );
-
-        if ( aArgs.m_bMergeMode )
-        {
-            //sal_uInt64 startreadloc = Export::startMessure();
-            MergeDataFile aMergeDataFile( aArgs.m_sMergeSrc, aArgs.m_sInputFile, false );
-
-            hasNoError = aParser.Merge( aArgs.m_sMergeSrc, aArgs.m_sOutputFile , Export::sLanguages , aMergeDataFile );
-        }
-        else
-            hasNoError =
-                aParser.CreateSDF(
-                    aArgs.m_sOutputFile, aArgs.m_sPrj, aArgs.m_sPrjRoot,
-                    aArgs.m_sInputFile, new XMLFile( OUString('0') ), "help" );
+    HelpParser aParser( aArgs.m_sInputFile );
+    if ( aArgs.m_bMergeMode )
+    {
+        //sal_uInt64 startreadloc = Export::startMessure();
+        MergeDataFile aMergeDataFile( aArgs.m_sMergeSrc, aArgs.m_sInputFile, false );
+        hasNoError = aParser.Merge( aArgs.m_sMergeSrc, aArgs.m_sOutputFile , Export::sLanguages , aMergeDataFile );
     }
     else
-        std::cerr << "helpex ERROR: Wrong input parameters!\n";
+    {
+        hasNoError =
+            aParser.CreateSDF(
+                aArgs.m_sOutputFile, aArgs.m_sPrj, aArgs.m_sPrjRoot,
+                aArgs.m_sInputFile, new XMLFile( OUString('0') ), "help" );
+    }
 
     if( hasNoError )
         return 0;
diff --git a/l10ntools/source/lngex.cxx b/l10ntools/source/lngex.cxx
index 706ab26..eb5cccc 100644
--- a/l10ntools/source/lngex.cxx
+++ b/l10ntools/source/lngex.cxx
@@ -34,15 +34,12 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
         return 1;
     }
 
-    if (!aArgs.m_sOutputFile.isEmpty())
-    {
-        LngParser aParser( aArgs.m_sInputFile, true );
-        if ( aArgs.m_bMergeMode )
-            aParser.Merge(aArgs.m_sMergeSrc, aArgs.m_sOutputFile);
-        else
-            aParser.CreateSDF(
-                aArgs.m_sOutputFile, aArgs.m_sPrj, aArgs.m_sPrjRoot );
-    }
+    LngParser aParser( aArgs.m_sInputFile, true );
+    if ( aArgs.m_bMergeMode )
+        aParser.Merge(aArgs.m_sMergeSrc, aArgs.m_sOutputFile);
+    else
+        aParser.CreateSDF(
+            aArgs.m_sOutputFile, aArgs.m_sPrj, aArgs.m_sPrjRoot );
 
     return 0;
 }


More information about the Libreoffice-commits mailing list