implement predef 01/16301/7
Antoine ELIAS [Tue, 31 Mar 2015 15:35:25 +0000 (17:35 +0200)]
Change-Id: Icbe59644144918e9e84ba7c50537fd7308507875

50 files changed:
scilab/etc/scilab.start
scilab/modules/api_scilab/includes/api_error.h
scilab/modules/api_scilab/src/cpp/api_boolean.cpp
scilab/modules/api_scilab/src/cpp/api_boolean_sparse.cpp
scilab/modules/api_scilab/src/cpp/api_common.cpp
scilab/modules/api_scilab/src/cpp/api_double.cpp
scilab/modules/api_scilab/src/cpp/api_int.cpp
scilab/modules/api_scilab/src/cpp/api_list.cpp
scilab/modules/api_scilab/src/cpp/api_pointer.cpp
scilab/modules/api_scilab/src/cpp/api_poly.cpp
scilab/modules/api_scilab/src/cpp/api_sparse.cpp
scilab/modules/api_scilab/src/cpp/api_string.cpp
scilab/modules/ast/includes/symbol/context.hxx
scilab/modules/ast/includes/symbol/libraries.hxx
scilab/modules/ast/includes/symbol/variables.hxx
scilab/modules/ast/includes/types/library.hxx
scilab/modules/ast/src/cpp/ast/run_AssignExp.hpp
scilab/modules/ast/src/cpp/ast/runvisitor.cpp
scilab/modules/ast/src/cpp/ast/visitor_common.cpp
scilab/modules/ast/src/cpp/symbol/context.cpp
scilab/modules/ast/src/cpp/types/library.cpp
scilab/modules/core/Makefile.am
scilab/modules/core/Makefile.in
scilab/modules/core/includes/core_gw.hxx
scilab/modules/core/sci_gateway/cpp/core_gw.cpp
scilab/modules/core/sci_gateway/cpp/core_gw.vcxproj
scilab/modules/core/sci_gateway/cpp/core_gw.vcxproj.filters
scilab/modules/core/sci_gateway/cpp/sci_clear.cpp
scilab/modules/core/sci_gateway/cpp/sci_predef.cpp [new file with mode: 0644]
scilab/modules/core/sci_gateway/cpp/sci_who.cpp
scilab/modules/core/src/cpp/getfunctionsname.cpp
scilab/modules/core/src/cpp/getmacrosname.cpp
scilab/modules/core/src/cpp/getvariablesname.cpp
scilab/modules/core/tests/unit_tests/predef.dia.ref
scilab/modules/core/tests/unit_tests/predef.tst
scilab/modules/core/tests/unit_tests/predef_names.dia.ref
scilab/modules/core/tests/unit_tests/predef_names.tst
scilab/modules/development_tools/macros/test_run.sci
scilab/modules/development_tools/macros/yasp_run.sci [deleted file]
scilab/modules/functions/sci_gateway/cpp/sci_functionlist.cpp
scilab/modules/functions/sci_gateway/cpp/sci_librarieslist.cpp
scilab/modules/functions/sci_gateway/cpp/sci_libraryinfo.cpp
scilab/modules/functions/sci_gateway/cpp/sci_whereis.cpp
scilab/modules/io/macros/getscilabkeywords.sci
scilab/modules/io/sci_gateway/cpp/sci_genlib.cpp
scilab/modules/io/src/cpp/loadlib.cpp
scilab/modules/matio/macros/savematfile.sci
scilab/modules/string/sci_gateway/cpp/sci_string.cpp
scilab/modules/types/sci_gateway/cpp/sci_inspectorGetFunctionList.cpp
scilab/modules/ui_data/src/cpp/BrowseVarManager.cpp

index d916575..b53e9cb 100644 (file)
@@ -77,6 +77,10 @@ if with_module("atoms") then
   clear atomsSystemInit;
 end
 
+
+// Protect variable previously defined  ================================
+predef("all");
+
 // At startup, no interactive vertical paging by default. ==============
 lines(0);
 
index 5d6efbb..40db021 100644 (file)
@@ -20,9 +20,9 @@
 extern "C" {
 #endif
 
-    /*api list error*/
+/*api list error*/
 
-    /*common error 1 - 99*/
+/*common error 1 - 99*/
 #define API_ERROR_INVALID_POINTER                           1
 #define API_ERROR_INVALID_TYPE                              2
 #define API_ERROR_NOT_MATRIX_TYPE                           3
@@ -52,8 +52,9 @@ extern "C" {
 #define API_ERROR_IS_NAMED_SCALAR                           70
 #define API_ERROR_IS_NAMED_SQUARE                           71
 #define API_ERROR_CHECK_NAMED_VAR_DIMENSION                 72
+#define API_ERROR_REDEFINE_PERMANENT_VAR                  73
 
-    /*double errors 101 - 199*/
+/*double errors 101 - 199*/
 #define API_ERROR_GET_DOUBLE                                101
 #define API_ERROR_GET_ZDOUBLE                               102
 #define API_ERROR_ALLOC_DOUBLE                              103
@@ -69,7 +70,7 @@ extern "C" {
 #define API_ERROR_CREATE_SCALAR_FROM_INTEGER                120
 #define API_ERROR_CREATE_MATRIX_FROM_INTEGER                121
 
-    /*poly errors 201 - 299*/
+/*poly errors 201 - 299*/
 #define API_ERROR_GET_POLY_VARNAME                          201
 #define API_ERROR_GET_POLY                                  202
 #define API_ERROR_CREATE_POLY                               203
@@ -81,7 +82,7 @@ extern "C" {
 #define API_ERROR_GET_ALLOC_MATRIX_POLY                     211
 #define API_ERROR_GET_ALLOC_NAMED_MATRIX_POLY               212
 
-    /*boolean errors 401 - 499*/
+/*boolean errors 401 - 499*/
 #define API_ERROR_GET_BOOLEAN                               401
 #define API_ERROR_CREATE_BOOLEAN                            402
 #define API_ERROR_CREATE_NAMED_BOOLEAN                      403
@@ -89,7 +90,7 @@ extern "C" {
 #define API_ERROR_CREATE_SCALAR_BOOLEAN                     405
 #define API_ERROR_CREATE_NAMED_SCALAR_BOOLEAN               406
 
-    /*sparse errors 501 - 599*/
+/*sparse errors 501 - 599*/
 #define API_ERROR_GET_SPARSE                                501
 #define API_ERROR_ALLOC_SPARSE                              502
 #define API_ERROR_CREATE_SPARSE                             504
@@ -98,7 +99,7 @@ extern "C" {
 #define API_ERROR_GET_ALLOC_SPARSE                          507
 #define API_ERROR_GET_NAMED_ALLOC_SPARSE                    508
 
-    /*boolean sparse errors 601 - 699*/
+/*boolean sparse errors 601 - 699*/
 #define API_ERROR_GET_BOOLEAN_SPARSE                        601
 #define API_ERROR_ALLOC_BOOLEAN_SPARSE                      602
 #define API_ERROR_FILL_BOOLEAN_SPARSE                       603
@@ -110,9 +111,9 @@ extern "C" {
 #define API_ERROR_GET_ALLOC_BOOLEAN_SPARSE                  611
 #define API_ERROR_GET_NAMED_ALLOC_BOOLEAN_SPARSE            612
 
-    /*matlab sparse errors 701 - 799*/
+/*matlab sparse errors 701 - 799*/
 
-    /*ints errors 801 - 899*/
+/*ints errors 801 - 899*/
 #define API_ERROR_GET_INT                                   802
 #define API_ERROR_CREATE_INT                                803
 #define API_ERROR_ALLOC_INT                                 804
@@ -123,13 +124,13 @@ extern "C" {
 #define API_ERROR_CREATE_SCALAR_INT                         809
 #define API_ERROR_CREATE_NAMED_SCALAR_INT                   810
 
-    /*handles errors 901 - 999*/
+/*handles errors 901 - 999*/
 #define API_ERROR_GET_HANDLE                                902
 #define API_ERROR_CREATE_HANDLE                             903
 #define API_ERROR_GET_SCALAR_HANDLE                         907
 #define API_ERROR_CREATE_SCALAR_HANDLE                      909
 
-    /*strings errors 1001 - 1099*/
+/*strings errors 1001 - 1099*/
 #define API_ERROR_GET_STRING                                1001
 #define API_ERROR_INVALID_SUBSTRING_POINTER                 1002
 #define API_ERROR_CREATE_STRING                             1003
@@ -152,7 +153,7 @@ extern "C" {
 #define API_ERROR_CREATE_NAMED_SINGLE_STRING                1021
 #define API_ERROR_CREATE_NAMED_SINGLE_WIDE_STRING           1022
 
-    /*list errors 1501 - 1599*/
+/*list errors 1501 - 1599*/
 #define API_ERROR_LIST_ITEM_NUMBER                          1501
 #define API_ERROR_INVALID_LIST_TYPE                         1502
 #define API_ERROR_GET_ITEM_ADDRESS                          1503
@@ -167,7 +168,7 @@ extern "C" {
 #define API_ERROR_NON_ORDERED_INSERTION                     1512
 #define API_ERROR_ALLOC_IN_LIST                             1513
 #define API_ERROR_CREATE_VOID_IN_LIST                       1514
-    /*double in list*/
+/*double in list*/
 #define API_ERROR_GET_DOUBLE_IN_LIST                        1520
 #define API_ERROR_ALLOC_DOUBLE_IN_LIST                      1521
 #define API_ERROR_CREATE_ZDOUBLE_IN_LIST                    1523
@@ -176,14 +177,14 @@ extern "C" {
 #define API_ERROR_CREATE_DOUBLE_IN_NAMED_LIST               1526
 #define API_ERROR_READ_DOUBLE_IN_NAMED_LIST                 1527
 
-    /*string in list*/
+/*string in list*/
 #define API_ERROR_GET_STRING_IN_LIST                        1530
 #define API_ERROR_FILL_STRING_IN_LIST                       1531
 #define API_ERROR_CREATE_STRING_IN_LIST                     1532
 #define API_ERROR_CREATE_STRING_IN_NAMED_LIST               1534
 #define API_ERROR_READ_STRING_IN_NAMED_LIST                 1535
 
-    /*boolean in list*/
+/*boolean in list*/
 #define API_ERROR_GET_BOOLEAN_IN_LIST                       1540
 #define API_ERROR_CREATE_BOOLEAN_IN_LIST                    1541
 #define API_ERROR_ALLOC_BOOLEAN_IN_LIST                     1542
@@ -191,14 +192,14 @@ extern "C" {
 #define API_ERROR_CREATE_BOOLEAN_IN_NAMED_LIST              1544
 #define API_ERROR_READ_BOOLEAN_IN_NAMED_LIST                1545
 
-    /*poly in list*/
+/*poly in list*/
 #define API_ERROR_GET_POLY_IN_LIST                          1550
 #define API_ERROR_CREATE_POLY_IN_LIST                       1551
 #define API_ERROR_FILL_POLY_IN_LIST                         1552
 #define API_ERROR_CREATE_POLY_IN_NAMED_LIST                 1553
 #define API_ERROR_READ_POLY_IN_NAMED_LIST                   1554
 
-    /*int in list*/
+/*int in list*/
 #define API_ERROR_FILL_INT_IN_LIST                          1560
 #define API_ERROR_ALLOC_INT_IN_LIST                         1561
 #define API_ERROR_CREATE_INT_IN_LIST                        1562
@@ -206,38 +207,38 @@ extern "C" {
 #define API_ERROR_CREATE_INT_IN_NAMED_LIST                  1564
 #define API_ERROR_READ_INT_IN_NAMED_LIST                    1565
 
-    /*sparse in list*/
+/*sparse in list*/
 #define API_ERROR_FILL_SPARSE_IN_LIST                       1570
 #define API_ERROR_CREATE_SPARSE_IN_LIST                     1571
 #define API_ERROR_CREATE_SPARSE_IN_NAMED_LIST               1572
 #define API_ERROR_GET_SPARSE_IN_LIST                        1573
 #define API_ERROR_READ_SPARSE_IN_NAMED_LIST                 1574
 
-    /*boolean sparse in list*/
+/*boolean sparse in list*/
 #define API_ERROR_FILL_BOOLEAN_SPARSE_IN_LIST               1580
 #define API_ERROR_CREATE_BOOLEAN_SPARSE_IN_LIST             1581
 #define API_ERROR_CREATE_BOOLEAN_SPARSE_IN_NAMED_LIST       1582
 #define API_ERROR_GET_BOOLEAN_SPARSE_IN_LIST                1583
 #define API_ERROR_READ_BOOLEAN_SPARSE_IN_NAMED_LIST         1584
 
-    /*pointer in list*/
+/*pointer in list*/
 #define API_ERROR_GET_POINTER_IN_LIST                       1590
 #define API_ERROR_CREATE_POINTER_IN_NAMED_LIST              1591
 #define API_ERROR_READ_POINTER_IN_NAMED_LIST                1592
 #define API_ERROR_CREATE_POINTER_IN_LIST                    1593
 
-    /*pointer errors 12801 - 12899*/
+/*pointer errors 12801 - 12899*/
 #define API_ERROR_GET_POINTER                               12801
 #define API_ERROR_ALLOC_POINTER                             12803
 #define API_ERROR_CREATE_POINTER                            12804
 #define API_ERROR_CREATE_NAMED_POINTER                      12805
 #define API_ERROR_READ_POINTER                              12806
 
-    /* error functions*/
-    int addStackSizeError(SciErr* _psciErr, char* _pstCaller, int iNeeded);
-    int addErrorMessage(SciErr* _psciErr, int _iErr, const char* _pstMsg, ...);
-    int printError(SciErr* _psciErr, int _iLastMsg);
-    char* getErrorMessage(SciErr _sciErr);
+/* error functions*/
+int addStackSizeError(SciErr* _psciErr, char* _pstCaller, int iNeeded);
+int addErrorMessage(SciErr* _psciErr, int _iErr, const char* _pstMsg, ...);
+int printError(SciErr* _psciErr, int _iLastMsg);
+char* getErrorMessage(SciErr _sciErr);
 
 #ifdef __cplusplus
 }
index 0675bae..cde8a82 100644 (file)
@@ -164,8 +164,20 @@ SciErr createNamedMatrixOfBoolean(void* _pvCtx, const char* _pstName, int _iRows
 
     wchar_t* pwstName = to_wide_string(_pstName);
     pBool->set(_piBool);
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pBool);
+
+    symbol::Context* ctx = symbol::Context::getInstance();
+    symbol::Symbol sym = symbol::Symbol(pwstName);
     FREE(pwstName);
+    if (ctx->isprotected(sym) == false)
+    {
+        ctx->put(sym, pBool);
+    }
+    else
+    {
+        delete pBool;
+        addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
+    }
+
     return sciErr;
 }
 
index dc0d7e4..5e6c1b2 100644 (file)
@@ -185,8 +185,18 @@ SciErr createNamedBooleanSparseMatrix(void* _pvCtx, const char* _pstName, int _i
     sciErr = fillBooleanSparseMatrix(_pvCtx, (int*)pSparse, _iRows, _iCols, _iNbItem, _piNbItemRow, _piColPos);
 
     wchar_t* pwstName = to_wide_string(_pstName);
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pSparse);
+    symbol::Context* ctx = symbol::Context::getInstance();
+    symbol::Symbol sym = symbol::Symbol(pwstName);
     FREE(pwstName);
+    if (ctx->isprotected(sym) == false)
+    {
+        ctx->put(sym, pSparse);
+    }
+    else
+    {
+        delete pSparse;
+        addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
+    }
     return sciErr;
 }
 
index ae75349..fe7abd4 100644 (file)
@@ -1540,9 +1540,18 @@ int deleteNamedVariable(void* _pvCtx, const char* _pstName)
     }
 
     wchar_t* pwstName = to_wide_string(_pstName);
-    symbol::Context* pCtx = symbol::Context::getInstance();
-    bool ret = pCtx->remove(symbol::Symbol(pwstName));
+    symbol::Context* ctx = symbol::Context::getInstance();
+    symbol::Symbol sym = symbol::Symbol(pwstName);
     FREE(pwstName);
+    bool ret = false;
+    if (ctx->isprotected(sym) == false)
+    {
+        ret = ctx->remove(symbol::Symbol(pwstName));
+    }
+    else
+    {
+        addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
+    }
 
     return ret ? 1 : 0;
 }
index 266a9e4..2cec68d 100644 (file)
@@ -424,8 +424,19 @@ SciErr createNamedComplexZMatrixOfDouble(void* _pvCtx, const char* _pstName, int
     C2F(dcopy)(&iSize, const_cast<double*>(&_pdblData->i), &iOne, pdblImg, &iOne);
 
     wchar_t* pwstName = to_wide_string(_pstName);
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pDbl);
+    symbol::Context* ctx = symbol::Context::getInstance();
+    symbol::Symbol sym = symbol::Symbol(pwstName);
     FREE(pwstName);
+    if (ctx->isprotected(sym) == false)
+    {
+        ctx->put(sym, pDbl);
+    }
+    else
+    {
+        delete pDbl;
+        addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
+    }
+
     return sciErr;
 }
 
@@ -453,8 +464,18 @@ SciErr createCommonNamedMatrixOfDouble(void* _pvCtx, const char* _pstName, int _
         C2F(dcopy)(&iSize, const_cast<double*>(_pdblImg), &iOne, pdblImg, &iOne);
     }
 
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pDbl);
+    symbol::Context* ctx = symbol::Context::getInstance();
+    symbol::Symbol sym = symbol::Symbol(pwstName);
     FREE(pwstName);
+    if (ctx->isprotected(sym) == false)
+    {
+        ctx->put(sym, pDbl);
+    }
+    else
+    {
+        delete pDbl;
+        addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
+    }
     return sciErr;
 }
 
index 02041b5..c2f3556 100644 (file)
@@ -835,8 +835,18 @@ SciErr createCommonNamedMatrixOfInteger(void* _pvCtx, const char* _pstName, int
     }
 
     wchar_t* pwstName = to_wide_string(_pstName);
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pIT);
+    symbol::Context* ctx = symbol::Context::getInstance();
+    symbol::Symbol sym = symbol::Symbol(pwstName);
     FREE(pwstName);
+    if (ctx->isprotected(sym) == false)
+    {
+        ctx->put(sym, pIT);
+    }
+    else
+    {
+        delete pIT;
+        addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
+    }
     return sciErr;
 }
 
index 9972360..b495012 100644 (file)
@@ -261,8 +261,18 @@ static SciErr createCommonNamedList(void* _pvCtx, const char* _pstName, int _iLi
     pL->set(_iNbItem - 1, new ListUndefined());
 
     wchar_t* pwstName = to_wide_string(_pstName);
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pL);
+    symbol::Context* ctx = symbol::Context::getInstance();
+    symbol::Symbol sym = symbol::Symbol(pwstName);
     FREE(pwstName);
+    if (ctx->isprotected(sym) == false)
+    {
+        ctx->put(sym, pL);
+    }
+    else
+    {
+        delete pL;
+        addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
+    }
     return sciErr;
 }
 
index fc9c089..8e896e6 100644 (file)
@@ -105,7 +105,18 @@ SciErr createNamedPointer(void* _pvCtx, const char* _pstName, void* _pvPtr)
     wchar_t* pwstName = to_wide_string(_pstName);
 
     Pointer* pP = new Pointer(_pvPtr);
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pP);
+    symbol::Context* ctx = symbol::Context::getInstance();
+    symbol::Symbol sym = symbol::Symbol(pwstName);
+    FREE(pwstName);
+    if (ctx->isprotected(sym) == false)
+    {
+        ctx->put(sym, pP);
+    }
+    else
+    {
+        delete pP;
+        addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
+    }
     FREE(pwstName);
 
     return sciErr;
index a3f1324..c959ca1 100644 (file)
@@ -287,8 +287,18 @@ SciErr createCommonNamedMatrixOfPoly(void* _pvCtx, const char* _pstName, char* _
     }
 
     wchar_t* pwstName = to_wide_string(_pstName);
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pP);
+    symbol::Context* ctx = symbol::Context::getInstance();
+    symbol::Symbol sym = symbol::Symbol(pwstName);
     FREE(pwstName);
+    if (ctx->isprotected(sym) == false)
+    {
+        ctx->put(sym, pP);
+    }
+    else
+    {
+        delete pP;
+        addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
+    }
     return sciErr;
 }
 
index 6c1c9eb..f64910e 100644 (file)
@@ -301,8 +301,18 @@ SciErr createCommonNamedSparseMatrix(void* _pvCtx, const char* _pstName, int _iC
 
 
     wchar_t* pwstName = to_wide_string(_pstName);
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pSparse);
+    symbol::Context* ctx = symbol::Context::getInstance();
+    symbol::Symbol sym = symbol::Symbol(pwstName);
     FREE(pwstName);
+    if (ctx->isprotected(sym) == false)
+    {
+        ctx->put(sym, pSparse);
+    }
+    else
+    {
+        delete pSparse;
+        addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
+    }
     return sciErr;
 }
 
index 7daa1de..be1d71d 100644 (file)
@@ -194,9 +194,18 @@ SciErr createNamedMatrixOfString(void* _pvCtx, const char* _pstName, int _iRows,
     }
 
     wchar_t* pwstName = to_wide_string(_pstName);
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pS);
+    symbol::Context* ctx = symbol::Context::getInstance();
+    symbol::Symbol sym = symbol::Symbol(pwstName);
     FREE(pwstName);
-
+    if (ctx->isprotected(sym) == false)
+    {
+        ctx->put(sym, pS);
+    }
+    else
+    {
+        delete pS;
+        addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
+    }
     return sciErr;
 }
 /*--------------------------------------------------------------------------*/
@@ -358,9 +367,18 @@ SciErr createNamedMatrixOfWideString(void* _pvCtx, const char* _pstName, int _iR
     }
 
     wchar_t* pwstName = to_wide_string(_pstName);
-    symbol::Context::getInstance()->put(symbol::Symbol(pwstName), pS);
+    symbol::Context* ctx = symbol::Context::getInstance();
+    symbol::Symbol sym = symbol::Symbol(pwstName);
     FREE(pwstName);
-
+    if (ctx->isprotected(sym) == false)
+    {
+        ctx->put(sym, pS);
+    }
+    else
+    {
+        delete pS;
+        addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
+    }
     return sciErr;
 }
 /*--------------------------------------------------------------------------*/
index d76d5fc..9f72cf6 100644 (file)
@@ -71,17 +71,17 @@ public :
     types::InternalType* getFunction(const Symbol& key);
 
     /*return function list in the module _stModuleName*/
-    std::list<Symbol>* getFunctionList(std::wstring _stModuleName);
-
-    std::list<std::wstring>*    getVarsName();
-    std::list<std::wstring>*    getMacrosName();
-    std::list<std::wstring>*    getFunctionsName();
-    std::list<std::wstring>*    getVarsNameForWho(bool sorted);
-    std::list<std::wstring>*    getGlobalNameForWho(bool sorted);
-    std::list<std::wstring>*    getWhereIs(const std::wstring& _str);
-    std::list<std::wstring>*    getLibrariesList();
-    std::list<Variable*>*       getVarsToVariableBrowser();
-    std::list<Library*>*        getLibsToVariableBrowser();
+    int getFunctionList(std::list<Symbol>& lst, std::wstring _stModuleName);
+
+    int getVarsName(std::list<std::wstring>& lst);
+    int getMacrosName(std::list<std::wstring>& lst);
+    int getFunctionsName(std::list<std::wstring>& lst);
+    int getVarsNameForWho(std::list<std::wstring>& lst, bool sorted);
+    int getGlobalNameForWho(std::list<std::wstring>& lst, bool sorted);
+    int getWhereIs(std::list<std::wstring>& lst, const std::wstring& _str);
+    int getLibrariesList(std::list<std::wstring>& lst);
+    int getVarsToVariableBrowser(std::list<Variable*>& lst);
+    int getLibsToVariableBrowser(std::list<Library*>& lst);
     /* global functions */
 
     /*return global variable visibility status*/
@@ -97,9 +97,15 @@ public :
     /*remove all global variables and references */
     //clearglobal
     void removeGlobalAll();
-
     void clearAll();
 
+    //predef
+    void protect();
+    void unprotect();
+    bool isprotected(const Symbol& key);
+    bool isprotected(Variable* _var);
+    int protectedVars(std::list<std::wstring>& lst);
+
     /*set variable visible/hidden in current global scope*/
     void setGlobalVisible(const Symbol& key, bool bVisible);
     void setGlobal(const Symbol& key);
@@ -129,6 +135,7 @@ private:
 
     types::InternalType* get(const Symbol& key, int _iLevel);
     bool clearCurrentScope(bool _bClose);
+    void updateProtection(bool protect);
 
     std::list<Symbol>* globals;
     VarStack varStack;
index 8bab2f6..b2a2e5f 100644 (file)
@@ -71,14 +71,14 @@ struct Library
         return NULL;
     }
 
-    std::list<std::wstring>* getMacrosName()
+    int getMacrosName(std::list<std::wstring>& lst)
     {
         if (empty() == false)
         {
-            return top()->m_pLib->getMacrosName();
+            top()->m_pLib->getMacrosName(lst);
         }
 
-        return new std::list<std::wstring>();
+        return static_cast<int>(lst.size());
     }
 
     bool empty() const
@@ -192,47 +192,42 @@ struct Libraries
         return false;
     }
 
-    std::list<std::wstring>* getMacrosName()
+    int getMacrosName(std::list<std::wstring>& lst)
     {
-        std::list<std::wstring>* names = new std::list<std::wstring>();
         MapLibs::iterator it = libs.begin();
         MapLibs::iterator itEnd = libs.end();
-        for (; it != itEnd ; ++it)
+        for (auto it : libs)
         {
-            std::list<std::wstring>* temp = it->second->getMacrosName();
-            names->insert(names->end(), temp->begin(), temp->end());
-            delete temp;
+            it.second->getMacrosName(lst);
         }
 
-        return names;
+        return static_cast<int>(lst.size());
     }
 
-    std::list<std::wstring>* getVarsName()
+    int getVarsName(std::list<std::wstring>& lst)
     {
-        std::list<std::wstring>* plOut = new std::list<std::wstring>();
-        for (auto it = libs.begin(), itEnd = libs.end(); it != itEnd; ++it)
+        for (auto it : libs)
         {
-            if (it->second->empty() == false)
+            if (it.second->empty() == false)
             {
-                plOut->push_back(it->first.getName().c_str());
+                lst.push_back(it.first.getName().c_str());
             }
         }
 
-        return plOut;
+        return static_cast<int>(lst.size());
     }
 
-    std::list<Library*>* getVarsToVariableBrowser()
+    int getVarsToVariableBrowser(std::list<Library*>& lst)
     {
-        std::list<Library*>* lst = new std::list<Library*>();
         for (auto lib : libs)
         {
             if (lib.second->empty() == false)
             {
-                lst->push_back(lib.second);
+                lst.push_back(lib.second);
             }
         }
 
-        return lst;
+        return static_cast<int>(lst.size());
     }
 
     void clearAll()
@@ -276,30 +271,26 @@ struct Libraries
         return true;
     }
 
-    std::list<std::wstring>* whereis(const Symbol& _key)
+    int whereis(std::list<std::wstring>& lst, const Symbol& _key)
     {
-        std::list<std::wstring>* ret = new std::list<std::wstring>();
-
         for (auto lib : libs)
         {
             if (lib.second->get(_key) != NULL)
             {
-                ret->push_back(lib.first.getName());
+                lst.push_back(lib.first.getName());
             }
         }
-        return ret;
+        return static_cast<int>(lst.size());
     }
 
-    std::list<std::wstring>* librarieslist()
+    int librarieslist(std::list<std::wstring>& lst)
     {
-        std::list<std::wstring>* ret = new std::list<std::wstring>();
-
         for (auto lib : libs)
         {
-            ret->push_back(lib.first.getName());
+            lst.push_back(lib.first.getName());
         }
 
-        return ret;
+        return static_cast<int>(lst.size());
     }
 
 private:
index 2d5dc9c..f9c1b99 100644 (file)
@@ -24,11 +24,12 @@ namespace symbol
 struct ScopedVariable
 {
     ScopedVariable(int _iLevel, types::InternalType* _pIT)
-        : m_iLevel(_iLevel), m_pIT(_pIT), m_globalVisible(false) {}
+        : m_iLevel(_iLevel), m_pIT(_pIT), m_globalVisible(false), protect(false) {}
 
     int m_iLevel;
     types::InternalType* m_pIT;
     bool m_globalVisible;
+    bool protect;
 };
 
 struct Variable
@@ -295,108 +296,123 @@ struct Variables
         return false;
     }
 
-    std::list<std::wstring>* getMacrosName()
+    int getMacrosName(std::list<std::wstring>& lst)
     {
-        std::list<std::wstring>* plOut = new std::list<std::wstring>();
-        MapVars::const_iterator it = vars.begin();
-        for (; it != vars.end(); ++it)
+        for (auto it : vars)
         {
-            if (it->second->empty() == false)
+            if (it.second->empty() == false)
             {
-                types::InternalType* pIT = it->second->top()->m_pIT;
+                types::InternalType* pIT = it.second->top()->m_pIT;
                 if (pIT && (pIT->isMacro() || pIT->isMacroFile()))
                 {
-                    plOut->push_back(it->first.getName().c_str());
+                    lst.push_back(it.first.getName().c_str());
                 }
             }
         }
 
-        return plOut;
+        return static_cast<int>(lst.size());
     }
 
-    std::list<std::wstring>* getVarsName()
+    int getVarsName(std::list<std::wstring>& lst)
     {
-        std::list<std::wstring>* plOut = new std::list<std::wstring>();
-        MapVars::const_iterator it = vars.begin();
-        for (; it != vars.end(); ++it)
+        for (auto it : vars)
         {
-            if (it->second->empty() == false)
+            if (it.second->empty() == false)
             {
-                types::InternalType* pIT = it->second->top()->m_pIT;
+                types::InternalType* pIT = it.second->top()->m_pIT;
                 if (pIT &&
                         pIT->isMacro() == false &&
                         pIT->isMacroFile() == false &&
                         pIT->isFunction() == false)
                 {
-                    plOut->push_back(it->first.getName().c_str());
+                    lst.push_back(it.first.getName().c_str());
                 }
             }
         }
 
-        return plOut;
+        return static_cast<int>(lst.size());
     }
 
-    bool getVarsNameForWho(std::list<std::wstring>* lstVarName, int* iVarLenMax, std::list<std::wstring>* lstGlobalVarName, int* iGlobalLenMax, bool bSorted = false) const
+    bool getVarsNameForWho(std::list<std::wstring>& lstVarName, int* iVarLenMax, bool bSorted = false) const
     {
-        for (auto it = vars.begin(), itEnd = vars.end(); it != itEnd; ++it)
+        for (auto it : vars)
         {
-            std::wstring wstrVarName(it->first.getName().c_str());
-            if (lstVarName && it->second->empty() == false)
+            std::wstring wstrVarName(it.first.getName().c_str());
+            if (it.second->empty() == false)
             {
-                types::InternalType* pIT = it->second->top()->m_pIT;
+                types::InternalType* pIT = it.second->top()->m_pIT;
                 if (pIT && pIT->isFunction() == false)
                 {
-                    lstVarName->push_back(wstrVarName);
+                    lstVarName.push_back(wstrVarName);
                     *iVarLenMax = std::max(*iVarLenMax, (int)wstrVarName.size());
                 }
             }
+        }
+
+        if (bSorted)
+        {
+            lstVarName.sort();
+        }
 
-            if (lstGlobalVarName && it->second->isGlobal())
+        return true;
+    }
+
+    bool getGlobalNameForWho(std::list<std::wstring>& lstVarName, int* iVarLenMax, bool bSorted = false) const
+    {
+        for (auto it : vars)
+        {
+            if (it.second->empty() == false && it.second->isGlobal())
             {
-                lstGlobalVarName->push_back(wstrVarName);
-                *iGlobalLenMax = std::max(*iGlobalLenMax, (int)wstrVarName.size());
+                std::wstring wstrVarName(it.first.getName().c_str());
+                lstVarName.push_back(wstrVarName);
+                *iVarLenMax = std::max(*iVarLenMax, (int)wstrVarName.size());
             }
         }
 
         if (bSorted)
         {
-            if (lstVarName)
-            {
-                lstVarName->sort();
-            }
+            lstVarName.sort();
+        }
+
+        return true;
+    }
 
-            if (lstGlobalVarName)
+    int getProtectedVarsName(std::list<std::wstring>& lstVarName) const
+    {
+        for (auto it : vars)
+        {
+            if (it.second->empty() == false)
             {
-                lstGlobalVarName->sort();
+                ScopedVariable* pSV = it.second->top();
+                if (pSV->protect && it.first.getName() != L"ans")
+                {
+                    lstVarName.push_back(it.first.getName());
+                }
             }
         }
 
-        return true;
+        return static_cast<int>(lstVarName.size());
     }
 
-    std::list<std::wstring>* getFunctionsName()
+    int getFunctionsName(std::list<std::wstring>& lst)
     {
-        std::list<std::wstring>* plOut = new std::list<std::wstring>();
-        MapVars::const_iterator it = vars.begin();
-        for (; it != vars.end(); ++it)
+        for (auto it : vars)
         {
-            if (it->second->empty() == false)
+            if (it.second->empty() == false)
             {
-                types::InternalType* pIT = it->second->top()->m_pIT;
+                types::InternalType* pIT = it.second->top()->m_pIT;
                 if (pIT && pIT->isFunction())
                 {
-                    plOut->push_back(it->first.getName().c_str());
+                    lst.push_back(it.first.getName().c_str());
                 }
             }
         }
 
-        return plOut;
+        return static_cast<int>(lst.size());
     }
 
-    std::list<Symbol>* getFunctionList(std::wstring _stModuleName, int _iLevel)
+    int getFunctionList(std::list<Symbol>& lst, std::wstring _stModuleName, int _iLevel)
     {
-        std::list<Symbol>* symb = new std::list<Symbol>();
-
         for (auto var : vars)
         {
             if (var.second->empty())
@@ -409,17 +425,16 @@ struct Variables
                 types::Callable* pCall = var.second->top()->m_pIT->getAs<types::Callable>();
                 if (_stModuleName == L"" || _stModuleName == pCall->getModule())
                 {
-                    symb->push_back(var.first);
+                    lst.push_back(var.first);
                 }
             }
         }
 
-        return symb;
+        return static_cast<int>(lst.size());
     }
 
-    std::list<Variable*>* getVarsToVariableBrowser()
+    int getVarsToVariableBrowser(std::list<Variable*>& lst)
     {
-        std::list<Variable*>* lst = new std::list<Variable*>();
         for (auto var : vars)
         {
             if (var.second->empty() == false)
@@ -430,12 +445,12 @@ struct Variables
                         pIT->isMacroFile() == false &&
                         pIT->isFunction() == false)
                 {
-                    lst->push_back(var.second);
+                    lst.push_back(var.second);
                 }
             }
         }
 
-        return lst;
+        return static_cast<int>(lst.size());
     }
 
     bool putInPreviousScope(Variable* _var, types::InternalType* _pIT, int _iLevel)
index e3c782b..66582d5 100644 (file)
@@ -60,7 +60,7 @@ public :
 
     void add(const std::wstring& _wstName, MacroFile* _macro);
     MacroFile* get(const std::wstring& _wstName);
-    std::list<std::wstring>* getMacrosName();
+    int getMacrosName(std::list<std::wstring>& lst);
     std::wstring getPath();
 private:
     std::wstring m_wstPath;
index 3d05127..ac2107b 100644 (file)
@@ -16,6 +16,7 @@ namespace ast {
 template<class T>
 void RunVisitorT<T>::visitprivate(const AssignExp  &e)
 {
+    symbol::Context* ctx = symbol::Context::getInstance();
     /*Create local exec visitor*/
     try
     {
@@ -64,7 +65,17 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
                 if (pIT->isListDelete())
                 {
                     //used to delete a variable in current scope
-                    symbol::Context::getInstance()->remove(pVar->getSymbol());
+                    symbol::Symbol sym = pVar->getSymbol();
+                    if (ctx->isprotected(sym) == false)
+                    {
+                        ctx->remove(sym);
+                    }
+                    else
+                    {
+                        std::wostringstream os;
+                        os << _W("Redefining permanent variable.\n");
+                        throw ast::ScilabError(os.str(), 999, e.getLeftExp().getLocation());
+                    }
                 }
 
                 setResult(NULL);
@@ -83,12 +94,21 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
             if (e.getRightExp().isReturnExp())
             {
                 //ReturnExp so, put the value in the previous scope
-                symbol::Context::getInstance()->putInPreviousScope(pVar->getStack(), pIT);
+                ctx->putInPreviousScope(pVar->getStack(), pIT);
                 ((AssignExp*)&e)->setReturn();
             }
             else
             {
-                symbol::Context::getInstance()->put(pVar->getStack(), pIT);
+                if (ctx->isprotected(pVar->getStack()) == false)
+                {
+                    ctx->put(pVar->getStack(), pIT);
+                }
+                else
+                {
+                    std::wostringstream os;
+                    os << _W("Redefining permanent variable.\n");
+                    throw ast::ScilabError(os.str(), 999, e.getLeftExp().getLocation());
+                }
             }
 
             if (e.isVerbose() && ConfigVariable::isPromptShow())
@@ -408,7 +428,7 @@ void RunVisitorT<T>::visitprivate(const AssignExp  &e)
             {
                 const wstring *pstName = getStructNameFromExp(pField);
 
-                types::InternalType* pPrint = symbol::Context::getInstance()->get(symbol::Symbol(*pstName));
+                types::InternalType* pPrint = ctx->get(symbol::Symbol(*pstName));
                 std::wostringstream ostr;
                 ostr << *pstName << L"  = " << std::endl << std::endl;
                 scilabWriteW(ostr.str().c_str());
index d402573..a26216a 100644 (file)
@@ -411,6 +411,7 @@ void RunVisitorT<T>::visitprivate(const WhileExp  &e)
 template <class T>
 void RunVisitorT<T>::visitprivate(const ForExp  &e)
 {
+    symbol::Context* ctx = symbol::Context::getInstance();
     e.getVardec().accept(*this);
     InternalType* pIT = getResult();
     //allow break and continue operations
@@ -426,7 +427,6 @@ void RunVisitorT<T>::visitprivate(const ForExp  &e)
 
     if (pIT->isImplicitList())
     {
-        symbol::Context* ctx = symbol::Context::getInstance();
         //get IL
         ImplicitList* pVar = pIT->getAs<ImplicitList>();
         //get IL initial Type
@@ -434,6 +434,13 @@ void RunVisitorT<T>::visitprivate(const ForExp  &e)
         //get index stack
         symbol::Variable* var = e.getVardec().getAs<VarDec>()->getStack();
 
+        if (ctx->isprotected(var))
+        {
+            std::wostringstream os;
+            os << _W("Redefining permanent variable.\n");
+            throw ast::ScilabError(os.str(), 999, e.getVardec().getLocation());
+        }
+
         ctx->put(var, pIL);
         //use ref count to lock var against clear and detect any changes
         pIL->IncreaseRef();
@@ -462,8 +469,15 @@ void RunVisitorT<T>::visitprivate(const ForExp  &e)
                     pIL = pVar->getInitalType();
                     //lock loop index
                     pIL->IncreaseRef();
-                    //update me ( must decrease ref of a
-                    symbol::Context::getInstance()->put(var, pIL);
+                    //update me ( must decrease ref of a )
+                    if (ctx->isprotected(var))
+                    {
+                        std::wostringstream os;
+                        os << _W("Redefining permanent variable.\n");
+                        throw ast::ScilabError(os.str(), 999, e.getVardec().getLocation());
+                    }
+
+                    ctx->put(var, pIL);
                     break;
             }
 
@@ -498,10 +512,18 @@ void RunVisitorT<T>::visitprivate(const ForExp  &e)
     {
         List* pL = pIT->getAs<List>();
         const int size = pL->getSize();
+        symbol::Variable* var = e.getVardec().getAs<VarDec>()->getStack();
         for (int i = 0; i < size; ++i)
         {
             InternalType* pNew = pL->get(i);
-            symbol::Context::getInstance()->put(e.getVardec().getAs<VarDec>()->getStack(), pNew);
+
+            if (ctx->isprotected(var))
+            {
+                std::wostringstream os;
+                os << _W("Redefining permanent variable.\n");
+                throw ast::ScilabError(os.str(), 999, e.getVardec().getLocation());
+            }
+            ctx->put(var, pNew);
 
             e.getBody().accept(*this);
             if (e.getBody().isBreak())
@@ -535,6 +557,7 @@ void RunVisitorT<T>::visitprivate(const ForExp  &e)
             throw ScilabError(_W("for expression can only manage 1 or 2 dimensions variables\n"), 999, e.getVardec().getLocation());
         }
 
+        symbol::Variable* var = e.getVardec().getAs<VarDec>()->getStack();
         for (int i = 0; i < pVar->getCols(); i++)
         {
             GenericType* pNew = pVar->getColumnValues(i);
@@ -545,7 +568,13 @@ void RunVisitorT<T>::visitprivate(const ForExp  &e)
                 throw ScilabError(_W("for expression : Wrong type for loop iterator.\n"), 999, e.getVardec().getLocation());
             }
 
-            symbol::Context::getInstance()->put(e.getVardec().getAs<VarDec>()->getStack(), pNew);
+            if (ctx->isprotected(var))
+            {
+                std::wostringstream os;
+                os << _W("Redefining permanent variable.\n");
+                throw ast::ScilabError(os.str(), 999, e.getVardec().getLocation());
+            }
+            ctx->put(var, pNew);
 
             e.getBody().accept(*this);
             if (e.getBody().isBreak())
@@ -1093,7 +1122,7 @@ void RunVisitorT<T>::visitprivate(const TransposeExp &e)
 template <class T>
 void RunVisitorT<T>::visitprivate(const FunctionDec & e)
 {
-
+    symbol::Context* ctx = symbol::Context::getInstance();
     /*
       function foo
       endfunction
@@ -1125,7 +1154,7 @@ void RunVisitorT<T>::visitprivate(const FunctionDec & e)
     int iFuncProt = ConfigVariable::getFuncprot();
     if (iFuncProt != 0)
     {
-        types::InternalType* pITFunc = symbol::Context::getInstance()->get(((FunctionDec&)e).getStack());
+        types::InternalType* pITFunc = ctx->get(((FunctionDec&)e).getStack());
         if (pITFunc && pITFunc->isCallable())
         {
             if (pITFunc->isMacroFile())
@@ -1169,7 +1198,16 @@ void RunVisitorT<T>::visitprivate(const FunctionDec & e)
         throw ScilabError(wstError, 999, e.getLocation());
     }
 
-    symbol::Context::getInstance()->addMacro(pMacro);
+
+    if (ctx->isprotected(symbol::Symbol(pMacro->getName())))
+    {
+        delete pMacro;
+        std::wostringstream os;
+        os << _W("Redefining permanent variable.\n");
+        throw ScilabError(os.str(), 999, e.getLocation());
+    }
+
+    ctx->addMacro(pMacro);
 
 }
 
index 1bde630..5fe2504 100644 (file)
@@ -813,12 +813,21 @@ InternalType* evaluateFields(const ast::Exp* _pExp, std::list<ExpHistory*>& fiel
         //*** get main variable ***//
         std::list<ExpHistory*>::iterator iterFields = fields.begin();
         ExpHistory* pFirstField = *iterFields;
-        InternalType* pIT = symbol::Context::getInstance()->getCurrentLevel(pFirstField->getExp()->getSymbol());
+        symbol::Context* ctx = symbol::Context::getInstance();
+
+        if (ctx->isprotected(pFirstField->getExp()->getSymbol()))
+        {
+            std::wostringstream os;
+            os << _W("Redefining permanent variable.\n");
+            throw ast::ScilabError(os.str(), 999, _pExp->getLocation());
+        }
+
+        InternalType* pIT = ctx->getCurrentLevel(pFirstField->getExp()->getSymbol());
 
         if (pIT == NULL)
         {
             // check if we not redefined a protected variable. (ie: sin(2) = 12 without redefine sin before)
-            symbol::Variable* var = symbol::Context::getInstance()->getOrCreate(pFirstField->getExp()->getSymbol());
+            symbol::Variable* var = ctx->getOrCreate(pFirstField->getExp()->getSymbol());
             if (var->empty() == false && var->top()->m_iLevel == 0)
             {
                 std::wostringstream os;
@@ -830,7 +839,7 @@ InternalType* evaluateFields(const ast::Exp* _pExp, std::list<ExpHistory*>& fiel
             {
                 // a{x}, where "a" doesn't exists
                 pIT = new Cell(1, 1);
-                symbol::Context::getInstance()->put(pFirstField->getExp()->getStack(), pIT);
+                ctx->put(pFirstField->getExp()->getStack(), pIT);
             }
             else if (fields.size() > 1)
             {
@@ -838,7 +847,7 @@ InternalType* evaluateFields(const ast::Exp* _pExp, std::list<ExpHistory*>& fiel
                 //"a" does not exist or it is another type, create it with size 1,1 and return it
                 //create new structure variable
                 pIT = new Struct(1, 1);
-                symbol::Context::getInstance()->put(pFirstField->getExp()->getStack(), pIT);
+                ctx->put(pFirstField->getExp()->getStack(), pIT);
             }
             // else
             // is a call exp
@@ -848,7 +857,7 @@ InternalType* evaluateFields(const ast::Exp* _pExp, std::list<ExpHistory*>& fiel
         else if (pIT->getRef() > 1 && pIT->isHandle() == false)
         {
             pIT = pIT->clone();
-            symbol::Context::getInstance()->put(pFirstField->getExp()->getStack(), pIT);
+            ctx->put(pFirstField->getExp()->getStack(), pIT);
         }
         else if (pIT == _pAssignValue)
         {
@@ -1522,7 +1531,7 @@ InternalType* evaluateFields(const ast::Exp* _pExp, std::list<ExpHistory*>& fiel
 
                 if (pEHParent == NULL)
                 {
-                    symbol::Context::getInstance()->put(pEH->getExp()->getStack(), pEH->getCurrent());
+                    ctx->put(pEH->getExp()->getStack(), pEH->getCurrent());
                     break;
                 }
 
@@ -1641,7 +1650,7 @@ InternalType* evaluateFields(const ast::Exp* _pExp, std::list<ExpHistory*>& fiel
             }
         }
 
-        return symbol::Context::getInstance()->getCurrentLevel(pFirstField->getExp()->getSymbol());
+        return ctx->getCurrentLevel(pFirstField->getExp()->getSymbol());
     }
     catch (ast::ScilabError error)
     {
index 49f44ae..b047f80 100644 (file)
@@ -100,27 +100,37 @@ bool Context::clearCurrentScope(bool _bClose)
     }
 
     VarList* varList = varStack.top();
+    std::list<Symbol> toremove;
     for (auto var : *varList)
     {
-        if (var.second->empty() == false && var.second->top()->m_iLevel == m_iLevel)
+        if (var.second->empty() == false)
         {
-            ScopedVariable * pSV = var.second->top();
-            types::InternalType * pIT = pSV->m_pIT;
-            pIT->DecreaseRef();
-            pIT->killMe();
-            var.second->pop();
-            delete pSV;
+            ScopedVariable* pSV = var.second->top();
+            if (pSV->m_iLevel == m_iLevel && (_bClose || pSV->protect == false))
+            {
+                ScopedVariable * pSV = var.second->top();
+                types::InternalType * pIT = pSV->m_pIT;
+                pIT->DecreaseRef();
+                pIT->killMe();
+                var.second->pop();
+                delete pSV;
+                toremove.push_back(var.first);
+            }
         }
     }
 
-    varList->clear();
-
     if (_bClose)
     {
         delete varList;
         varStack.pop();
     }
-
+    else
+    {
+        for (auto var : toremove)
+        {
+            varList->erase(var);
+        }
+    }
     return true;
 }
 
@@ -194,63 +204,53 @@ types::InternalType* Context::getFunction(const Symbol& _key)
     return get(_key);
 }
 
-std::list<Symbol>* Context::getFunctionList(std::wstring _stModuleName)
+int Context::getFunctionList(std::list<Symbol>& lst, std::wstring _stModuleName)
 {
-    return variables.getFunctionList(_stModuleName, m_iLevel);
+    return variables.getFunctionList(lst, _stModuleName, m_iLevel);
 }
 
-std::list<std::wstring>* Context::getVarsName()
+int Context::getVarsName(std::list<std::wstring>& lst)
 {
-    std::list<std::wstring>* vars = variables.getVarsName();
-    std::list<std::wstring>* libs = libraries.getVarsName();
-    vars->insert(vars->end(), libs->begin(), libs->end());
-    delete libs;
+    variables.getVarsName(lst);
+    libraries.getVarsName(lst);
 
-    for (auto it = globals->begin(), itEnd = globals->end(); it != itEnd; ++it)
-    {
-        vars->push_back((*it).getName());
-    }
-    return vars;
+    return static_cast<int>(lst.size());
 }
 
-std::list<std::wstring>* Context::getMacrosName()
+int Context::getMacrosName(std::list<std::wstring>& lst)
 {
-    std::list<std::wstring>* vars = variables.getMacrosName();
-    std::list<std::wstring>* libs = libraries.getMacrosName();
-    vars->insert(vars->end(), libs->begin(), libs->end());
-    delete libs;
-    return vars;
+    variables.getMacrosName(lst);
+    libraries.getMacrosName(lst);
+    return static_cast<int>(lst.size());
 }
 
-std::list<std::wstring>* Context::getFunctionsName()
+int Context::getFunctionsName(std::list<std::wstring>& lst)
 {
-    return variables.getFunctionsName();
+    return variables.getFunctionsName(lst);
 }
 
-std::list<std::wstring>* Context::getVarsNameForWho(bool bSorted)
+int Context::getVarsNameForWho(std::list<std::wstring>& lst, bool bSorted)
 {
-    std::list<std::wstring>* lstVar = new std::list<std::wstring>();
     int iZero = 0;
-    variables.getVarsNameForWho(lstVar, &iZero, NULL, &iZero, bSorted);
-    return lstVar;
+    variables.getVarsNameForWho(lst, &iZero, bSorted);
+    return static_cast<int>(lst.size());
 }
 
-std::list<std::wstring>* Context::getGlobalNameForWho(bool bSorted)
+int Context::getGlobalNameForWho(std::list<std::wstring>& lst, bool bSorted)
 {
-    std::list<std::wstring>* lstVar = new std::list<std::wstring>();
     int iZero = 0;
-    variables.getVarsNameForWho(NULL, &iZero, lstVar, &iZero, bSorted);
-    return lstVar;
+    variables.getGlobalNameForWho(lst, &iZero, bSorted);
+    return static_cast<int>(lst.size());
 }
 
-std::list<std::wstring>* Context::getWhereIs(const std::wstring& _str)
+int Context::getWhereIs(std::list<std::wstring>& lst, const std::wstring& _str)
 {
-    return libraries.whereis(Symbol(_str));
+    return libraries.whereis(lst, Symbol(_str));
 }
 
-std::list<std::wstring>* Context::getLibrariesList()
+int Context::getLibrariesList(std::list<std::wstring>& lst)
 {
-    return libraries.librarieslist();
+    return libraries.librarieslist(lst);
 }
 
 void Context::put(Variable* _var, types::InternalType* _pIT)
@@ -383,7 +383,8 @@ void Context::print(std::wostream& ostr, bool sorted) const
     std::list<std::wstring> lstGlobal;
     int iVarLenMax = 10; // initialise to the minimal value of padding
     int iGlobalLenMax = 10; // initialise to the minimal value of padding
-    variables.getVarsNameForWho(&lstVar, &iVarLenMax, &lstGlobal, &iGlobalLenMax);
+    variables.getVarsNameForWho(lstVar, &iVarLenMax);
+    variables.getGlobalNameForWho(lstGlobal, &iGlobalLenMax);
     libraries.getVarsNameForWho(&lstVar, &iVarLenMax);
 
     if (sorted)
@@ -480,13 +481,13 @@ bool Context::isValidVariableName(const char* name)
     return isValid;
 }
 
-std::list<Library*>* Context::getLibsToVariableBrowser()
+int Context::getLibsToVariableBrowser(std::list<Library*>& lst)
 {
-    std::list<Library*>* libs = libraries.getVarsToVariableBrowser();
+    libraries.getVarsToVariableBrowser(lst);
 
     std::list<Library*> toremove;
     //list lib that have a variable with the same name
-    for (auto lib : *libs)
+    for (auto lib : lst)
     {
         Variable* var = getOrCreate(lib->getSymbol());
         if (var->empty() == false)
@@ -498,15 +499,78 @@ std::list<Library*>* Context::getLibsToVariableBrowser()
     //remove
     for (auto lib : toremove)
     {
-        libs->remove(lib);
+        lst.remove(lib);
     }
 
-    return libs;
+    return static_cast<int>(lst.size());
 }
 
-std::list<Variable*>* Context::getVarsToVariableBrowser()
+int Context::getVarsToVariableBrowser(std::list<Variable*>& lst)
 {
-    return variables.getVarsToVariableBrowser();
+    variables.getVarsToVariableBrowser(lst);
+    return static_cast<int>(lst.size());
 }
 
+void Context::updateProtection(bool protect)
+{
+    if (varStack.empty() == false)
+    {
+        VarList* lst = varStack.top();
+        for (auto var : *lst)
+        {
+            if (var.second->empty() == false)
+            {
+                ScopedVariable* pSV = var.second->top();
+                //only for current scope but normally vars in VarStack are in the current scope
+                if (pSV->m_iLevel == m_iLevel)
+                {
+                    pSV->protect = protect;
+                }
+                else
+                {
+                    std::wcerr << L"heu ... " << var.first.getName() << std::endl;
+                }
+            }
+        }
+    }
+}
+
+void Context::protect()
+{
+    updateProtection(true);
+}
+
+void Context::unprotect()
+{
+    updateProtection(false);
+}
+
+bool Context::isprotected(const Symbol& key)
+{
+    return isprotected(getOrCreate(key));
+}
+
+bool Context::isprotected(Variable* _var)
+{
+    //don't check protection on "ans"
+    if (_var->getSymbol().getName() == L"ans")
+    {
+        return false;
+    }
+
+    if (_var->empty() == false)
+    {
+        ScopedVariable* pSV = _var->top();
+        if (pSV->m_iLevel == m_iLevel && pSV->protect)
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+int Context::protectedVars(std::list<std::wstring>& vars)
+{
+    return variables.getProtectedVarsName(vars);
+}
 }
index 4addf76..528493c 100644 (file)
@@ -108,15 +108,14 @@ MacroFile* Library::get(const std::wstring& _wstName)
     return NULL;
 }
 
-std::list<std::wstring>* Library::getMacrosName()
+int Library::getMacrosName(std::list<std::wstring>& lst)
 {
-    std::list<std::wstring>* pOut = new std::list<std::wstring>;
     for (auto macro : m_macros)
     {
-        pOut->push_back(macro.first);
+        lst.push_back(macro.first);
     }
 
-    return pOut;
+    return static_cast<int>(lst.size());
 }
 
 std::wstring Library::getPath()
index 875f505..3e072c9 100644 (file)
@@ -128,7 +128,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_errclear.cpp \
        sci_gateway/cpp/sci_intppty.cpp \
        sci_gateway/cpp/sci_analyzeroptions.cpp \
-       sci_gateway/cpp/sci_macr2tree.cpp
+       sci_gateway/cpp/sci_macr2tree.cpp \
+       sci_gateway/cpp/sci_predef.cpp
 
 libscicore_la_CPPFLAGS = \
     -I$(srcdir)/includes/ \
index 5e9b9e9..74eed7e 100644 (file)
@@ -292,7 +292,8 @@ am__objects_5 = sci_gateway/cpp/libscicore_la-core_gw.lo \
        sci_gateway/cpp/libscicore_la-sci_errclear.lo \
        sci_gateway/cpp/libscicore_la-sci_intppty.lo \
        sci_gateway/cpp/libscicore_la-sci_analyzeroptions.lo \
-       sci_gateway/cpp/libscicore_la-sci_macr2tree.lo
+       sci_gateway/cpp/libscicore_la-sci_macr2tree.lo \
+       sci_gateway/cpp/libscicore_la-sci_predef.lo
 am_libscicore_la_OBJECTS = $(am__objects_4) $(am__objects_5)
 libscicore_la_OBJECTS = $(am_libscicore_la_OBJECTS)
 libscicore_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
@@ -802,7 +803,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_errclear.cpp \
        sci_gateway/cpp/sci_intppty.cpp \
        sci_gateway/cpp/sci_analyzeroptions.cpp \
-       sci_gateway/cpp/sci_macr2tree.cpp
+       sci_gateway/cpp/sci_macr2tree.cpp \
+       sci_gateway/cpp/sci_predef.cpp
 
 libscicore_la_CPPFLAGS = -I$(srcdir)/includes/ -I$(srcdir)/src/c/ \
        -I$(srcdir)/src/cpp/ -I$(top_srcdir)/modules/ast/includes/ast/ \
@@ -1371,6 +1373,9 @@ sci_gateway/cpp/libscicore_la-sci_analyzeroptions.lo:  \
 sci_gateway/cpp/libscicore_la-sci_macr2tree.lo:  \
        sci_gateway/cpp/$(am__dirstamp) \
        sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libscicore_la-sci_predef.lo:  \
+       sci_gateway/cpp/$(am__dirstamp) \
+       sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
 
 libscicore.la: $(libscicore_la_OBJECTS) $(libscicore_la_DEPENDENCIES) $(EXTRA_libscicore_la_DEPENDENCIES) 
        $(AM_V_CXXLD)$(libscicore_la_LINK) $(am_libscicore_la_rpath) $(libscicore_la_OBJECTS) $(libscicore_la_LIBADD) $(LIBS)
@@ -1428,6 +1433,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_mode.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_newfun.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_pause.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_predef.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_quit.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_sciargs.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_stacksize.Plo@am__quote@
@@ -2242,6 +2248,13 @@ sci_gateway/cpp/libscicore_la-sci_macr2tree.lo: sci_gateway/cpp/sci_macr2tree.cp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscicore_la-sci_macr2tree.lo `test -f 'sci_gateway/cpp/sci_macr2tree.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_macr2tree.cpp
 
+sci_gateway/cpp/libscicore_la-sci_predef.lo: sci_gateway/cpp/sci_predef.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscicore_la-sci_predef.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_predef.Tpo -c -o sci_gateway/cpp/libscicore_la-sci_predef.lo `test -f 'sci_gateway/cpp/sci_predef.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_predef.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_predef.Tpo sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_predef.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_predef.cpp' object='sci_gateway/cpp/libscicore_la-sci_predef.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscicore_la-sci_predef.lo `test -f 'sci_gateway/cpp/sci_predef.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_predef.cpp
+
 .f.o:
        $(AM_V_F77)$(F77COMPILE) -c -o $@ $<
 
index b3972f0..56ae7c2 100644 (file)
@@ -68,5 +68,6 @@ CPP_GATEWAY_PROTOTYPE(sci_clearfun);
 CPP_GATEWAY_PROTOTYPE(sci_funptr);
 CPP_GATEWAY_PROTOTYPE(sci_analyzeroptions);
 CPP_GATEWAY_PROTOTYPE(sci_macr2tree);
+CPP_GATEWAY_PROTOTYPE(sci_predef);
 
 #endif /* __CORE_GW_HXX__ */
index 652919b..4a623e3 100644 (file)
@@ -63,5 +63,6 @@ int CoreModule::Load()
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"funptr", &sci_funptr, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"analyzerOptions", &sci_analyzeroptions, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"macr2tree", &sci_macr2tree, MODULE_NAME));
+    symbol::Context::getInstance()->addFunction(Function::createFunction(L"predef", &sci_predef, MODULE_NAME));
     return 1;
 }
index 9bd0047..556667b 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
     <ClCompile Include="sci_macr2tree.cpp" />
     <ClCompile Include="sci_mode.cpp" />
     <ClCompile Include="sci_newfun.cpp" />
+    <ClCompile Include="sci_predef.cpp" />
     <ClCompile Include="sci_sciargs.cpp" />
     <ClCompile Include="..\c\sci_getdebuginfo.c" />
     <ClCompile Include="..\c\sci_type.c" />
index bd079f5..c780b46 100644 (file)
     <ClCompile Include="..\c\sci_type.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="sci_predef.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\includes\banner.hxx">
index e815b25..da735b9 100644 (file)
@@ -28,31 +28,54 @@ using namespace types;
 
 Function::ReturnValue sci_clear(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
-    types::typed_list::iterator inIterator;
+    symbol::Context* ctx = symbol::Context::getInstance();
     int iWrongType = 1;
 
     if (in.size() == 0)
     {
         //clear();
-        symbol::Context::getInstance()->removeAll();
+        ctx->removeAll();
         return Function::OK;
     }
 
     // First check if all arguments are Single Strings.
-    for (inIterator = in.begin() ; inIterator != in.end() ; iWrongType++, inIterator++)
+    int var = 0;
+    for (auto pIT : in)
     {
-        if ((*inIterator)->isString() == false)
+        ++var;
+        if (pIT->isString() == false)
         {
-            Scierror(207, _("%s: Wrong type for input argument #%d: Matrix of strings expected.\n"), "clear", iWrongType);
+            Scierror(207, _("%s: Wrong type for input argument #%d: Matrix of strings expected.\n"), "clear", var);
             return Function::Error;
         }
+    }
 
-        types::String* pStr = (*inIterator)->getAs<types::String>();
+    bool bShow = false;
+    for (auto pIT : in)
+    {
+        types::String* pStr = pIT->getAs<types::String>();
         for (int i = 0; i < pStr->getSize(); i++)
         {
-            symbol::Context::getInstance()->remove(symbol::Symbol(pStr->get(i)));
+            symbol::Symbol sym = symbol::Symbol(pStr->get(i));
+            if (ctx->isprotected(sym) == false)
+            {
+                ctx->remove(sym);
+            }
+            else
+            {
+                if (bShow == false)
+                {
+                    Scierror(999, _("Redefining permanent variable.\n"));
+                    bShow = true;
+                }
+            }
         }
     }
 
+    if (bShow)
+    {
+        return Function::Error;
+    }
+
     return Function::OK;
 }
diff --git a/scilab/modules/core/sci_gateway/cpp/sci_predef.cpp b/scilab/modules/core/sci_gateway/cpp/sci_predef.cpp
new file mode 100644 (file)
index 0000000..5e45358
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+*  Copyright (C) 2011-2011 - DIGITEO - Bruno JOFRET
+*
+*  This file must be used under the terms of the CeCILL.
+*  This source file is licensed as described in the file COPYING, which
+*  you should have received as part of this distribution.  The terms
+*  are also available at
+*  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+
+#include "core_gw.hxx"
+#include "function.hxx"
+#include "string.hxx"
+#include "context.hxx"
+
+extern "C"
+{
+#include "charEncoding.h"
+#include "localization.h"
+#include "Scierror.h"
+}
+
+static const std::string fname("predef");
+
+types::Function::ReturnValue sci_predef(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    int rhs = in.size();
+    symbol::Context* ctx = symbol::Context::getInstance();
+    if (rhs > 1)
+    {
+        Scierror(77, _("%s: Wrong number of input argument(s): %d to %d expected.\n"), fname.data(), 0, 1);
+        return types::Function::Error;
+    }
+
+    if (rhs == 0)
+    {
+        //return size
+        std::list<std::wstring> lst;
+        int size = ctx->protectedVars(lst);
+        out.push_back(new types::Double(size));
+        return types::Function::OK;
+    }
+
+    types::InternalType* pIT = in[0];
+
+    if (pIT->isString() == false)
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: A string expected."), fname.data(),  1);
+        return types::Function::Error;
+    }
+
+    types::String* pS = pIT->getAs<types::String>();
+
+    if (pS->isScalar() == false)
+    {
+        Scierror(999, _("%s: Wrong size for input argument #%d: A string expected."), fname.data(), 1);
+        return types::Function::Error;
+    }
+
+    std::wstring opt(pS->get()[0]);
+
+    if (opt == L"all" || opt == L"a")
+    {
+        symbol::Context::getInstance()->protect();
+    }
+    else if (opt == L"clear" || opt == L"c")
+    {
+        symbol::Context::getInstance()->unprotect();
+    }
+    else if (opt == L"names" || opt == L"n")
+    {
+        std::list<std::wstring> lst;
+        int size = ctx->protectedVars(lst);
+
+        //create output string
+        if (size == 0)
+        {
+            out.push_back(types::Double::Empty());
+            return types::Function::OK;
+        }
+
+        types::String* pS = new types::String(size, 1);
+        int i = 0;
+        wchar_t** ws = pS->get();
+        for (auto var : lst)
+        {
+            pS->set(i++, var.c_str());
+        }
+
+        out.push_back(pS);
+    }
+    else
+    {
+        Scierror(999, _("%s: Wrong value for input argument #%d: '%s', '%s' or '%s' expected.\n"), fname.data(), 1, "all", "clear", "names");
+        return types::Function::Error;
+    }
+
+    return types::Function::OK;
+}
index 55dc1ff..27ff1b5 100644 (file)
@@ -31,7 +31,8 @@ types::Function::ReturnValue sci_who(types::typed_list& in, int _iRetCount, type
     bool bSorted = false;
     types::String* pStrOut = NULL;
     types::Double* pDblOut = NULL;
-    std::list<std::wstring>* lstVar = NULL;
+    std::list<std::wstring> lstVar;
+    int size = 0;
 
     if (in.size() < 0 || in.size() > 2)
     {
@@ -102,11 +103,11 @@ types::Function::ReturnValue sci_who(types::typed_list& in, int _iRetCount, type
 
     if (wcscmp(wcsWhat, L"local") == 0 || wcscmp(wcsWhat, L"get") == 0)
     {
-        lstVar = symbol::Context::getInstance()->getVarsNameForWho(bSorted);
+        size = symbol::Context::getInstance()->getVarsNameForWho(lstVar, bSorted);
     }
     else if (wcscmp(wcsWhat, L"global") == 0)
     {
-        lstVar = symbol::Context::getInstance()->getGlobalNameForWho(bSorted);
+        size = symbol::Context::getInstance()->getGlobalNameForWho(lstVar, bSorted);
     }
     else if (bSorted == false && wcscmp(wcsWhat, L"sorted") == 0)
     {
@@ -131,7 +132,7 @@ types::Function::ReturnValue sci_who(types::typed_list& in, int _iRetCount, type
         return types::Function::Error;
     }
 
-    if (lstVar->empty())
+    if (lstVar.empty())
     {
         out.push_back(types::Double::Empty());
         if (_iRetCount == 2)
@@ -139,18 +140,16 @@ types::Function::ReturnValue sci_who(types::typed_list& in, int _iRetCount, type
             out.push_back(types::Double::Empty());
         }
 
-        delete lstVar;
         return types::Function::OK;
     }
 
-    pStrOut = new types::String(lstVar->size(), 1);
-    std::list<std::wstring>::const_iterator it = lstVar->begin();
-    for (int i = 0; it != lstVar->end(); ++it, i++)
+    pStrOut = new types::String(size, 1);
+    int i = 0;
+    for (auto it : lstVar)
     {
-        pStrOut->set(i, (*it).c_str());
+        pStrOut->set(i++, it.c_str());
     }
 
-    delete lstVar;
     out.push_back(pStrOut);
 
     if (_iRetCount == 2)
index 26dc466..3abc005 100644 (file)
@@ -20,22 +20,21 @@ extern "C" {
 /*----------------------------------------------------------------------------------*/
 char **getFunctionsName(int *sizearray)
 {
-    std::list<std::wstring>* plMacrosList = symbol::Context::getInstance()->getFunctionsName();
-    *sizearray = (int)plMacrosList->size();
+    std::list<std::wstring> macrosList;
+    *sizearray = symbol::Context::getInstance()->getFunctionsName(macrosList);
+
     char** functions = NULL;
     if (*sizearray != 0)
     {
         functions = (char**)MALLOC(*sizearray * sizeof(char*));
 
-        plMacrosList->sort();
+        macrosList.sort();
 
-        std::list<std::wstring>::iterator it = plMacrosList->begin();
-        for (int i = 0; it != plMacrosList->end(); ++it, i++)
+        int i = 0;
+        for (auto it : macrosList)
         {
-            functions[i] = wide_string_to_UTF8((*it).c_str());
+            functions[i++] = wide_string_to_UTF8(it.c_str());
         }
-
-        delete plMacrosList;
     }
 
     return functions;
index 0bb6254..f224844 100644 (file)
@@ -20,27 +20,27 @@ extern "C" {
 /*----------------------------------------------------------------------------------*/
 char **getMacrosName(int *sizearray)
 {
-    std::list<std::wstring>* plMacrosList = symbol::Context::getInstance()->getMacrosName();
+    std::list<std::wstring> macrosList;
+    int size = symbol::Context::getInstance()->getMacrosName(macrosList);
 
     //sort list
-    plMacrosList->sort();
+    macrosList.sort();
     //same names could come from libraries AND context
-    plMacrosList->unique();
+    macrosList.unique();
 
-    *sizearray = (int)plMacrosList->size();
+    *sizearray = static_cast<int>(macrosList.size());
     char** macros = NULL;
     if (*sizearray != 0)
     {
         macros = (char**)MALLOC(*sizearray * sizeof(char*));
 
-        std::list<std::wstring>::iterator it = plMacrosList->begin();
-        for (int i = 0; it != plMacrosList->end(); ++it, i++)
+        int i = 0;
+        for (auto it : macrosList)
         {
-            macros[i] = wide_string_to_UTF8((*it).c_str());
+            macros[i++] = wide_string_to_UTF8(it.c_str());
         }
     }
 
-    delete plMacrosList;
     return macros;
 }
 /*----------------------------------------------------------------------------------*/
index a5d8069..7dfc34d 100644 (file)
@@ -20,8 +20,8 @@ extern "C" {
 /*----------------------------------------------------------------------------------*/
 char **getVariablesName(int *sizearray, BOOL sorted)
 {
-    std::list<std::wstring>* plVarNames = symbol::Context::getInstance()->getVarsName();
-    *sizearray = (int)plVarNames->size();
+    std::list<std::wstring> varNames;
+    *sizearray = symbol::Context::getInstance()->getVarsName(varNames);
     char** variables = NULL;
 
     if (*sizearray != 0)
@@ -30,16 +30,14 @@ char **getVariablesName(int *sizearray, BOOL sorted)
 
         if (sorted)
         {
-            plVarNames->sort();
+            varNames.sort();
         }
 
-        std::list<std::wstring>::iterator it = plVarNames->begin();
-        for (int i = 0; it != plVarNames->end(); ++it, i++)
+        int i = 0;
+        for (auto it : varNames)
         {
-            variables[i] = wide_string_to_UTF8((*it).c_str());
+            variables[i++] = wide_string_to_UTF8(it.c_str());
         }
-
-        delete plVarNames;
     }
 
     return variables;
index 23f588d..c48fe69 100644 (file)
@@ -2,20 +2,19 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2008 - INRIA
 // Copyright (C) 2009 - DIGITEO - Allan CORNET
+// Copyright (C) 2015 - Scilab Enterprises - Antoine ELIAS
 //
 //  This file is distributed under the same license as the Scilab package.
 // =============================================================================
-//predef
-N = predef();
+//
+// <-- CLI SHELL MODE -->
+//
 a = 1;
 predef("all");
 ierr = execstr('clear a','errcatch');
-if ierr <> 13 then bugmes();quit;end
+assert_checktrue(ierr <> 0);
 ierr = execstr('predef(''clear'')','errcatch');
-if ierr <> 0 then bugmes();quit;end
+assert_checktrue(ierr == 0);
 ierr = execstr('clear','errcatch');
-if ierr <> 0 then bugmes();quit;end
-ierr = execstr('predef(N)','errcatch');
-if ierr <> 0 then bugmes();quit;end
-       
-if predef() <> N then bugmes();quit;end
+assert_checktrue(ierr == 0);
+assert_checktrue(predef() == 0);
index 3a98e73..14fa2a9 100644 (file)
@@ -2,27 +2,25 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2008 - INRIA
 // Copyright (C) 2009 - DIGITEO - Allan CORNET
+// Copyright (C) 2015 - Scilab Enterprises - Antoine ELIAS
 //
 //  This file is distributed under the same license as the Scilab package.
 // =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
 
-//predef
-
-N = predef();
 a = 1;
 predef("all");
 
 ierr = execstr('clear a','errcatch');
-if ierr <> 13 then pause,end
+assert_checktrue(ierr <> 0);
 
 ierr = execstr('predef(''clear'')','errcatch');
-if ierr <> 0 then pause,end
+assert_checktrue(ierr == 0);
 
 ierr = execstr('clear','errcatch');
-if ierr <> 0 then pause,end
+assert_checktrue(ierr == 0);
+
+assert_checktrue(predef() == 0);
 
-ierr = execstr('predef(N)','errcatch');
-if ierr <> 0 then pause,end
-       
-if predef() <> N then pause,end
-  
index 327dfad..21a2a7f 100644 (file)
@@ -8,8 +8,8 @@
 // <-- CLI SHELL MODE -->
 //
 variables_names_1 = predef('names');
-assert_checkequal(size(grep(variables_names_1,'SCI'), '*') <> [], %t);
-assert_checkequal(size(grep(variables_names_1,'corelib'), '*'), 1);
+assert_checkequal(size(grep(variables_names_1,'jnull'), '*'), 1);
+assert_checkequal(size(grep(variables_names_1,'evoid'), '*'), 1);
 clear
 // we add 3 variables
 toto_1 = 1;
@@ -17,7 +17,6 @@ toto_2 = 1;
 toto_3 = 1;
 predef("all"); // and protect
 variables_names_2 = predef('names');
-ref = ["toto_1";
-       "toto_2";
-       "toto_3"];
-assert_checkequal(variables_names_2($-2:$), ref);
+assert_checktrue(grep(variables_names_2,'toto_1') <> []);
+assert_checktrue(grep(variables_names_2,'toto_2') <> []);
+assert_checktrue(grep(variables_names_2,'toto_3') <> []);
index a3e0da8..bb60fda 100644 (file)
@@ -8,8 +8,8 @@
 // <-- CLI SHELL MODE -->
 //
 variables_names_1 = predef('names');
-assert_checkequal(size(grep(variables_names_1,'SCI'), '*') <> [], %t);
-assert_checkequal(size(grep(variables_names_1,'corelib'), '*'), 1);
+assert_checkequal(size(grep(variables_names_1,'jnull'), '*'), 1);
+assert_checkequal(size(grep(variables_names_1,'evoid'), '*'), 1);
 
 clear
 // we add 3 variables
@@ -19,7 +19,7 @@ toto_3 = 1;
 
 predef("all"); // and protect
 variables_names_2 = predef('names');
-ref = ["toto_1";
-       "toto_2";
-       "toto_3"];
-assert_checkequal(variables_names_2($-2:$), ref);
+assert_checktrue(grep(variables_names_2,'toto_1') <> []);
+assert_checktrue(grep(variables_names_2,'toto_2') <> []);
+assert_checktrue(grep(variables_names_2,'toto_3') <> []);
+
index 0336d06..8b6c7b5 100644 (file)
@@ -705,7 +705,7 @@ function status = test_single(_module, _testPath, _testName)
     "   quit;" ;
     "endfunction" ;
     "function []=bugmes(), printf(''error on test'');endfunction"
-    "//predef(''all'');";
+    "predef(''all'');";
     "tmpdirToPrint = msprintf(''TMPDIR1=''''%s'''';//\n'',TMPDIR);"
     ];
 
@@ -1116,6 +1116,7 @@ function msg = checkthefile( filename )
     if params.show_error == %t then
         msg=[msg; mgetl(filename)]
     end
+
 endfunction
 
 // launchthecommand
diff --git a/scilab/modules/development_tools/macros/yasp_run.sci b/scilab/modules/development_tools/macros/yasp_run.sci
deleted file mode 100644 (file)
index fee53ce..0000000
+++ /dev/null
@@ -1,1687 +0,0 @@
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2007-2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr>
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution.  The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-
-// test_run  --
-//   Launch unit tests.
-//   Search for .tst files in the unit test and non-regression test library
-//   execute them, and display a report about success of failures.
-//   The .tst files are searched in directories SCI+"/modules/*/tests/unit_tests"
-//   and SCI+"/modules/*/tests/nonreg_tests".
-//   Whenever a test is executed, a .dia file is generated which contains
-//   the full list of commands executed along with message which appears in the
-//   console. When the script is done, the .dia file is compared with
-//   the .dia.ref file which is expected to be in the same directory
-//   as the .tst file. If the two file are different, the test fails.
-//   Special tags may be inserted in the .tst file, which help to
-//   control the processing of the corresponding test. These tags
-//   are expected to be found in Scilab comments.
-//   These are the available tags :
-//     <-- INTERACTIVE TEST -->
-//       This test will be skipped because it is interactive.
-//     <-- LONG TIME EXECUTION -->
-//       This test will be skipped because it needs long-time duration. It will
-//       launched if the optional argument "enable_lt" is called
-//     <-- NOT FIXED -->
-//       This test will be skipped because it is a known, but unfixed bug.
-//     <-- TEST WITH GRAPHIC -->
-//       This test will not be executed if the option "mode_nwni" is used.
-//     <-- NO TRY CATCH -->
-//     <-- NO CHECK ERROR OUTPUT -->
-//       The error output file is not checked
-//     <-- NO CHECK REF -->
-//       The .dia and the .dia.ref files are not compared.
-//     <-- ENGLISH IMPOSED -->
-//       This test will be executed with the -l en_US option.
-//     <-- FRENCH IMPOSED -->
-//       This test will be executed with the -l fr_FR option.
-//     <-- JVM NOT MANDATORY -->
-//       This test will be executed with the nwni mode by default.
-//     <-- WINDOWS ONLY -->
-//       If the operating system isn't Windows, the test is skipped.
-//     <-- UNIX ONLY -->
-//       If the operating system isn't an unix OS, the test is skipped.
-//     <-- LINUX ONLY -->
-//       If the operating system isn't Linux, the test is skipped.
-//     <-- MACOSX ONLY -->
-//       If the operating system isn't MacOSX, the test is skipped.
-//     <-- XCOS TEST -->
-//       This test will launch all the necessary Xcos libs. This test
-//       will be launched in nw mode.
-//
-//   Each test is executed in a separated process, created with the "host" command.
-//   That enables the current command to continue, even if the test as
-//   created an unstable environment. It also enables the tests to be
-//   independent from one another.
-//
-// Arguments:
-//   modulename, optional : a string or a vector of strings, where
-//     each string is a the name of a module to test
-//   testname, optional : a string, a vector or a matrix of strings, where
-//     each string is a the name of a test. For example, if testname is "foo",
-//     the associated test file is "foo.tst".
-//   options, optional : a string or a vector of strings, where options can
-//     have the following values :
-//       'no_check_ref' : does not check if the .dia and .dia.ref are equal
-//       'no_check_error_output'
-//       'create_ref' : create the .dia.ref file and does not check if the .dia and .dia.ref are equal
-//       'list' : does not process the tests but displays a list of available tests
-//       'mode_nw' : add the "-nw" option to the launch
-//       'mode_nwni' : add the "-nwni" option to the launch
-//       'help' : display some examples about how to use this command
-//       "nonreg_tests" : runs only the non-regression tests, skipping unit tests
-//       "unit_tests" : runs only the unit tests, skipping non-regression tests
-//
-// =============================================================================
-// Launch tests
-// =============================================================================
-// Examples :
-//
-// Launch all tests
-// test_run();
-// test_run([]);
-// test_run([],[]);
-//
-// Test one or several module
-// test_run('core');
-// test_run('core',[]);
-// test_run(['core','string']);
-//
-// Launch one or several test in a specified module
-// test_run('core',['trycatch','opcode']);
-//
-// With options
-// test_run([],[],'no_check_ref');
-// test_run([],[],'no_check_error_output');
-// test_run([],[],'create_ref');
-// test_run([],[],'list');
-// test_run([],[],'mode_nw');
-// test_run([],[],'mode_nwni');
-// test_run([],[],'help');
-// test_run([],[],['no_check_error_output','create_ref']);
-
-
-function yasp_run(varargin)
-
-    lhs = argn(1);
-    rhs = argn(2);
-
-    // test type
-    type_filter  = "all_tests"; // By default, lauch nonreg tests AND unitary tests
-    skip_mat     = [];          // The list of test to skip
-
-    // =========================================================================
-    // Print test_run help
-    // =========================================================================
-
-    if (rhs >= 3) & (~ isempty(grep(varargin(3),"help"))) then
-        example = test_examples();
-        printf("%s\n",example);
-        return;
-    end
-
-    // =======================================================
-    // Gestion des types de tests à lancer
-    // =======================================================
-
-    global testsuite;
-    testsuite = testsuite_new();
-
-    if rhs >= 3 then
-
-        option_mat = varargin(3);
-
-        if (or(option_mat == "unit_tests") & or(option_mat == "nonreg_tests")) | (or(option_mat == "all_tests") ) then
-            type_filter = "all_tests";
-
-        elseif or(option_mat == "unit_tests") then
-            type_filter = "unit_tests";
-
-        elseif or(option_mat == "nonreg_tests") then
-            type_filter = "nonreg_tests";
-        end
-
-        if or(option_mat == "skip_tests") then
-            skip_mat = varargin(2);
-        end
-
-    end
-
-    // =======================================================
-    // Stacksize management
-    // =======================================================
-
-    //gstacksize(10000000);
-    //stacksize(10000000);
-
-    // =======================================================
-    // Gestion des tests à lancer
-    // =======================================================
-
-    if (rhs == 0) ..
-        | ((rhs == 1) & (varargin(1)==[])) ..
-        | (((rhs == 2)|(rhs == 3)) & (varargin(1)==[]) & (varargin(2)==[])) then
-
-        // No input argument
-        // test_run()
-        // test_run([])
-        // => Launch each test of each module
-
-        module_list = getmodules();
-        module_list = gsort(module_list,"lr","i");
-
-        for i=1:size(module_list,"*")
-            module    = module_new();
-            module    = module_set_name(module,module_list(i));
-            module    = module_set_path(module,pathconvert(SCI+"/modules/"+module.name,%F));
-            tests     = get_tests_from_module(module,type_filter,skip_mat);
-            testsuite = testsuite_add_tests( testsuite, tests );
-        end
-    elseif (rhs == 1) ..
-        | ((rhs == 2) & (varargin(2)==[])) ..
-        | ((rhs == 3) & (varargin(2)==[])) ..
-        | ( ~ isempty(skip_mat)) then
-
-        // One input argument
-        // test_run(<module_name>)
-        // test_run([<module_name_1>,<module_name_2>])
-
-        // varargin(1) = [<module_name_1>,<module_name_2>]
-
-        module_mat = varargin(1);
-
-        // test_run([<module_name_1>,<module_name_2>])
-
-        for i=1:size(module_mat,"*")
-
-            module = module_new();
-            module = module_set_name(module,module_mat(i));
-
-            // It's a scilab internal module
-            if with_module(module.items(1)) then
-                module = module_set_path(module,pathconvert(SCI+"/modules/"+module.items(1),%F));
-
-
-                // It's an external module
-            elseif isdir(module.items(1)) then
-                module = module_set_path(module,pathconvert(module.items(1),%F));
-
-                // It's an error
-            else
-                error(sprintf(gettext("%s is not an installed module or toolbox"),module_mat(i)));
-            end
-
-            tests = get_tests_from_module(module,type_filter,skip_mat);
-
-            testsuite = testsuite_add_tests( testsuite , tests);
-
-        end
-
-    elseif (rhs == 2) | (rhs == 3) then
-
-        // Two input arguments
-        // test_run(<module_name>,<test_name>)
-        // test_run(<module_name>,[<test_name_1>,<test_name_2>] )
-
-        // varargin(1) = <module_name> ==> string 1x1
-        // varargin(2) = <test_name_1> ==> mat nl x nc
-
-        module_in  = varargin(1);
-        test_mat   = varargin(2);
-
-        if ((or(size(module_in) <> [1,1])) & (test_mat <> [])) then
-
-            example = test_examples();
-            err     = ["" ; msprintf(gettext("%s: Wrong size for input argument."),"yasp_run") ; "" ; example ];
-            printf("%s\n",err);
-            return;
-        end
-
-        module = module_new();
-        module = module_set_name(module,module_in)
-
-        // It's a scilab internal module
-        if with_module(module.items(1)) then
-            module = module_set_path(module,pathconvert(SCI+"/modules/"+module.items(1),%F));
-
-            // It's an external module
-        elseif isdir(module.items(1)) then
-            module = module_set_path(module,pathconvert(module.items(1),%F));
-
-            // It's an error
-        else
-            error(sprintf(gettext("%s is not an installed module or toolbox"),module.items(1)));
-        end
-
-        for i=1:size(test_mat,"*")
-
-            types    = ["unit_tests";"nonreg_tests"];
-            my_tests = list();
-
-            for j=1:size(types,"*")
-
-                if (type_filter<>"all_tests") & (type_filter<>types(j)) then
-                    continue;
-                end
-
-                // Get the list of directories where search
-
-                test_directory_path = module.path + "/tests/" + types(j);
-                for k=2:size(module.items,"*")
-                    test_directory_path = test_directory_path + "/" + module.items(k);
-                end
-
-                // The main directory doesn't exist, continue the loop
-
-                if ~ isdir(test_directory_path) then
-                    continue;
-                end
-
-                test_main_directory = directory_new();
-                test_main_directory = directory_set_type(test_main_directory,types(j));
-                test_main_directory = directory_set_module(test_main_directory,module);
-                test_main_directory = directory_set_path(test_main_directory,test_directory_path);
-
-                test_directories = get_directories(test_main_directory);
-
-                for k=1:size(test_directories)
-
-                    this_directory = test_directories(k);
-
-                    test = st_new();
-                    test = st_set_name(   test , test_mat(i) );
-                    test = st_set_module( test , this_directory.module );
-                    test = st_set_type(   test , types(j) );
-                    test = st_set_path(   test , pathconvert( this_directory.path + "/" + test.name + ".tst" , %F ) );
-
-                    if isfile(test.path) then
-                        test = st_analyse(test);
-                        my_tests($+1) = test;
-                    end
-
-                end
-
-            end
-
-            if size(my_tests) == 0 then
-                error(sprintf(gettext("The test ""%s"" is not available from the ""%s"" module"),test_mat(i),module.name));
-            end
-
-            testsuite = testsuite_add_tests(testsuite,my_tests);
-
-        end
-
-    else
-        error(msprintf(gettext("%s: Wrong number of input arguments."),"yasp_run"));
-    end
-
-    // =========================================================================
-    // Gestion des options
-    // =========================================================================
-
-    if rhs >= 3 then
-
-        // Mode
-
-        if grep(option_mat,"mode_nw") <> [] then
-            testsuite = testsuite_set_WM(testsuite,"NW");
-        end
-
-        if grep(option_mat,"mode_nwni") <> [] then
-            testsuite = testsuite_set_WM(testsuite,"NWNI");
-        end
-
-        // Reference
-
-        if grep(option_mat,"no_check_ref") <> [] then
-            testsuite = testsuite_set_reference(testsuite,"skip");
-        end
-
-        if grep(option_mat,"create_ref") <> [] then
-            testsuite = testsuite_set_reference(testsuite,"create");
-        end
-
-        // Error Output
-
-        if grep(option_mat,"no_check_error_output") <> [] then
-            testsuite = testsuite_set_EO(testsuite,"skip");
-        end
-
-        // Enable long-time tests
-
-        if grep(option_mat,"disable_lt") <> [] then
-            testsuite = testsuite_set_LT(testsuite,"skip");
-        end
-
-        if grep(option_mat,"enable_lt") <> [] then
-            testsuite = testsuite_set_LT(testsuite,"enable");
-        end
-
-    end
-
-    // =========================================================================
-    // List test
-    // =========================================================================
-
-    if (rhs >= 3) & (~ isempty(grep(option_mat,"list"))) then
-        testsuite_list(testsuite);
-        clearglobal testsuite;
-        return;
-
-        // =========================================================================
-        // Test launch
-        // =========================================================================
-
-    else
-        testsuite_run(testsuite);
-        clearglobal testsuite;
-        return;
-    end
-
-endfunction
-
-//-----------------------------------------------------------------------------
-// Pierre MARECHAL
-// Scilab team
-// Date : 28 oct. 2007
-//
-// => List all test files in the module <module_mat>
-// => Add them to the test_mat matrix
-//-----------------------------------------------------------------------------
-
-function my_tests = get_tests_from_module(module,type_filter,skip_mat)
-
-    my_types = ["unit_tests","nonreg_tests"];
-
-    // 1st action : build the list of directories to explore
-    // test_type : {"all_tests"|"unit_tests"|"nonreg_tests"}
-
-    // Example of a directory :
-    //   path: "/home/robert/scilab/modules/time/tests/unit_tests/date"
-    //   type: "unit_tests"
-    //   module: "time|date"
-
-    my_directories = list();
-
-    for i=1:size(my_types,"*")
-        if (type_filter == "all_tests") | (type_filter == my_types(i)) then
-
-            directory = directory_new();
-            directory = directory_set_type(directory,my_types(i));
-            directory = directory_set_module(directory,module);
-
-            directory_path = module.path+"/tests/"+my_types(i);
-            module_items   = module.items;
-
-            for j=2:size(module_items,"*")
-                directory_path = directory_path + "/" + module_items(j);
-            end
-
-            directory = directory_set_path(directory,directory_path);
-
-            if isdir(directory.path) then
-                my_directories = lstcat( my_directories , get_directories(directory) );
-            end
-        end
-    end
-
-    // 2nd action : Build the list of tests
-    // Example of a test :
-    //   name: "bug_793"
-    //   path: "/home/robert/scilab/modules/time/tests/nonreg_tests/bug_793.tst"
-    //   type: "nonreg_tests"
-    //   module: "time"
-
-    my_tests = list();
-    for i=1:size(my_directories)
-        directory = my_directories(i);
-        tests_in  = get_tests_from_directory(directory.path);
-        tests_out = list();
-
-        for j=1:size(tests_in)
-            test = tests_in(j);
-            if or(test.name==skip_mat) then
-                continue;
-            end
-            test = st_set_type(test,directory.type);
-            test = st_set_module(test,directory.module);
-            test = st_analyse(test);
-            tests_out($+1) = test;
-        end
-
-        my_tests = lstcat( my_tests , tests_out );
-
-    end
-endfunction
-
-
-
-//-----------------------------------------------------------------------------
-// Pierre MARECHAL
-// Scilab team
-// Date : 28 août 2009
-//
-// List all test file in the directory
-//-----------------------------------------------------------------------------
-
-function tests = get_tests_from_directory(directory)
-
-    tests = list();
-
-    if isdir(directory) then
-        test_mat = gsort(basename(listfiles(directory+"/*.tst")),"lr","i");
-        for i=1:size(test_mat,"*")
-            this_test  = st_new();
-            this_test  = st_set_name(this_test,test_mat(i));
-            this_test  = st_set_path(this_test,pathconvert(directory)+test_mat(i)+".tst");
-            tests($+1) = this_test;
-        end
-    end
-
-endfunction
-
-//-----------------------------------------------------------------------------
-// Pierre MARECHAL
-// Scilab team
-// Date : 28 août 2009
-//
-// => Get subdirectories of a directory
-//
-// directories is a list of "directory" object (See directory interface)
-//-----------------------------------------------------------------------------
-
-function directories = get_directories(directory)
-
-    this_directory_type   = directory.type;
-    directories           = list();
-    directories($+1)      = directory;
-    items = gsort(listfiles(directory.path),"lr","i");
-
-    for i=1:size(items,"*")
-        if isdir(pathconvert(directory.path) + items(i)) then
-
-            new_module = module_new();
-            new_module = module_set_name( new_module , directory.module.name +  "|" + items(i) );
-            new_module = module_set_path( new_module , pathconvert(directory.path) + items(i) );
-
-            new_dir = directory_new();
-            new_dir = directory_set_path(new_dir,pathconvert(directory.path) + items(i));
-            new_dir = directory_set_module(new_dir,new_module);
-            new_dir = directory_set_type(new_dir,directory.type);
-
-            directories = lstcat( directories , get_directories(new_dir) );
-        end
-    end
-endfunction
-
-
-//-----------------------------------------------------------------------------
-// Pierre MARECHAL
-// Scilab team
-// Date : 8 novembre 2007
-//
-// => remove header from the diary txt
-//
-//-----------------------------------------------------------------------------
-
-function dia_out = remove_headers(dia_in)
-
-    dia_out = dia_in;
-    body_start = grep(dia_out,"// <-- HEADER END -->");
-
-    if body_start<>[] then
-        dia_out(1:body_start(1)) = [];
-    end
-
-    body_end   = grep(dia_out,"// <-- FOOTER START -->");
-
-    if body_end<>[] then
-        [dia_nl,dia_nc] = size(dia_out);
-        dia_out(body_end(1):dia_nl) = [];
-    end
-
-    return;
-
-endfunction
-
-//-----------------------------------------------------------------------------
-// Pierre MARECHAL
-// Scilab team
-// Date : 28 oct. 2007
-//
-// => Check ref or generate ref
-//-----------------------------------------------------------------------------
-
-function example = test_examples()
-
-    example = [ sprintf("Examples :\n\n") ];
-
-
-    example = [ example ; sprintf("// Launch all tests\n") ];
-    example = [ example ; sprintf("yasp_run();\n") ];
-    example = [ example ; sprintf("yasp_run([]);\n") ];
-    example = [ example ; sprintf("yasp_run([],[]);\n") ];
-    example = [ example ; "" ];
-    example = [ example ; sprintf("// Test one or several module\n") ];
-    example = [ example ; sprintf("yasp_run(''core'');\n") ];
-    example = [ example ; sprintf("yasp_run(''core'',[]);\n") ];
-    example = [ example ; sprintf("yasp_run([''core'',''string'']);\n") ];
-    example = [ example ; "" ];
-    example = [ example ; sprintf("// Launch one or several test in a specified module\n") ];
-    example = [ example ; sprintf("yasp_run(''core'',[''trycatch'',''opcode'']);\n") ];
-    example = [ example ; "" ];
-    example = [ example ; sprintf("// With options\n") ];
-    example = [ example ; sprintf("yasp_run([],[],''no_check_ref'');\n") ];
-    example = [ example ; sprintf("yasp_run([],[],''no_check_error_output'');\n") ];
-    example = [ example ; sprintf("yasp_run([],[],''create_ref'');\n") ];
-    example = [ example ; sprintf("yasp_run([],[],''list'');\n") ];
-    example = [ example ; sprintf("yasp_run([],[],''help'');\n") ];
-    example = [ example ; sprintf("yasp_run([],[],[''no_check_ref'',''mode_nw'']);\n") ];
-    example = [ example ; "" ];
-
-endfunction
-
-// =============================================================================
-// Pierre MARECHAL
-// Scilab team
-// Date : 31 août 2009
-//
-// singletest interface
-// =============================================================================
-
-// constructor
-// -----------------------------------------------------------------------------
-
-function st = st_new()
-
-    st = tlist([ "T_SINGLETEST"   ..
-    "name"           ..
-    "type"           ..
-    "path"           ..
-    "module"         ..
-    "skip"           ..
-    "content"        ..
-    "interactive"    ..
-    "notyetfixed"    ..
-    "longtime"       ..    // needs long-time duration
-    "reopened"       ..
-    "platform"       ..
-    "language"       ..
-    "jvm_mandatory"  ..
-    "graphic"        ..
-    "mode"           ..    // NW, NWNI, GUI
-    "reference"      ..    // check, create, skip
-    "error_output"   ..    // check, skip
-    "try_catch"      ..
-    "path_dia"       ..    // diary file
-    "path_dia_ref"   ..    // reference file
-    "tmp_tst"        ..    // diary file
-    "tmp_dia"        ..    // reference file
-    "tmp_res"        ..    // diary file
-    "tmp_err"        ..    // reference file
-    "status"         ..    // status
-    "xcos"           ..    // xcos test ?
-    "cmd"            ..    // command to launch
-    ] );
-
-    // Default values
-    st.skip          = %F;
-    st.interactive   = %F;
-    st.notyetfixed   = %F;
-    st.longtime      = %F;
-    st.reopened      = %F;
-    st.jvm_mandatory = %T;
-    st.graphic       = %F;
-    st.mode          = "";
-    st.platform      = "all";
-    st.language      = "any";
-    st.try_catch     = %T;
-    st.error_output  = "check";
-    st.reference     = "check";
-
-    st.path_dia      = "";
-    st.path_dia_ref  = "";
-
-    st.tmp_tst       = "";
-    st.tmp_dia       = "";
-    st.tmp_res       = "";
-    st.tmp_err       = "";
-
-    st.cmd           = "";
-
-    st.content       = "";
-
-    st.status        = status_new();
-
-    st.xcos          = %F;
-
-endfunction
-
-// setters
-// -----------------------------------------------------------------------------
-
-function st = st_set_name(st,name)
-
-    st.name = name;
-
-    st.tmp_tst       = pathconvert( TMPDIR + "/" + name + ".tst"     , %F);
-    st.tmp_dia       = pathconvert( TMPDIR + "/" + name + ".dia.tmp" , %F);
-    st.tmp_res       = pathconvert( TMPDIR + "/" + name + ".res"     , %F);
-    st.tmp_err       = pathconvert( TMPDIR + "/" + name + ".err"     , %F);
-    st.path_dia      = pathconvert( TMPDIR + "/" + name + ".dia"     , %F);
-endfunction
-
-function st = st_set_type(st,sttype)
-    st.type = sttype;
-endfunction
-
-function st = st_set_path(st,path)
-
-    st.path         = path;
-    basepath        = strsubst(path,"/\.tst$/","","r");
-    st.path_dia_ref = basepath + ".dia.ref";
-
-    // Reference file management OS by OS
-    osName = getos();
-    if osName == "Windows" then //Windows
-        altreffile = [ basepath+".win.dia.ref" ];
-    elseif osName == "Darwin" then //MacOSX
-        altreffile = [ basepath+".unix.dia.ref" ; basepath+".macosx.dia.ref" ];
-    elseif osName == "Linux" then //Linux
-        altreffile = [ basepath+".unix.dia.ref" ; basepath+".linux.dia.ref" ];
-    else //others
-        altreffile = [ basepath+".unix.dia.ref" ];
-    end
-
-    for i=1:size(altreffile,"*")
-        if isfile(altreffile(i)) then
-            st.path_dia_ref = altreffile(i);
-        end
-    end
-
-endfunction
-
-function st = st_set_module(st,module)
-    st.module = module;
-endfunction
-
-function st = st_set_skip(st,skip)
-    st.skip = skip;
-endfunction
-
-function st = st_set_content(st,content)
-    st.content = content;
-endfunction
-
-function st = st_set_interactive(st,interactive)
-    st.interactive = interactive;
-endfunction
-
-function st = st_set_notyetfixed(st,notyetfixed)
-    st.notyetfixed = notyetfixed;
-endfunction
-
-function st = st_set_longtime(st,longtime)
-    st.longtime = longtime;
-endfunction
-
-function st = st_set_reopened(st,reopened)
-    st.reopened = reopened;
-endfunction
-
-function st = st_set_platform(st,platform)
-    st.platform = platform;
-endfunction
-
-function st = st_set_jvm_mandatory(st,jvm_mandatory)
-    st.jvm_mandatory = jvm_mandatory;
-endfunction
-
-function st = st_set_graphic(st,graphic)
-    st.graphic = graphic;
-endfunction
-
-function st = st_set_language(st,language)
-    st.language = language;
-endfunction
-
-function st = st_set_try_catch(st,try_catch)
-    st.try_catch = try_catch;
-endfunction
-
-function st = st_set_error_output(st,error_output)
-    st.error_output = error_output;
-endfunction
-
-function st = st_set_reference(st,reference)
-    st.reference = reference;
-endfunction
-
-function st = st_set_status(st,status)
-    st.status = status;
-endfunction
-
-function st = st_set_cmd(st,cmd)
-    st.cmd = cmd;
-endfunction
-
-function st = st_set_mode(st,smode)
-    st.mode = smode;
-endfunction
-
-function st = st_set_xcos(st,xmode)
-    st.xcos = xmode;
-endfunction
-
-// show
-// -----------------------------------------------------------------------------
-
-function st_show(st)
-
-    if st.skip           then st_skip           = "Yes"; else st_skip           = "No"; end
-    if st.interactive    then st_interactive    = "Yes"; else st_interactive    = "No"; end
-    if st.notyetfixed    then st_notyetfixed    = "Yes"; else st_notyetfixed    = "No"; end
-    if st.longtime       then st_longtime       = "Yes"; else st_longtime       = "No"; end
-    if st.reopened       then st_reopened       = "Yes"; else st_reopened       = "No"; end
-    if st.jvm_mandatory  then st_jvm_mandatory  = "Yes"; else st_jvm_mandatory  = "No"; end
-    if st.graphic        then st_graphic        = "Yes"; else st_graphic        = "No"; end
-    if st.try_catch      then st_try_catch      = "Yes"; else st_try_catch      = "No"; end
-    if st.xcos           then st_xcos           = "Yes"; else st_xcos           = "No"; end
-
-    mprintf("Test :\n");
-    mprintf("  name           = %s\n"   ,st.name);
-    mprintf("  type           = %s\n"   ,st.type);
-    mprintf("  module         = %s\n"   ,st.module.name);
-    mprintf("\n");
-
-    mprintf("Test paths :\n");
-    mprintf("  path           = %s\n"   ,st.path);
-    mprintf("  path_dia       = %s\n"   ,st.path_dia);
-    mprintf("  path_dia_ref   = %s\n"   ,st.path_dia_ref);
-    mprintf("  tmp_tst        = %s\n"   ,st.tmp_tst);
-    mprintf("  tmp_dia        = %s\n"   ,st.tmp_dia);
-    mprintf("  tmp_res        = %s\n"   ,st.tmp_res);
-    mprintf("  tmp_err        = %s\n"   ,st.tmp_err);
-    mprintf("\n");
-
-    mprintf("Test features :\n");
-    mprintf("  skip           = %s\n"   ,st_skip);
-    mprintf("  interactive    = %s\n"   ,st_interactive);
-    mprintf("  notyetfixed    = %s\n"   ,st_notyetfixed);
-    mprintf("  longtime       = %s\n"   ,st_longtime);
-    mprintf("  reopened       = %s\n"   ,st_reopened);
-    mprintf("  platform       = %s\n"   ,st.platform);
-    mprintf("  jvm_mandatory  = %s\n"   ,st_interactive);
-    mprintf("  graphic        = %s\n"   ,st_graphic);
-    mprintf("  mode           = %s\n"   ,st.mode);
-    mprintf("  reference      = %s\n"   ,st.reference);
-    mprintf("  error_output   = %s\n"   ,st.error_output);
-    mprintf("  try_catch      = %s\n"   ,st_try_catch);
-    mprintf("  xcos           = %s\n"   ,st_xcos);
-    mprintf("\n");
-
-    mprintf("Test scilab cmd :\n");
-    mprintf("  cmd            = %s\n"   ,st.cmd);
-    mprintf("\n");
-
-    module_show(test.module);
-    status_show(test.status);
-
-endfunction
-
-// Analyse
-// -----------------------------------------------------------------------------
-
-function st = st_analyse(st)
-
-    if typeof(st) <> "T_SINGLETEST" then
-        error(msprintf(gettext("%s: Wrong type for input argument #%d: %s expected.\n"),"st_analyse","T_SINGLETEST",1));
-    end
-
-    if ~isfile(st.path) then
-        error(msprintf(gettext("%s: The test ''%s'' doesn''t exist or is not read available.\n"),"st_analyse",st.path));
-    end
-
-    // Get the test content
-    st = st_set_content(st,mgetl(st.path));
-
-    // Test status
-    // =========================================================================
-
-    if ~ isempty( grep(st.content,"<-- NOT FIXED -->") ) then
-        st = st_set_notyetfixed(st,%T);
-    end
-
-    if ~ isempty( grep(st.content,"<-- REOPENED -->") ) then
-        st = st_set_reopened(st,%T);
-    end
-
-    // platform
-    // =========================================================================
-
-    if ~ isempty( grep(st.content,"<-- WINDOWS ONLY -->") ) then
-        st = st_set_platform(st,"windows");
-    end
-
-    if ~ isempty( grep(st.content,"<-- LINUX ONLY -->") ) then
-        st = st_set_platform(st,"linux");
-    end
-
-    if ~ isempty( grep(st.content,"<-- MACOSX ONLY -->") ) then
-        st = st_set_platform(st,"macosx");
-    end
-
-    if ~ isempty( grep(st.content,"<-- MACOSX ONLY -->") ) then
-        st = st_set_platform(st,"macosx");
-    end
-
-    // Test execution
-    // =========================================================================
-
-    if ~ isempty( grep(st.content,"<-- INTERACTIVE TEST -->") ) then
-        st = st_set_interactive(st,%T);
-    end
-
-    if ~ isempty( grep(st.content,"<-- LONG TIME EXECUTION -->") ) then
-        st = st_set_longtime(st,%T);
-    end
-
-    if ~ isempty( grep(st.content,"<-- TEST WITH GRAPHIC -->") ) then
-        st = st_set_graphic(st,%T);
-        st = st_set_jvm_mandatory(st,%T);
-        st = st_set_mode(st,"NW");
-    end
-
-    if ~ isempty( grep(st.content,"<-- JVM NOT MANDATORY -->") ) then
-        st = st_set_jvm_mandatory(st,%F);
-        st = st_set_mode(st,"NWNI");
-    end
-
-    if ~ isempty( grep(st.content,"<-- XCOS TEST -->") ) then
-        st = st_set_xcos(st,%T);
-        st = st_set_jvm_mandatory(st,%T);
-    end
-    // Language
-    // =========================================================================
-
-    if ~ isempty( grep(st.content,"<-- FRENCH IMPOSED -->") ) then
-        st = st_set_language(st,"fr_FR");
-    end
-
-    if ~ isempty( grep(st.content,"<-- ENGLISH IMPOSED -->") ) then
-        st = st_set_language(st,"en_US");
-    end
-
-    // Test building
-    // =========================================================================
-
-    if ~ isempty( grep(st.content,"<-- NO TRY CATCH -->") ) then
-        st = st_set_try_catch(st,%F);
-    end
-
-    // Test result
-    // =========================================================================
-
-    if ~ isempty( grep(st.content,"<-- NO CHECK ERROR OUTPUT -->") ) then
-        st = st_set_error_output(st,"skip");
-    end
-
-    if ~ isempty( grep(st.content,"<-- NO CHECK REF -->") ) then
-        st = st_set_reference(st,"skip");
-    end
-
-endfunction
-
-
-//-----------------------------------------------------------------------------
-// Pierre MARECHAL
-// Scilab team
-// Date : 28 oct. 2007
-//
-// => Run one test
-//
-// Example of test variable :
-//    name: "bug_793"
-//    path: "/home/robert/scilab/modules/time/tests/nonreg_tests/bug_793.tst"
-//    type: "nonreg_tests"
-//    module: "time"
-//
-//-----------------------------------------------------------------------------
-
-function st = st_run(st)
-
-    //Reset standard globals
-    rand("seed",0);
-    rand("uniform");
-
-    st.status = status_new();
-
-    // Case where the test is skipped
-    // =========================================================================
-
-    // The test is interactive
-
-    if st.interactive then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : interactive test");
-        return;
-    end
-
-    // The test needs long-time duration
-
-    if st.longtime & (testsuite.longtime == "skip") then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : Long time duration");
-        return;
-    end
-
-    // The bug is not yet fixed
-
-    if st.notyetfixed then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : not yet fixed");
-        return;
-    end
-
-    // The bug is reopenned
-
-    if st.reopened then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : Bug reopened");
-        return;
-    end
-
-    // The test cannot be launched on this platform
-
-    if (st.platform=="windows") & (getos() <> "Windows") then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : Windows only");
-        return;
-    end
-
-    if (st.platform=="unix") & getos() == "Windows" then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : Unix only");
-        return;
-    end
-
-    if (st.platform=="linux") & getos() <> "Linux" then
-        st.status = status_set_id(status,10);
-        st.status = status_set_message(status,"skipped : Linux only");
-        return;
-    end
-
-    if (st.platform=="macosx") & getos() <> "Darwin" then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : MacOSX only");
-        return;
-    end
-
-    // The test launches some graphic windows
-
-    if st.graphic & (testsuite.wanted_mode == "NWNI") then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : Test with graphic");
-        return;
-    end
-
-    // Build the test
-    // =========================================================================
-
-    txt = st.content;
-
-    // Do some modification in tst file
-    txt = strsubst(txt,"pause,end" ,"bugmes();quit;end");
-    txt = strsubst(txt,"pause, end","bugmes();quit;end");
-    txt = strsubst(txt,"pause;end" ,"bugmes();quit;end");
-    txt = strsubst(txt,"pause; end","bugmes();quit;end");
-    txt = strsubst(txt,"-->","@#>"); //to avoid suppression of input --> with prompts
-    txt = strsubst(txt,"halt();","");
-
-    // Test header
-
-    head = [                                                                ...
-    "// <-- HEADER START -->";                                              ...
-    "mode(3);" ;                                                            ...
-    // "lines(28,72);";                                                        ...
-    // "lines(0);" ;                                                           ...
-    // "function %onprompt" ;                                                  ...
-    // "quit;" ;                                                               ...
-    // "endfunction" ;                                                         ...
-    // "deff(''[]=bugmes()'',''write(%io(2),''''error on test'''')'');" ;      ...
-    "function [] = bugmes(), disp(""error on test\n"");endfunction";      ...
-    // "predef(''all'');" ;                                                    ...
-    "tmpdirToPrint = msprintf(''TMPDIR1=''''%s''''\n'',TMPDIR);"            ...
-    // "tmpdirToPrint = ""TMPDIR1=""+""TMPDIR"";"                                  ...
-    ];
-
-    if st.xcos then
-        head = [ head ; "loadScicosLibs();"];
-    end
-
-    if st.try_catch then
-        //             head = [ head ; "try" ];
-    end
-
-    head = [head ; "diary(''"+st.tmp_dia+"'');" ;  "disp(tmpdirToPrint);" ; "// <-- HEADER END -->"];
-
-    // Test footer
-
-    tail = [ "// <-- FOOTER START -->" ];
-
-    if st.try_catch then
-        //             tail = [ tail ; "catch" ; "   errmsg = ""<--""+""Error on the test script file""+""-->"";" ; "   printf(""%s\n"",errmsg);" ; "   lasterror()" ; "end"];
-    end
-
-    tail = [ tail; "diary(0);" ];
-
-    if st.graphic then
-        tail = [ tail; "xdel(winsid());sleep(1000);" ];
-    end
-
-    tail = [ tail; "exit;" ; "// <-- FOOTER END -->" ];
-
-    // Assembly
-
-    txt = [head;
-    txt;
-    tail];
-
-    // Build the command
-    // =========================================================================
-
-    // Gestion de l'emplacement de bin/scilab
-    // -------------------------------------------------------------------------
-
-    if (getos() <> "Windows") & ~isfile(SCI+"/bin/scilab")==[] then
-        SCI_BIN = strsubst(SCI,"share/scilab","");
-    else
-        SCI_BIN = SCI;
-    end
-
-    // Mode Argument (NW, NWNI, GUI)
-    // -------------------------------------------------------------------------
-
-    if testsuite.wanted_mode == "NW" then
-        mode_arg = "-nw";
-
-    elseif testsuite.wanted_mode == "NWNI" then
-        mode_arg = "-nwni";
-
-    else
-        if st.mode == "NWNI" then
-            mode_arg = "-nwni";
-        elseif st.mode == "NW" then
-            mode_arg = "-nw";
-        else
-            mode_arg = "-nw";
-        end
-    end
-
-    // Language Argument (en_US, fr_FR, ... )
-    // -------------------------------------------------------------------------
-
-    if st.language == "any" then
-        language_arg = "";
-    elseif getos() == "Windows" then
-        language_arg = "-l "+ st.language;
-    else
-        language_arg = "LANG=" + st.language + " ; ";
-    end
-
-    // Assembly
-    // -------------------------------------------------------------------------
-
-    if getos() == "Windows" then
-        test_cmd = "( """+SCI_BIN+"\bin\YaSp.exe"+""""+" "+mode_arg+" "+language_arg+" -nb -f """+st.tmp_tst+""" > """+st.tmp_res+""" ) 2> """+st.tmp_err+"""";
-    else
-        test_cmd = "( "+language_arg+" "+SCI_BIN+"/bin/scilab "+mode_arg+" -nb -f "+st.tmp_tst+" > "+st.tmp_res+" ) 2> "+st.tmp_err;
-    end
-
-    st= st_set_cmd(st,test_cmd);
-
-    // Remove the previous tmp files
-    // =========================================================================
-
-    if isfile(st.tmp_tst) then
-        deletefile(st.tmp_tst);
-    end
-
-    if isfile(st.tmp_dia) then
-        deletefile(st.tmp_dia);
-    end
-
-    if isfile(st.tmp_res) then
-        deletefile(st.tmp_res);
-    end
-
-    if isfile(st.tmp_err) then
-        deletefile(st.tmp_err);
-    end
-
-
-    // Write the tmp test file
-    // =========================================================================
-    mputl(txt,st.tmp_tst);
-
-
-    // Launch the test exec
-    // =========================================================================
-    host(st.cmd);
-
-    // First Check : error output
-    // =========================================================================
-
-    if (st.error_output == "check") & (testsuite.error_output == "check") then
-
-        tmp_errfile_info = fileinfo(st.tmp_err);
-
-        if ( (tmp_errfile_info <> []) & (tmp_errfile_info(1)<>0) ) then
-            st.status = status_set_id(st.status,5);
-            st.status = status_set_message(st.status,"failed  : error_output not empty");
-            st.status = status_set_details(st.status,sprintf("     Check the following file : \n     - %s",st.tmp_err));
-            return;
-        end
-    end
-
-    //  Get the dia file
-    dia = mgetl(st.tmp_dia);
-
-    // To get TMPDIR value
-    tmpdir1_line = grep(dia,"TMPDIR1");
-    execstr(dia(tmpdir1_line));
-
-    //Check for execution errors
-    if st.try_catch & grep(dia,"<--Error on the test script file-->")<>[] then
-        details = [ sprintf("     Check the following file : \n     - %s",st.tmp_dia); ..
-        sprintf("     Or launch the following command : \n     - exec %s;",st.path) ];
-        st.status = status_set_id(st.status,3);
-        st.status = status_set_message(st.status,"failed  : premature end of the test script");
-        st.status = status_set_details(st.status,details);
-        return;
-    end
-
-    // Remove Header and Footer
-    dia = remove_headers(dia);
-
-    //Check for execution errors
-    dia_tmp = dia;
-    grep_dia = grep(dia_tmp,"//");
-    dia_tmp(grep_dia) = [];  // remove commented lines
-
-    if st.try_catch & grep(dia_tmp,"!--error")<>[] then
-        details = [ sprintf("     Check the following file : \n     - %s",st.tmp_dia); ..
-        sprintf("     Or launch the following command : \n     - exec %s;",st.path) ];
-        st.status = status_set_id(st.status,1);
-        st.status = status_set_message(st.status,"failed  : the string (!--error) has been detected");
-        st.status = status_set_details(st.status,details);
-        return;
-    end
-
-
-    if grep(dia_tmp,"error on test")<>[] then
-        details = [ sprintf("     Check the following file : \n     - %s",st.tmp_dia); ..
-        sprintf("     Or launch the following command : \n     - exec %s;",st.path) ];
-        st.status = status_set_id(st.status,2);
-        st.status = status_set_message(st.status, "failed  : one or several tests failed");
-        st.status = status_set_details(st.status,details);
-        return;
-    end
-
-
-    if tmpdir1_line == [] then
-        st.status = status_set_id(st.status,6);
-        st.status = status_set_message(st.status, "failed  : the dia file is not correct");
-        st.status = status_set_details(st.status,sprintf("     Check the following file : \n     - %s",st.tmp_dia));
-        return;
-    end
-
-
-
-    // Check the reference file only if check_ref (i.e. for the whole
-    // test sequence) is true and this_check_ref (i.e. for the specific current .tst)
-    // is true.
-
-    if (st.reference=="check") & (testsuite.reference=="check")  then
-        if isempty(fileinfo(st.path_dia_ref)) then
-            st.status = status_set_id(st.status,5);
-            st.status = status_set_message(st.status,"failed  : the ref file doesn''t exist");
-            st.status = status_set_details(st.status,sprintf("     Add or create the following file : \n     - %s",st.path_dia_ref));
-            return;
-        end
-    end
-
-    // Comparaison ref <--> dia
-
-    if ( (st.reference=="check") & (testsuite.reference=="check") ) | (testsuite.reference=="create") then
-
-        //  Do some modification in  dia file
-        dia(grep(dia,"disp(tmpdirToPrint)"))= [];
-        dia(grep(dia,"TMPDIR1"))                   = [];
-        dia(grep(dia,"diary(0)"))                  = [];
-
-        dia = strsubst(dia,TMPDIR ,"TMPDIR");
-        dia = strsubst(dia,TMPDIR1,"TMPDIR");
-
-        if getos() == "Windows" then
-            dia = strsubst(dia,strsubst(TMPDIR ,"\","/"),"TMPDIR");
-            dia = strsubst(dia,strsubst(TMPDIR1,"\","/"),"TMPDIR");
-            dia = strsubst(dia,strsubst(TMPDIR ,"/","\"),"TMPDIR");
-            dia = strsubst(dia,strsubst(TMPDIR1,"/","\"),"TMPDIR");
-            dia = strsubst(dia,strsubst(getshortpathname(TMPDIR) ,"\","/"),"TMPDIR");
-            dia = strsubst(dia,strsubst(getshortpathname(TMPDIR1),"\","/"),"TMPDIR");
-            dia = strsubst(dia,getshortpathname(TMPDIR) ,"TMPDIR");
-            dia = strsubst(dia,getshortpathname(TMPDIR1),"TMPDIR");
-        end
-
-        dia = strsubst(dia,SCI,"SCI");
-
-        if getos() == "Windows" then
-            dia = strsubst(dia,strsubst(SCI ,"\","/"),"SCI");
-            dia = strsubst(dia,strsubst(SCI ,"/","\"),"SCI");
-            dia = strsubst(dia,strsubst(getshortpathname(SCI) ,"\","/"),"SCI");
-            dia = strsubst(dia,getshortpathname(SCI) ,"SCI");
-        end
-
-        //suppress the prompts
-        dia = strsubst(dia,"-->" ,"");
-        dia = strsubst(dia,"@#>" ,"-->");
-        dia = strsubst(dia,"-1->","");
-
-        //standardise  number display
-
-        // strsubst(dia," .","0.");
-        // strsubst(dia,"-.","-0.")
-        // strsubst(dia,"E+","D+");
-        // strsubst(dia,"E-","D-");
-
-        //not to change the ref files
-        dia = strsubst(dia,"bugmes();return","bugmes();quit");
-
-        if testsuite.reference=="create" then
-
-            // Delete previous .dia.ref file
-            if fileinfo(st.path_dia_ref) <> [] then
-                deletefile(st.path_dia_ref);
-            end
-
-            mputl(dia,st.path_dia_ref);
-
-            st.status = status_set_id(st.status,20);
-            st.status = status_set_message(st.status,"passed : ref created");
-            return;
-
-        else
-
-            // write down the resulting dia file
-            mputl(dia,st.path_dia);
-
-            //Check for diff with the .ref file
-
-            [u,ierr] = mopen(st.path_dia_ref,"r");
-            if ierr== 0 then //ref file exists
-
-                ref=mgetl(u);
-                mclose(u);
-
-                // suppress blank (diff -nw)
-
-                dia = strsubst(dia," ","");
-                ref = strsubst(ref," ","");
-
-                dia(find(dia=="")) = [];
-                ref(find(ref=="")) = [];
-
-                dia(find(dia=="")) = [];
-                ref(find(ref=="")) = [];
-
-                dia( find(part(dia,(1:2))=="//") ) = [];
-                ref( find(part(ref,(1:2))=="//") ) = [];
-
-                if or(ref<>dia) then
-                    st.status = status_set_id(st.status,4);
-                    st.status = status_set_message(st.status,"failed  : dia and ref are not equal");
-                    st.status = status_set_details(st.status,sprintf("     Compare the following files : \n     - %s\n     - %s",st.path_dia,st.path_dia_ref));
-                    return;
-                end
-
-            else
-                error(sprintf(gettext("The ref file (%s) doesn''t exist"),st.path_dia_ref));
-            end
-        end
-
-    end
-
-    st.status = status_set_id(st.status,0);
-    st.status = status_set_message(st.status,"passed");
-
-    return;
-
-endfunction
-
-
-
-
-
-
-
-// =============================================================================
-// Pierre MARECHAL
-// Scilab team
-// Date : 31 août 2009
-//
-// module interface
-// =============================================================================
-
-// constructor
-// -----------------------------------------------------------------------------
-
-function md = module_new()
-    md = tlist([  "T_MODULE" "name" "path" "items" ] );
-endfunction
-
-// setters
-// -----------------------------------------------------------------------------
-
-function md = module_set_name(md,name)
-    md.name  = name;
-    if isempty( regexp(stripblanks(name),"/\|/") ) then
-        md.items = [ name ];
-    else
-        md.items = stripblanks( strsubst( strsplit(name,regexp(stripblanks(name),"/\|/")) , "/\|$/","","r" ) );
-    end
-endfunction
-
-function md = module_set_path(md,path)
-    md.path = path;
-endfunction
-
-// show
-// -----------------------------------------------------------------------------
-
-function module_show(module)
-    mprintf("Module :\n");
-    mprintf("  name           = %s\n"   ,module.name);
-    mprintf("  path           = %s\n"   ,module.path);
-    mprintf("  items          = %s\n"   ,module.items);
-    mprintf("\n");
-endfunction
-
-
-
-// =============================================================================
-// Pierre MARECHAL
-// Scilab team
-// Date : 31 août 2009
-//
-// directory interface
-// =============================================================================
-
-// constructor
-// -----------------------------------------------------------------------------
-
-function directory = directory_new()
-    directory = tlist([  "T_DIRECTORY" "path" "module" "type"]);
-endfunction
-
-// setters
-// -----------------------------------------------------------------------------
-
-function directory = directory_set_path(directory,path)
-    directory.path = path;
-endfunction
-
-function directory = directory_set_module(directory,module)
-    directory.module = module;
-endfunction
-
-function directory = directory_set_type(directory,dtype)
-    directory.type = dtype;
-endfunction
-
-
-// show
-// -----------------------------------------------------------------------------
-
-function directory_show(directory)
-    mprintf("Directory :\n");
-    mprintf("  path           = %s\n"   ,directory.path);
-    mprintf("  module         = %s\n"   ,directory.module.name);
-    mprintf("  type           = %s\n"   ,directory.type);
-    mprintf("\n");
-endfunction
-
-
-
-
-// =============================================================================
-// Pierre MARECHAL
-// Scilab team
-// Date : 31 août 2009
-//
-// testsuite interface
-// =============================================================================
-
-// constructor
-// -----------------------------------------------------------------------------
-
-function testsuite = testsuite_new()
-
-    testsuite = tlist([  "T_TESTSUITE" "items" "current_mode" "wanted_mode" "reference" "error_output" "longtime"]);
-
-    testsuite.items = list();
-
-    // Default values
-
-    if and(getscilabmode() <> ["NW";"STD"]) then
-        testsuite.current_mode = "NWNI";
-    else
-        testsuite.current_mode = "NW";
-    end
-
-    testsuite.wanted_mode  = "";
-    testsuite.reference    = "check";
-    testsuite.error_output = "check";
-    testsuite.longtime     = "skip";
-
-endfunction
-
-// Add tests
-// -----------------------------------------------------------------------------
-
-function testsuite = testsuite_add_tests(testsuite,tests)
-    testsuite.items = lstcat(testsuite.items,tests);
-endfunction
-
-function testsuite = testsuite_add_one_test(testsuite,test)
-    testsuite.items($+1) = test;
-endfunction
-
-// Number of tests
-// -----------------------------------------------------------------------------
-
-function l = testsuite_length(testsuite)
-    l = size(testsuite.items);
-endfunction
-
-// Setters
-// -----------------------------------------------------------------------------
-
-function testsuite = testsuite_set_WM(testsuite,wanted_mode)
-    testsuite.wanted_mode = wanted_mode;
-endfunction
-
-function testsuite = testsuite_set_reference(testsuite,reference)
-    testsuite.reference = reference;
-endfunction
-
-function testsuite = testsuite_set_EO(testsuite,error_output)
-    testsuite.error_output = error_output;
-endfunction
-
-// Enable/Disable Long Time Execution tests
-function testsuite = testsuite_set_LT(testsuite,lt)
-    testsuite.longtime = lt;
-endfunction
-
-// List tests
-// -----------------------------------------------------------------------------
-
-function testsuite_list(testsuite)
-
-    for i=1:size(testsuite.items)
-        test = testsuite.items(i);
-        printf("   %03d - ",i);
-        printf("[%s] %s\n",test.module.name,test.name);
-    end
-
-endfunction
-
-// Launch tests
-// -----------------------------------------------------------------------------
-
-function testsuite_run(testsuite)
-
-    details_failed     = "";
-    test_count         = 0;
-    test_passed_count  = 0;
-    test_failed_count  = 0;
-    test_skipped_count = 0;
-
-    printf("   TMPDIR = %s\n",TMPDIR);
-    printf("\n");
-
-    start_date = getdate();
-    test_count = length(testsuite.items);
-
-    for i=1:test_count
-
-        test        = testsuite.items(i);
-        test_module = test.module.name;
-        test_name   = test.name;
-
-        // Improve the display of the module
-        if isdir(test_module) then
-            if part(test.module.name,1:length(SCI)) == SCI then
-                test_module = "SCI" + part(test_module,length(SCI)+1:length(test_module));
-            elseif part(test.module.name,1:length(SCIHOME)) == SCIHOME then
-                test_module = "SCIHOME" + part(test_module,length(SCIHOME)+1:length(test_module));
-            end
-        end
-
-        printf("   %03d/%03d - ",i,test_count);
-        printf("[%s] %s",test_module,test_name);
-        for j = length(test_name+test_module):50
-            printf(".");
-        end
-
-        test = st_run(test);
-
-        printf("%s \n",test.status.message);
-
-        // Recencement des tests
-
-        if test.status.id == 0 then
-            // passed
-            test_passed_count = test_passed_count + 1;
-
-        elseif (test.status.id > 0) & (test.status.id < 10) then
-            // failed
-            test_failed_count = test_failed_count + 1;
-            details_failed = [ details_failed ; sprintf("   TEST : [%s] %s",test.module.name,test.name)];
-            details_failed = [ details_failed ; sprintf("     %s",test.status.message) ];
-            details_failed = [ details_failed ; test.status.details ];
-            details_failed = [ details_failed ; "" ];
-
-        elseif (test.status.id >= 10) & (test.status.id < 20) then
-            // skipped
-            test_skipped_count = test_skipped_count + 1;
-        end
-    end
-
-    end_date = getdate();
-
-    // Summary
-
-    if test_count<>0 then
-        test_passed_percent  = test_passed_count  / test_count * 100;
-        test_skipped_percent = test_skipped_count / test_count * 100;
-        test_failed_percent  = test_failed_count  / test_count * 100;
-    else
-        test_passed_percent  = 0;
-        test_skipped_percent = 0;
-        test_failed_percent  = 0;
-    end
-
-    printf("\n");
-    printf("   --------------------------------------------------------------------------\n");
-    printf("   Summary\n\n");
-    printf("   tests                     %4d - 100 %% \n",test_count);
-    printf("   passed                    %4d - %3d %% \n",test_passed_count ,test_passed_percent);
-    printf("   failed                    %4d - %3d %% \n",test_failed_count ,test_failed_percent);
-    printf("   skipped                   %4d - %3d %% \n",test_skipped_count,test_skipped_percent);
-    printf("   length                          %4.2f sec \n" ,etime(end_date,start_date));
-    printf("   --------------------------------------------------------------------------\n");
-
-    if test_failed_count > 0 then
-        printf("   Details\n\n");
-        printf("%s\n",details_failed);
-        printf("\n");
-        printf("   --------------------------------------------------------------------------\n");
-    end
-
-endfunction
-
-
-// =============================================================================
-// Pierre MARECHAL
-// Scilab team
-// Date : 1 septembre 2009
-//
-// status
-// =============================================================================
-
-// constructor
-// -----------------------------------------------------------------------------
-
-function status = status_new()
-    status = tlist([  "T_STATUS" "id" "message" "details"]);
-
-    status.id      = 0;
-    status.message = "";
-    status.details = "";
-
-endfunction
-
-// setters
-// -----------------------------------------------------------------------------
-
-function status = status_set_id(status,id)
-    status.id = id;
-endfunction
-
-function status = status_set_message(status,smessage)
-    status.message = smessage;
-endfunction
-
-function status = status_set_details(status,details)
-    status.details = details;
-endfunction
-
-// show
-// -----------------------------------------------------------------------------
-
-function status_show(status)
-    mprintf("Status :\n");
-    mprintf("  id             = %d\n"   ,status.id);
-    mprintf("  message        = %s\n"   ,status.message);
-    mprintf("  details        = %s\n"   ,status.details);
-    mprintf("\n");
-endfunction
-
-
index 75061ca..88084cf 100644 (file)
@@ -51,18 +51,18 @@ Function::ReturnValue sci_funclist(types::typed_list &in, int _iRetCount, types:
         pstLibName = L"";
     }
 
-    std::list<symbol::Symbol>* FuncList = pContext->getFunctionList(pstLibName);
+    std::list<symbol::Symbol> funcList;
+    int size = pContext->getFunctionList(funcList, pstLibName);
 
-    String *pS = new String((int)FuncList->size(), 1);
+    String *pS = new String(size, 1);
 
     std::list<symbol::Symbol>::iterator it;
     int i = 0;
-    for (it = FuncList->begin() ; it != FuncList->end() ; ++it)
+    for (auto it : funcList)
     {
-        pS->set(i++, 0, it->getName().c_str());
+        pS->set(i++, 0, it.getName().c_str());
     }
 
-    delete FuncList;
     out.push_back(pS);
     return Function::OK;
 }
index f535543..84abcf9 100644 (file)
@@ -32,16 +32,16 @@ Function::ReturnValue sci_librarieslist(types::typed_list &in, int _iRetCount, t
         return Function::Error;
     }
 
-    std::list<std::wstring>* lst = symbol::Context::getInstance()->getLibrariesList();
+    std::list<std::wstring> lst;
+    int size = symbol::Context::getInstance()->getLibrariesList(lst);
 
-    String* pOut = new String(static_cast<int>(lst->size()), 1);
+    String* pOut = new String(size, 1);
     int i = 0;
-    for (auto l : *lst)
+    for (auto l : lst)
     {
         pOut->set(i++, l.c_str());
     }
 
-    delete lst;
     out.push_back(pOut);
     return Function::OK;
 }
index c1cd494..e42ff68 100644 (file)
@@ -68,15 +68,15 @@ Function::ReturnValue sci_libraryinfo(types::typed_list &in, int _iRetCount, typ
 
     types::Library* lib = pIT->getAs<Library>();
 
-    std::list<std::wstring>* names = lib->getMacrosName();
-    String* pNames = new String(static_cast<int>(names->size()), 1);
+    std::list<std::wstring> names;
+    int size = lib->getMacrosName(names);
+    String* pNames = new String(size, 1);
     int i = 0;
-    for (auto name : *names)
+    for (auto name : names)
     {
         pNames->set(i++, name.c_str());
     }
 
-    delete names;
     out.push_back(pNames);
 
     if (_iRetCount == 2)
index 97ec84d..eb32c8c 100644 (file)
@@ -52,26 +52,22 @@ Function::ReturnValue sci_whereis(types::typed_list &in, int _iRetCount, types::
             return Function::Error;
         }
 
-        std::list<std::wstring>* lst = symbol::Context::getInstance()->getWhereIs(pS->get(0));
-        if (lst == NULL || lst->empty())
+        std::list<std::wstring> lst;
+        int size = symbol::Context::getInstance()->getWhereIs(lst, pS->get(0));
+        if (lst.empty())
         {
             out.push_back(types::Double::Empty());
-            if (lst)
-            {
-                delete lst;
-            }
             return Function::OK;
         }
 
-        types::String* pOut = new types::String(static_cast<int>(lst->size()), 1);
+        types::String* pOut = new types::String(size, 1);
         int i = 0;
-        for (std::wstring l : *lst)
+        for (std::wstring l : lst)
         {
             pOut->set(i++, l.c_str());
         }
 
         out.push_back(pOut);
-        delete lst;
     }
     else
     {
index f37b81c..0453540 100644 (file)
@@ -20,8 +20,7 @@ function list_keywords = getscilabkeywords()
     [scilab_primitives, scilab_commands] = what();
 
     // predefined variables
-    names = who("get");
-    predef_variables = names(($-predef())+1:$);
+    predef_variables = predef("names");
 
     //library functions
     libvar = librarieslist();
index 5c0db1d..6ca73eb 100644 (file)
@@ -48,6 +48,7 @@ extern "C"
 #include "os_wfopen.h"
 #include "sciprint.h"
 #include "freeArrayOfString.h"
+#include "Scierror.h"
 }
 
 
@@ -218,7 +219,17 @@ Function::ReturnValue sci_genlib(types::typed_list &in, int _iRetCount, types::t
             delete parser.getTree();
         }
 
-        symbol::Context::getInstance()->put(symbol::Symbol(pstLibName), pLib);
+        symbol::Context* ctx = symbol::Context::getInstance();
+        symbol::Symbol sym = symbol::Symbol(pstLibName);
+        if (ctx->isprotected(sym) == false)
+        {
+            ctx->put(symbol::Symbol(pstLibName), pLib);
+        }
+        else
+        {
+            Scierror(999, _("Redefining permanent variable.\n"));
+            return Function::Error;
+        }
     }
 
     freeArrayOfWideString(pstPath, iNbFile);
index cf6e577..3e73d6b 100644 (file)
@@ -183,7 +183,18 @@ types::Library* loadlib(std::wstring _wstXML, bool _isFile, bool _bAddInContext)
 
     if (_bAddInContext)
     {
-        symbol::Context::getInstance()->put(symbol::Symbol(pstLibName), lib);
+        symbol::Context* ctx = symbol::Context::getInstance();
+        symbol::Symbol sym = symbol::Symbol(pstLibName);
+        if (ctx->isprotected(sym) == false)
+        {
+            ctx->put(symbol::Symbol(pstLibName), lib);
+        }
+        else
+        {
+            delete lib;
+            lib = NULL;
+        }
+
     }
 
     xmlFreeDoc(doc);
index 1f48061..4664e18 100644 (file)
@@ -127,9 +127,11 @@ function savematfile(varargin)
         mtlb_names=vars;
 
         // Part to delete Scilab variables from mtlb_names (should be improved)
-        mtlb_names(1)=[];// remove varargin
-        mtlb_names(mtlb_names=="savematfile")=[];
-        mtlb_names(($-predef()+1):$)=[]; // clear predefined variables
+        predef_names = [predef("names");"savematfile";"varargin"];
+        for i=1:size(predef_names, "*")
+            mtlb_names(mtlb_names==predef_names(i))=[];
+        end
+        //mtlb_names(($-predef()+1):$)=[]; // clear predefined variables
     end
 
     // If binary format and no extension for filename, .mat is added
@@ -225,6 +227,7 @@ function savematfile(varargin)
                 MOPT=[M O P T]
 
                 [m,n]=size(x)
+
                 head=[MOPT*[1000;100;10;1] m,n,it,length(mtlb_names(mtlb_k))+1]
 
                 mput(head,"uil",mtlb_fd);
index b24ee40..a33631a 100644 (file)
@@ -494,13 +494,14 @@ Function::ReturnValue sci_string(typed_list &in, int _iRetCount, typed_list &out
         {
             Library* pL = in[0]->getAs<Library>();
             std::wstring path = pL->getPath();
-            std::list<std::wstring>* macros = pL->getMacrosName();
-            String* pS = new String((int)macros->size() + 1, 1);
+            std::list<std::wstring> macros;
+            int size = pL->getMacrosName(macros);
+            String* pS = new String(size + 1, 1);
             pS->set(0, path.c_str());
             int i = 1;
-            for (auto it = macros->begin(), itEnd = macros->end(); it != itEnd; ++it, ++i)
+            for (auto it : macros)
             {
-                pS->set(i, (*it).c_str());
+                pS->set(i++, it.c_str());
             }
 
             out.push_back(pS);
index 74f82e2..28ee7aa 100644 (file)
@@ -35,14 +35,15 @@ Function::ReturnValue sci_inspectorGetFunctionList(typed_list &in, int _iRetCoun
 
     symbol::Context* pC = symbol::Context::getInstance();
 
-    std::list<symbol::Symbol>* FuncName = pC->getFunctionList(L"");
+    std::list<symbol::Symbol> funcName;
+    int size = pC->getFunctionList(funcName, L"");
 
-    String* pOut = new String((int)FuncName->size(), 4);
+    String* pOut = new String(size, 4);
 
-    std::list<symbol::Symbol>::iterator it = FuncName->begin();
-    for (int i = 0; it != FuncName->end() ; ++it, i++)
+    int i = 0;
+    for (auto it : funcName)
     {
-        types::Callable* pCall = pC->get(*it)->getAs<types::Callable>();
+        types::Callable* pCall = pC->get(it)->getAs<types::Callable>();
         //Function name
         pOut->set(i, 0, pCall->getName().c_str());
         pOut->set(i, 1, pCall->getModule().c_str());
@@ -56,9 +57,10 @@ Function::ReturnValue sci_inspectorGetFunctionList(typed_list &in, int _iRetCoun
         {
             pOut->set(i, 3, L"");
         }
+
+        ++i;
     }
 
-    delete FuncName;
     out.push_back(pOut);
     return Function::OK;
 }
index 12f5e08..2515c40 100644 (file)
@@ -86,9 +86,12 @@ void SetBrowseVarData()
     int i = 0;
 
     symbol::Context* ctx = symbol::Context::getInstance();
-    std::list<symbol::Variable*>* lstVars = ctx->getVarsToVariableBrowser();
-    std::list<symbol::Library*>* lstLibs = ctx->getLibsToVariableBrowser();
-    iLocalVariablesUsed = static_cast<int>(lstVars->size() + lstLibs->size());
+
+    std::list<symbol::Variable*> lstVars;
+    std::list<symbol::Library*> lstLibs;
+
+    iLocalVariablesUsed = ctx->getVarsToVariableBrowser(lstVars);
+    iLocalVariablesUsed += ctx->getLibsToVariableBrowser(lstLibs);
 
     char **pstAllVariableNames = new char*[iLocalVariablesUsed];
     char **pstAllVariableVisibility = new char*[iLocalVariablesUsed];
@@ -109,7 +112,7 @@ void SetBrowseVarData()
     int iLevel = ctx->getScopeLevel();
 
     // for each local variable get information
-    for (auto var : *lstVars)
+    for (auto var : lstVars)
     {
         //get top level value
         symbol::ScopedVariable* sv = var->top();
@@ -213,7 +216,7 @@ void SetBrowseVarData()
         ++i;
     }
 
-    for (auto lib : *lstLibs)
+    for (auto lib : lstLibs)
     {
         //get top level value
         symbol::ScopedLibrary* sl = lib->top();
@@ -275,8 +278,6 @@ void SetBrowseVarData()
     delete[] piAllVariableIntegerTypes;
     delete[] piAllVariableNbRows;
     delete[] piAllVariableNbCols;
-
-    delete lstVars;
 }
 
 /*--------------------------------------------------------------------------*/