startup: fix -version option (return 6.0.0.0) 50/14450/2
Simon Marchetto [Wed, 23 Apr 2014 13:26:22 +0000 (15:26 +0200)]
Change-Id: Idfcf9b47a4adaa63bc4e4d6a0d1a8bb291b769bc

scilab/modules/core/includes/InitScilab.h
scilab/modules/core/src/cpp/InitScilab.cpp
scilab/modules/startup/src/cpp/scilab.cpp

index 41327c4..a2ca07e 100644 (file)
@@ -27,6 +27,7 @@ typedef struct
     int iConsoleMode;
     int iNoJvm;
     int iNoStart;
+    int iShowVersion;
     char* pstParseFile;
     char* pstFile;
     char* pstExec;
index 1a57ea7..2dd1ee2 100644 (file)
@@ -111,6 +111,7 @@ ScilabEngineInfo* InitScilabEngineInfo()
     pSEI->iConsoleMode  = 0;
     pSEI->iNoJvm        = 0;
     pSEI->iNoStart      = 0;
+    pSEI->iShowVersion  = 0;
 
     pSEI->pstParseFile  = NULL;
     pSEI->pstFile       = NULL;
index 09718d6..b237bc8 100644 (file)
@@ -26,6 +26,7 @@ extern "C"
 #include "sci_mode.h"
 #include "scilabRead.h"
 #include "ConsoleRead.h"
+#include "version.h"
 
     extern char *getCmdLine(void);
 }
@@ -121,6 +122,14 @@ static int get_option(const int argc, char *argv[], ScilabEngineInfo* _pSEI)
                 _pSEI->pstParseFile = argv[i];
             }
         }
+        else if (!strcmp("-version", argv[i]))
+        {
+            i++;
+            if (argc >= i)
+            {
+                _pSEI->iShowVersion = 1;
+            }
+        }
         else if (!strcmp("-f", argv[i]))
         {
             i++;
@@ -259,6 +268,12 @@ int main(int argc, char *argv[])
     setScilabOutputMethod(&TermPrintf);
 #endif // defined(WITHOUT_GUI)
 
+    if (pSEI->iShowVersion == 1)
+    {
+        disp_scilab_version();
+        exit(0);
+    }
+
     StartScilabEngine(pSEI);
     iRet = RunScilabEngine(pSEI);
     StopScilabEngine(pSEI);