genlib updated about 4th argument 62/17162/4
Cedric Delamarre [Fri, 4 Sep 2015 10:16:02 +0000 (12:16 +0200)]
 * bug_12593 updated.
 * bug_9059 updated.
 * -quit added to make macros.
 * genlib return an error if the 4th output argument is given.

test_run functions bug_12593

Change-Id: Ib620c08007b773df920ce3ee424db2e0e0c43dd1

scilab/Makefile.am
scilab/Makefile.in
scilab/modules/elementary_functions/macros/acot.sci
scilab/modules/functions/tests/nonreg_tests/bug_12593.dia.ref
scilab/modules/functions/tests/nonreg_tests/bug_12593.tst
scilab/modules/functions/tests/nonreg_tests/bug_9059.dia.ref
scilab/modules/functions/tests/nonreg_tests/bug_9059.tst
scilab/modules/io/sci_gateway/cpp/sci_genlib.cpp

index 3dac92f..ced6368 100644 (file)
@@ -205,8 +205,8 @@ valgrind_DATA = $(top_srcdir)/tools/profiling/valgrind.supp
 
 macros: $(top_builddir)/scilab-cli-bin $(top_builddir)/bin/scilab-cli check-jvm-dep check-libstdcpp-dep
        -@( cd $(top_builddir) ; \
-       echo "$(top_builddir)/bin/scilab-cli -ns -noatomsautoload -f modules/functions/scripts/buildmacros/buildmacros.sce" ; \
-       $(top_builddir)/bin/scilab-cli -ns -noatomsautoload -f modules/functions/scripts/buildmacros/buildmacros.sce) || exit 1
+       echo "$(top_builddir)/bin/scilab-cli -ns -noatomsautoload -quit -f modules/functions/scripts/buildmacros/buildmacros.sce" ; \
+       $(top_builddir)/bin/scilab-cli -ns -noatomsautoload -quit -f modules/functions/scripts/buildmacros/buildmacros.sce) || exit 1
 
 
 check-jvm-dep:
index 81db25a..0169d77 100644 (file)
@@ -2136,8 +2136,8 @@ all-local: $(TARGETS_ALL)
 
 macros: $(top_builddir)/scilab-cli-bin $(top_builddir)/bin/scilab-cli check-jvm-dep check-libstdcpp-dep
        -@( cd $(top_builddir) ; \
-       echo "$(top_builddir)/bin/scilab-cli -ns -noatomsautoload -f modules/functions/scripts/buildmacros/buildmacros.sce" ; \
-       $(top_builddir)/bin/scilab-cli -ns -noatomsautoload -f modules/functions/scripts/buildmacros/buildmacros.sce) || exit 1
+       echo "$(top_builddir)/bin/scilab-cli -ns -noatomsautoload -quit -f modules/functions/scripts/buildmacros/buildmacros.sce" ; \
+       $(top_builddir)/bin/scilab-cli -ns -noatomsautoload -quit -f modules/functions/scripts/buildmacros/buildmacros.sce) || exit 1
 
 check-jvm-dep:
 # Check that scilab-cli does not have a dependency on libjvm
index a4e0117..52df28c 100644 (file)
@@ -15,7 +15,7 @@ function y = acot(x)
     if rhs <> 1 then
         error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "acot", 1));
     end
-    
+
     if type(x) <> 1 then
         error(msprintf(gettext("%s: Wrong type for input argument #%d: Real or complex matrix expected.\n"), "acot", 1));
     end
index b6d6b0f..bddf2b2 100644 (file)
 // Unrelated error message when running genlib on a sci file containing a scilab function
 // with a missing parenthesis
 // Error: "mprintf: wrong number of input arguments: data do not fit with format"
+// <-- CLI SHELL MODE -->
 my_function = ["function test()";"foo(";"endfunction"];
 my_dir      = pathconvert(TMPDIR+"/bug12593_dir");
 my_file     = my_dir+"test.sci";
 mkdir(my_dir);
 mputl(my_function,my_file);
-errmsg=msprintf(gettext("%s: Error in file %s.\n"), "genlib", my_file);
-assert_checkerror("genlib(""bug_12593_dir"", TMPDIR+""/bug12593_dir"",%T)",errmsg);
+[a,b,c,d]=genlib("bug_12593_dir", TMPDIR+"/bug12593_dir",%T);
+assert_checkequal(my_file,d);
index ca63140..a3ce164 100644 (file)
@@ -22,6 +22,5 @@ my_file     = my_dir+"test.sci";
 mkdir(my_dir);
 mputl(my_function,my_file);
 
-errmsg=msprintf(gettext("%s: Error in file %s.\n"), "genlib", my_file);
-assert_checkerror("genlib(""bug_12593_dir"", TMPDIR+""/bug12593_dir"",%T)",errmsg);
-
+[a,b,c,d]=genlib("bug_12593_dir", TMPDIR+"/bug12593_dir",%T);
+assert_checkequal(my_file,d);
index 48ab6d1..468a315 100644 (file)
@@ -20,7 +20,6 @@ f = ["function [t] = macrobug(z)"; "t=z/"; "endfunction"];
 mputl(f,TMPDIR+"/bug_9059/macrobug.sci");
 cd("bug_9059");
 exec("macrobug.sci","errcatch");
-errmsg=msprintf(gettext("%s: Error in file %s.\n"), "genlib", pathconvert("TMPDIR" +"/bug_9059/macrobug.sci", %f));
-assert_checkerror("genlib(""bug_9059lib"",""TMPDIR/bug_9059"",%f,%t)",errmsg);
+assert_checkerror("genlib(""bug_9059lib"",""TMPDIR/bug_9059"",%f,%t)",[], 999);
 -- Creation of [bug_9059lib] (Macros) --
 genlib: Processing file: macrobug.sci
index 2c36585..4492892 100644 (file)
@@ -24,5 +24,4 @@ mputl(f,TMPDIR+"/bug_9059/macrobug.sci");
 cd("bug_9059");
 exec("macrobug.sci","errcatch");
 
-errmsg=msprintf(gettext("%s: Error in file %s.\n"), "genlib", pathconvert("TMPDIR" +"/bug_9059/macrobug.sci", %f));
-assert_checkerror("genlib(""bug_9059lib"",""TMPDIR/bug_9059"",%f,%t)",errmsg);
+assert_checkerror("genlib(""bug_9059lib"",""TMPDIR/bug_9059"",%f,%t)",[], 999);
index c176660..0c41b51 100644 (file)
@@ -241,8 +241,25 @@ Function::ReturnValue sci_genlib(typed_list &in, int _iRetCount, typed_list &out
             parser.parseFile(stFullPath, ConfigVariable::getSCIPath());
             if (parser.getExitStatus() !=  Parser::Succeded)
             {
-                scilabWriteW(parser.getErrorMessage());
-                sciprint(_("%ls: Error in file %ls.\n"), L"genlib", stFullPath.data());
+                if (_iRetCount != 4)
+                {
+                    std::wstring wstrErr = parser.getErrorMessage();
+
+                    wchar_t errmsg[256];
+                    os_swprintf(errmsg, 256, _W("%ls: Error in file %ls.\n").c_str(), L"genlib", stFullPath.data());
+                    wstrErr += errmsg;
+
+                    char* str = wide_string_to_UTF8(wstrErr.c_str());
+                    Scierror(999, str);
+                    FREE(str);
+
+                    FREE(pstParsePath);
+                    freeArrayOfWideString(pstPath, iNbFile);
+                    closeXMLFile(pWriter);
+                    delete pLib;
+                    return Function::Error;
+                }
+
                 failed_files.push_back(stFullPath);
                 succes = 0;
                 continue;
@@ -296,6 +313,11 @@ Function::ReturnValue sci_genlib(typed_list &in, int _iRetCount, typed_list &out
         else
         {
             Scierror(999, _("Redefining permanent variable.\n"));
+
+            freeArrayOfWideString(pstPath, iNbFile);
+            FREE(pstParsePath);
+            closeXMLFile(pWriter);
+            delete pLib;
             return Function::Error;
         }
     }
@@ -414,6 +436,7 @@ xmlTextWriterPtr openXMLFile(const wchar_t *_pstFilename, const wchar_t* _pstLib
     iLen = xmlTextWriterStartDocument(pWriter, NULL, DEFAULT_ENCODING, "no");
     if (iLen < 0)
     {
+        closeXMLFile(pWriter);
         return NULL;
     }
 
@@ -421,6 +444,7 @@ xmlTextWriterPtr openXMLFile(const wchar_t *_pstFilename, const wchar_t* _pstLib
     iLen = xmlTextWriterStartElement(pWriter, (xmlChar*)"scilablib");
     if (iLen < 0)
     {
+        closeXMLFile(pWriter);
         return NULL;
     }
 
@@ -428,6 +452,7 @@ xmlTextWriterPtr openXMLFile(const wchar_t *_pstFilename, const wchar_t* _pstLib
     iLen = xmlTextWriterWriteAttribute(pWriter, (xmlChar*)"name", (xmlChar*)pstLibName);
     if (iLen < 0)
     {
+        closeXMLFile(pWriter);
         return NULL;
     }