warning about redefining function fixed 50/17650/3
Cedric Delamarre [Thu, 7 Jan 2016 15:51:27 +0000 (16:51 +0100)]
test_run ast bug_13919
test_run functions bug_1469

a=1;
function a(), end

Change-Id: Icfb02480fb83e18fbb6d3ba9f9cd56048eb2c9b1

scilab/modules/ast/src/cpp/symbol/variables.cpp

index 7ece052..f19447a 100644 (file)
@@ -99,7 +99,7 @@ bool Variable::put(types::InternalType* _pIT, int _iLevel)
                 int iFuncProt = ConfigVariable::getFuncprot();
                 if (iFuncProt != 0)
                 {
-                    bool bEquals = false;
+                    bool bEquals = true;
                     if (pIT && pIT->isCallable())
                     {
                         if (pIT->isMacroFile())
@@ -121,13 +121,16 @@ bool Variable::put(types::InternalType* _pIT, int _iLevel)
                             return false;
                         }
 
-                        wchar_t pwstFuncName[1024];
-                        os_swprintf(pwstFuncName, 1024, L"%-24ls", name.getName().c_str());
-                        char* pstFuncName = wide_string_to_UTF8(pwstFuncName);
+                        if (ConfigVariable::getWarningMode())
+                        {
+                            wchar_t pwstFuncName[1024];
+                            os_swprintf(pwstFuncName, 1024, L"%-24ls", name.getName().c_str());
+                            char* pstFuncName = wide_string_to_UTF8(pwstFuncName);
 
-                        sciprint(_("Warning : redefining function: %s. Use funcprot(0) to avoid this message"), pstFuncName);
-                        sciprint("\n");
-                        FREE(pstFuncName);
+                            sciprint(_("Warning : redefining function: %s. Use funcprot(0) to avoid this message"), pstFuncName);
+                            sciprint("\n");
+                            FREE(pstFuncName);
+                        }
                     }
                 }
             }
@@ -396,21 +399,21 @@ int Variables::getFunctionList(std::list<types::Callable *>& lst, std::wstring _
 {
     for (auto var : vars)
     {
-       if (var.second->empty())
-       {
-           continue;
-       }
-       
-       if ((var.second->top()->m_iLevel == _iLevel || _iLevel == 1) && var.second->top()->m_pIT->isCallable())
-       {
-           types::Callable * pCall = var.second->top()->m_pIT->getAs<types::Callable>();
-           if (_stModuleName == L"" || _stModuleName == pCall->getModule())
-           {
-               lst.push_back(pCall);
-           }
-       }
+        if (var.second->empty())
+        {
+            continue;
+        }
+
+        if ((var.second->top()->m_iLevel == _iLevel || _iLevel == 1) && var.second->top()->m_pIT->isCallable())
+        {
+            types::Callable * pCall = var.second->top()->m_pIT->getAs<types::Callable>();
+            if (_stModuleName == L"" || _stModuleName == pCall->getModule())
+            {
+                lst.push_back(pCall);
+            }
+        }
     }
-    
+
     return static_cast<int>(lst.size());
 }