From: Antoine ELIAS Date: Fri, 19 Oct 2018 20:07:20 +0000 (+0200) Subject: bug 15811: fix Cell::operator== function X-Git-Tag: 6.0.2~152 X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=commitdiff_plain;h=e30b5609bfd8d7d13821f90bf4e19a855f8c856c bug 15811: fix Cell::operator== function http://bugzilla.scilab.org/show_bug.cgi?id=15811 Change-Id: I2e0170ff779fe1924933a9f4ab55c35db90abd9a --- diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index aa2b4ac..7dd0a05 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -656,6 +656,7 @@ Known issues * [#15806](http://bugzilla.scilab.org/show_bug.cgi?id=15806): `colorbar(..)` missed some simple syntaxes with default umin, umax and colminmax values, such as `colorbar()`. * [#15808](http://bugzilla.scilab.org/show_bug.cgi?id=15808): `[5i]` was parsed as `[5,i]` * [#15809](http://bugzilla.scilab.org/show_bug.cgi?id=15809): HDF5 load/save was super slow for nested lists. +* [#15811](http://bugzilla.scilab.org/show_bug.cgi?id=15811): comparison of containers with cell failed. * [#15813](http://bugzilla.scilab.org/show_bug.cgi?id=15813): In polarplot mode, datatips displayed irrelevant cartesian coordinates instead of polar ones. * [#15814](http://bugzilla.scilab.org/show_bug.cgi?id=15814): Selecting graphic children with booleans yielded an error. * [#15815](http://bugzilla.scilab.org/show_bug.cgi?id=15815): After `polarplot()`, reversing axes or switching `gca().rotation_angles` shifted all angular and radial labels. diff --git a/scilab/modules/ast/ast.vcxproj.filters b/scilab/modules/ast/ast.vcxproj.filters index 3a7d11e..8234f7e 100644 --- a/scilab/modules/ast/ast.vcxproj.filters +++ b/scilab/modules/ast/ast.vcxproj.filters @@ -865,6 +865,9 @@ Header Files\ast + + Header Files\ast + @@ -1572,5 +1575,8 @@ Source Files\analysis + + Source Files\ast + \ No newline at end of file diff --git a/scilab/modules/ast/src/cpp/operations/types_comparison_eq.cpp b/scilab/modules/ast/src/cpp/operations/types_comparison_eq.cpp index 8838cdb..1d0eb51 100644 --- a/scilab/modules/ast/src/cpp/operations/types_comparison_eq.cpp +++ b/scilab/modules/ast/src/cpp/operations/types_comparison_eq.cpp @@ -3671,36 +3671,7 @@ InternalType* compequal_LT_LT(T *_pL, U *_pR) template<> types::InternalType* compequal_M_M(types::Cell* _pL, types::Cell* _pR) { - /* check dimension*/ - if (_pL->getDims() != _pR->getDims()) - { - return new Bool(false); - } - - int* piDimsL = _pL->getDimsArray(); - int* piDimsR = _pR->getDimsArray(); - - for (int i = 0; i < _pL->getDims(); i++) - { - if (piDimsL[i] != piDimsR[i]) - { - return new Bool(false); - } - } - - if (_pL->getSize() == 0) - { - //{} == {} -> return true - return new Bool(true); - } - - Bool *pB = new Bool(_pL->getDims(), piDimsL); - for (int i = 0; i < _pL->getSize(); i++) - { - pB->set(i, *_pL->get(i) == *_pR->get(i)); - } - - return pB; + return new Bool(*_pL == *_pR); } template<> diff --git a/scilab/modules/ast/src/cpp/types/cell.cpp b/scilab/modules/ast/src/cpp/types/cell.cpp index 1ee2d04..fa8d06b 100644 --- a/scilab/modules/ast/src/cpp/types/cell.cpp +++ b/scilab/modules/ast/src/cpp/types/cell.cpp @@ -441,7 +441,7 @@ bool Cell::operator==(const InternalType& it) for (int i = 0 ; i < getSize() ; i++) { - if (get(i) != pC->get(i)) + if (*get(i) != *pC->get(i)) { return false; } diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_15811.tst b/scilab/modules/ast/tests/nonreg_tests/bug_15811.tst new file mode 100644 index 0000000..7fb070d --- /dev/null +++ b/scilab/modules/ast/tests/nonreg_tests/bug_15811.tst @@ -0,0 +1,29 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2018 - ESI - Antoine ELIAS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// <-- NO CHECK REF --> +// +// <-- Non-regression test for bug 15811 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/15811 +// +// <-- Short Description --> +// comparison of containers with cell failed. + +m = mlist(["m" "c"], {1}); +save(TMPDIR + "/tmp.sod", "m"); +oldm = m; +clear m; +load(TMPDIR + "/tmp.sod"); +assert_checkequal(m, oldm); + +a = {1 + 1}; +b = {3 - 1}; +assert_checkequal(a, b); +