summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSt├ęphane MOTTELET <stephane.mottelet@utc.fr>2019-07-01 17:08:58 +0200
committerClement DAVID <clement.david@esi-group.com>2019-07-19 14:04:05 +0200
commitc69421ba366f75283aab3dfd4eccf70b985a89a1 (patch)
tree6f2ce189bed3a5207ec042d087ab9058f9fbb66c
parent2482db1753d7383cf16611a2823d035c9815acb4 (diff)
downloadscilab-c69421ba366f75283aab3dfd4eccf70b985a89a1.zip
scilab-c69421ba366f75283aab3dfd4eccf70b985a89a1.tar.gz
* Bug 16111 fixed: now isglobal supports array of strings
http://bugzilla.scilab.org/show_bug.cgi?id=16111 Change-Id: I5fefe90e3e688a9dd8699f365c275cfbb603459e
-rw-r--r--modules/core/tests/nonreg_tests/bug_16111.tst23
-rw-r--r--scilab/CHANGES.md1
-rw-r--r--scilab/modules/core/sci_gateway/cpp/sci_isglobal.cpp29
3 files changed, 38 insertions, 15 deletions
diff --git a/modules/core/tests/nonreg_tests/bug_16111.tst b/modules/core/tests/nonreg_tests/bug_16111.tst
new file mode 100644
index 0000000..9a54897
--- /dev/null
+++ b/modules/core/tests/nonreg_tests/bug_16111.tst
@@ -0,0 +1,23 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2019 - St├ęphane MOTTELET
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7//
8// <-- Non-regression test for bug 16111 -->
9//
10// <-- CLI SHELL MODE -->
11// <-- NO CHECK REF -->
12//
13// <-- Bugzilla URL -->
14// http://bugzilla.scilab.org/16111
15//
16// <-- Short Description -->
17// isglobal does not support non-scalar array of string as input
18
19global a;
20a=1;
21b=1;
22
23assert_checkequal(isglobal(["a","b"]), [%t, %f]) \ No newline at end of file
diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md
index 91c5625..0c823bb 100644
--- a/scilab/CHANGES.md
+++ b/scilab/CHANGES.md
@@ -178,5 +178,6 @@ Bug Fixes
178* [#16075](http://bugzilla.scilab.org/show_bug.cgi?id=16075): `prettyprint()` was broken for cells. 178* [#16075](http://bugzilla.scilab.org/show_bug.cgi?id=16075): `prettyprint()` was broken for cells.
179* [#16085](http://bugzilla.scilab.org/show_bug.cgi?id=16085): insertion in an empty struct was broken. 179* [#16085](http://bugzilla.scilab.org/show_bug.cgi?id=16085): insertion in an empty struct was broken.
180* [#16087](http://bugzilla.scilab.org/show_bug.cgi?id=16087): Insertion of struct() in a non-empty struct crashed Scilab. 180* [#16087](http://bugzilla.scilab.org/show_bug.cgi?id=16087): Insertion of struct() in a non-empty struct crashed Scilab.
181* [#16111](http://bugzilla.scilab.org/show_bug.cgi?id=16111): `isglobal` was not supporting non-scalar array of strings as input.
181 182
182 183
diff --git a/scilab/modules/core/sci_gateway/cpp/sci_isglobal.cpp b/scilab/modules/core/sci_gateway/cpp/sci_isglobal.cpp
index e41df61..3a55c61 100644
--- a/scilab/modules/core/sci_gateway/cpp/sci_isglobal.cpp
+++ b/scilab/modules/core/sci_gateway/cpp/sci_isglobal.cpp
@@ -36,29 +36,28 @@ types::Function::ReturnValue sci_isglobal(types::typed_list &in, int _iRetCount,
36 Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), "isglobal", 1); 36 Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), "isglobal", 1);
37 return types::Function::Error; 37 return types::Function::Error;
38 } 38 }
39 else 39
40 if (in[0]->isString() == false)
40 { 41 {
41 if (in[0]->isString() == false) 42 Scierror(999, _("%s: Wrong type for input argument #%d: string expected.\n"), "isglobal", 1);
42 { 43 return types::Function::Error;
43 Scierror(999, _("%s: Wrong type for input argument #%d: string expected.\n"), "isglobal", 1); 44 }
44 return types::Function::Error;
45 }
46 45
47 types::String* pS = in[0]->getAs<types::String>(); 46 types::String* pS = in[0]->getAs<types::String>();
48 if (pS->isScalar() == false) 47 types::Bool *pOut = new types::Bool(pS->getDims(), pS->getDimsArray());
49 {
50 Scierror(999, _("%s: Wrong type for input argument #%d: string expected.\n"), "isglobal", 1);
51 return types::Function::Error;
52 }
53 48
54 if (symbol::Context::getInstance()->isGlobalVisible(symbol::Symbol(pS->get(0)))) 49 for (int i = 0; i < pS->getSize(); i++)
50 {
51 if (symbol::Context::getInstance()->isGlobalVisible(symbol::Symbol(pS->get(i))))
55 { 52 {
56 out.push_back(new types::Bool(1)); 53 pOut->set(i,1);
57 } 54 }
58 else 55 else
59 { 56 {
60 out.push_back(new types::Bool(0)); 57 pOut->set(i,0);
61 } 58 }
62 } 59 }
60
61 out.push_back(pOut);
63 return types::Function::OK; 62 return types::Function::OK;
64} 63}