* [#16553](https://bugzilla.scilab.org/16553): `unique(["" ""])` returned `["" ""]`.
* [#16557](https://bugzilla.scilab.org/16557): `macr2tree` + `tree2code` translated `e={2}` into `"e=1"` and `e={2,"ab"}` into `"e=[2,"ab"]"`.
* [#16559](https://bugzilla.scilab.org/16553): `isempty(A)` was true for sparse matrix of dimension 2^16 or larger.
+* [#16565](https://bugzilla.scilab.org/16565): `edit(user_defined_function)` corrupted the original code.
* [#16567](https://bugzilla.scilab.org/16567): `mfile2sci` did not support Matlab block-comments %{ ..%}.
* [#16571](https://bugzilla.scilab.org/16571): `mfile2sci` had several issues when converting the NOT ~ operator: 1) `~(1-1)` was converted into `~1-1` instead of `~(1-1)` 2) ~ applied to an integer expression yielded an error from `convert2double` 3) `~i` was converted into `~%i` instead of `~abs(%i)`.
* [#16586](https://bugzilla.scilab.org/16586): `mfile2sci`: The `prettyprintoutput` flag badly managed appended comments.
// Copyright (C) 2008 - INRIA - Allan CORNET
// Copyright (C) 2010 - DIGITEO - Allan CORNET
// Copyright (C) 2012 - 2016 - Scilab Enterprises
-// Copyright (C) 2018 - Samuel GOUGEON
+// Copyright (C) 2018 - 2020 - Samuel GOUGEON
//
// This file is hereby licensed under the terms of the GNU GPL v2.0,
// pursuant to article 5.3.4 of the CeCILL v.2.1.
// priority = from library:
fname = pathconvert(path) + macroname + ".sci"
else
- txt = tree2code(tree, %t);
+ // txt = tree2code(tree, %t);
+ // http://bugzilla.scilab.org/16565 : no actual workaround
+ // http://bugzilla.scilab.org/16576 : workaround
+ // http://bugzilla.scilab.org/16595 : no workaround
+ [o,i,txt] = string(object)
+ if size(o,"*")==1
+ o = o + " = "
+ elseif size(o,"*") > 1
+ o = "[" + strcat(o,", ") + "] = "
+ else
+ o = ""
+ end
+ if txt(1)==" ", txt(1)=[], end
+ if txt($)==" ", txt($)=[], end
+ if i<>[], i = strcat(i, ", "), else i = "", end
+ txt = ["function " + o + macroname + "(" + i + ")"
+ " " + txt
+ "endfunction"
+ ];
fname = tmpdir + macroname + ".sci";
mputl(txt, fname);
end
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2020 - Samuel GOUGEON
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+//
+// <-- Non-regression test for bug 16565 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/16565
+//
+// <-- Short Description -->
+// edit(user_defined_function) does not yield reliable code
+
+function a = test(c,d)
+ // http://bugzilla.scilab.org/16565 :
+ y = c{1}
+ // y = c{2} // yields = c{1}
+ // y = c{1,2} // yields = c{1,1}
+ y = c{2,1}
+ y{3} = 4
+ y{2,1} = 3
+ y{1,2} = 3
+ plot
+ // http://bugzilla.scilab.org/16576 :
+ b = gcf().children.axes_reverse(:,2)
+ //
+ while a > 0
+ a = a - 0.1
+ end
+endfunction
+
+try // We just need edit to create the file(). Scinotes can't be opened
+ edit test
+end
+
+File = pathconvert(TMPDIR) + "test.sci";
+t = mgetl(File);
+Ref = [
+ "function a = test(c, d)"
+ " // http://bugzilla.scilab.org/16565 :"
+ " y = c{1}"
+ " // y = c{2} // yields = c{1}"
+ " // y = c{1,2} // yields = c{1,1}"
+ " y = c{2, 1}"
+ " y{3} = 4"
+ " y{2, 1} = 3"
+ " y{1, 2} = 3"
+ " plot"
+ " // http://bugzilla.scilab.org/16576 :"
+ " b = gcf().children.axes_reverse(:, 2)"
+ " //"
+ " while (a > 0) do"
+ " a = a - 0.1"
+ " end"
+ "endfunction"
+ ];
+assert_checkequal(t, Ref);