summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas <nicolas.carrez@scilab-enterprises.com>2016-10-26 12:23:35 +0200
committerPaul BIGNIER <paul.bignier@scilab-enterprises.com>2016-10-26 18:46:07 +0200
commit7125f73a255d1e343db4d3aa5312ba41f41cee19 (patch)
tree3c1940499c5fe78c00c4aba8c300d842c17cc169
parent862728671c013d7f2ca698fb1d801852a9569012 (diff)
downloadscilab-7125f73a255d1e343db4d3aa5312ba41f41cee19.zip
scilab-7125f73a255d1e343db4d3aa5312ba41f41cee19.tar.gz
* Bug #14564 fixed - fieldnames failed for empty structs
Change-Id: I03d17878412e13ea8f4334763fa3aaac609e9460
-rw-r--r--scilab/CHANGES.md1
-rw-r--r--scilab/modules/core/sci_gateway/cpp/sci_fieldnames.cpp13
-rw-r--r--scilab/modules/types/tests/nonreg_tests/bug_14564.dia.ref19
-rw-r--r--scilab/modules/types/tests/nonreg_tests/bug_14564.tst21
4 files changed, 52 insertions, 2 deletions
diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md
index 2805f89..a50b17a 100644
--- a/scilab/CHANGES.md
+++ b/scilab/CHANGES.md
@@ -349,6 +349,7 @@ Bug Fixes
349* [#14513](http://bugzilla.scilab.org/show_bug.cgi?id=14513): `isqual` comparing two built-in functions yielded an error. 349* [#14513](http://bugzilla.scilab.org/show_bug.cgi?id=14513): `isqual` comparing two built-in functions yielded an error.
350* [#14527](http://bugzilla.scilab.org/show_bug.cgi?id=14527): Calling pathconvert function without parameters crashed Scilab. 350* [#14527](http://bugzilla.scilab.org/show_bug.cgi?id=14527): Calling pathconvert function without parameters crashed Scilab.
351* [#14557](http://bugzilla.scilab.org/show_bug.cgi?id=14557): `csim` failed when the system has no state. 351* [#14557](http://bugzilla.scilab.org/show_bug.cgi?id=14557): `csim` failed when the system has no state.
352* [#14564](http://bugzilla.scilab.org/show_bug.cgi?id=14564): fieldnames failed for empty structs.
352* [#14582](http://bugzilla.scilab.org/show_bug.cgi?id=14582): `gettext`or it alias `_()` were sometimes applied to broken literal strings 353* [#14582](http://bugzilla.scilab.org/show_bug.cgi?id=14582): `gettext`or it alias `_()` were sometimes applied to broken literal strings
353* [#14586](http://bugzilla.scilab.org/show_bug.cgi?id=14586): Xcos simulation stop button did not work. 354* [#14586](http://bugzilla.scilab.org/show_bug.cgi?id=14586): Xcos simulation stop button did not work.
354* [#14587](http://bugzilla.scilab.org/show_bug.cgi?id=14587): Datatip textbox wrong clipping when loaded from `*.scg` file. 355* [#14587](http://bugzilla.scilab.org/show_bug.cgi?id=14587): Datatip textbox wrong clipping when loaded from `*.scg` file.
diff --git a/scilab/modules/core/sci_gateway/cpp/sci_fieldnames.cpp b/scilab/modules/core/sci_gateway/cpp/sci_fieldnames.cpp
index a800f24..e545d49 100644
--- a/scilab/modules/core/sci_gateway/cpp/sci_fieldnames.cpp
+++ b/scilab/modules/core/sci_gateway/cpp/sci_fieldnames.cpp
@@ -51,8 +51,17 @@ types::Function::ReturnValue sci_fieldnames(types::typed_list &in, int _iRetCoun
51 types::String* pFields = in[0]->getAs<types::Struct>()->getFieldNames(); 51 types::String* pFields = in[0]->getAs<types::Struct>()->getFieldNames();
52 if (pFields) 52 if (pFields)
53 { 53 {
54 out.push_back(pFields); 54 if (pFields->getSize() == 0)
55 //delete pFields; 55 {
56 delete pFields;
57 out.push_back(types::Double::Empty());
58 }
59 else
60 {
61
62 out.push_back(pFields);
63 //delete pFields;
64 }
56 } 65 }
57 else 66 else
58 { 67 {
diff --git a/scilab/modules/types/tests/nonreg_tests/bug_14564.dia.ref b/scilab/modules/types/tests/nonreg_tests/bug_14564.dia.ref
new file mode 100644
index 0000000..e84d5ba
--- /dev/null
+++ b/scilab/modules/types/tests/nonreg_tests/bug_14564.dia.ref
@@ -0,0 +1,19 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Scilab Enterprises - Nicolas Carrez
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7//
8// <-- Non-regression test for bug 14564 -->
9//
10// <-- CLI SHELL MODE -->
11//
12// <-- Bugzilla URL -->
13// http://bugzilla.scilab.org/show_bug.cgi?id=14564
14//
15// <-- Short Description -->
16// fieldnames failed for empty struct
17a.r = 1;
18a.r = null();
19assert_checkequal(fieldnames(a), []);
diff --git a/scilab/modules/types/tests/nonreg_tests/bug_14564.tst b/scilab/modules/types/tests/nonreg_tests/bug_14564.tst
new file mode 100644
index 0000000..2d98da3
--- /dev/null
+++ b/scilab/modules/types/tests/nonreg_tests/bug_14564.tst
@@ -0,0 +1,21 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Scilab Enterprises - Nicolas Carrez
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7//
8// <-- Non-regression test for bug 14564 -->
9//
10// <-- CLI SHELL MODE -->
11//
12// <-- Bugzilla URL -->
13// http://bugzilla.scilab.org/show_bug.cgi?id=14564
14//
15// <-- Short Description -->
16// fieldnames failed for empty struct
17
18a.r = 1;
19a.r = null();
20assert_checkequal(fieldnames(a), []);
21