* [#16263](http://bugzilla.scilab.org/show_bug.cgi?id=16263): Polynomial insertion was broken for complex case.
* [#16264](http://bugzilla.scilab.org/show_bug.cgi?id=16264): After empty for loop iterator was left uninitialized.
* [#16265](http://bugzilla.scilab.org/show_bug.cgi?id=16265): The translated pages of the `warning` documentation were not up-to-date.
+* [#16269](http://bugzilla.scilab.org/show_bug.cgi?id=16269): Scalar structures were poorly displayed.
* [#16271](http://bugzilla.scilab.org/show_bug.cgi?id=16271): `loadmatfile()` was never able to automatically detect the input data format.
* [#16272](http://bugzilla.scilab.org/show_bug.cgi?id=16272): `spzeros(0,n)` and `spzeros(n,0)` were different from `sparse(0,0)`.
* [#16273](http://bugzilla.scilab.org/show_bug.cgi?id=16273): `calendar()` had no formated display mode.
+++ /dev/null
-//
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2011 - DIGITEO - Antoine ELIAS
-//
-// Copyright (C) 2012 - 2016 - Scilab Enterprises
-//
-// 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.
-// This file was originally licensed under the terms of the CeCILL v2.1,
-// and continues to be available under such terms.
-// For more information, see the COPYING file which you should have received
-// along with this program.
-//
-//
-// <-- CLI SHELL MODE -->
-//function struct
-firstname = "firstname";
-firstname_new = "firstname_new";
-lastname = "lastname";
-lastname_new = "lastname_new";
-email = "email";
-email_new = "email_new";
-phone_new = "phone_new";
-// create a one dimensional struct
-st = struct("firstname", firstname, "lastname", lastname, "email", email);
-assert_checkequal(st.firstname, firstname);
-assert_checkequal(st.lastname, lastname);
-assert_checkequal(st.email, email);
-//change some values
-st.firstname = firstname_new;
-st.lastname = lastname_new;
-st.email = email_new;
-// add a phone field
-st.phone = phone_new;
-assert_checkequal(st.firstname, firstname_new);
-assert_checkequal(st.lastname, lastname_new);
-assert_checkequal(st.email, email_new);
-assert_checkequal(st.phone, phone_new);
-clear st;
-//create multi-dimentional struct (4x3x2)
-n1 = 4;
-n2 = 3;
-n3 = 2;
-firstnames{n1,n2,n3} = [];
-lastnames{n1,n2,n3} = [];
-emails{n1,n2,n3} = [];
-for i = 1:(n1*n2*n3)
- sz = string(i);
- firstnames{i} = "firstname_" + sz;
- lastnames{i} = "lastname_" + sz;
- emails{i} = "email_" + sz;
-end
-st = struct("firstname", firstnames, "lastname", lastnames, "email", emails);
-for i = 1:24
- if st(i).firstname <> firstnames{i} then pause end
- if st(i).lastname <> lastnames{i} then pause end
- if st(i).email <> emails{i} then pause end
-end
-clear firstnames
-clear lastnames
-clear emails
-clear st;
-//creating one dimensional structure by insertion
-firstname = "firstname";
-lastname = "lastname";
-email = "email";
-st.firstname = firstname;
-st.lastname = lastname;
-st.email = email;
-assert_checkequal(st.firstname, firstname);
-assert_checkequal(st.lastname, lastname);
-assert_checkequal(st.email, email);
-clear st;
-//create multi dimentional struct by insertion
-n1 = 4;
-n2 = 3;
-n3 = 2;
-firstnames(n1,n2,n3) = "";
-lastnames(n1,n2,n3) = "";
-emails(n1,n2,n3) = "";
-for i = 1:(n1*n2*n3)
- sz = string(i);
- firstnames(i) = "firstname_" + sz;
- lastnames(i) = "lastname_" + sz;
- emails(i) = "email_" + sz;
-end
-//set dimension to 4x3x2
-st(4,3,2).firstname = firstnames($);
-st(4,3,2).lastname = lastnames($);
-//fill struct as vector
-for i = 1:(n1*n2*n3)
- st(i).firstname = firstnames(i);
- st(i).lastname = lastnames(i);
- st(i).email = emails(i);
-end
-//check data on each dimension
-for i = 1:n1
- for j = i:n2
- for k = 1:n3
- assert_checkequal(st(i,j,k).firstname, firstnames(i,j,k));
- assert_checkequal(st(i,j,k).lastname, lastnames(i,j,k));
- assert_checkequal(st(i,j,k).email, emails(i,j,k));
- end
- end
-end
-clear firstnames
-clear lastnames
-clear emails
-clear st;
-//fields of an empty struct
-fields = getfield(1,struct());
-assert_checkequal(fields(1), "st");
-assert_checkequal(fields(2), "dims");
+++ /dev/null
-//
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2011 - DIGITEO - Antoine ELIAS
-//
-// Copyright (C) 2012 - 2016 - Scilab Enterprises
-//
-// 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.
-// This file was originally licensed under the terms of the CeCILL v2.1,
-// and continues to be available under such terms.
-// For more information, see the COPYING file which you should have received
-// along with this program.
-//
-//
-
-// <-- CLI SHELL MODE -->
-
-//function struct
-
-firstname = "firstname";
-firstname_new = "firstname_new";
-lastname = "lastname";
-lastname_new = "lastname_new";
-email = "email";
-email_new = "email_new";
-phone_new = "phone_new";
-
-// create a one dimensional struct
-st = struct("firstname", firstname, "lastname", lastname, "email", email);
-
-assert_checkequal(st.firstname, firstname);
-assert_checkequal(st.lastname, lastname);
-assert_checkequal(st.email, email);
-
-//change some values
-st.firstname = firstname_new;
-st.lastname = lastname_new;
-st.email = email_new;
-
-// add a phone field
-st.phone = phone_new;
-
-assert_checkequal(st.firstname, firstname_new);
-assert_checkequal(st.lastname, lastname_new);
-assert_checkequal(st.email, email_new);
-assert_checkequal(st.phone, phone_new);
-clear st;
-
-//create multi-dimentional struct (4x3x2)
-n1 = 4;
-n2 = 3;
-n3 = 2;
-
-firstnames{n1,n2,n3} = [];
-lastnames{n1,n2,n3} = [];
-emails{n1,n2,n3} = [];
-
-
-for i = 1:(n1*n2*n3)
- sz = string(i);
- firstnames{i} = "firstname_" + sz;
- lastnames{i} = "lastname_" + sz;
- emails{i} = "email_" + sz;
-end
-
-st = struct("firstname", firstnames, "lastname", lastnames, "email", emails);
-
-for i = 1:24
- if st(i).firstname <> firstnames{i} then pause end
- if st(i).lastname <> lastnames{i} then pause end
- if st(i).email <> emails{i} then pause end
-end
-clear firstnames
-clear lastnames
-clear emails
-clear st;
-
-//creating one dimensional structure by insertion
-firstname = "firstname";
-lastname = "lastname";
-email = "email";
-
-st.firstname = firstname;
-st.lastname = lastname;
-st.email = email;
-
-assert_checkequal(st.firstname, firstname);
-assert_checkequal(st.lastname, lastname);
-assert_checkequal(st.email, email);
-clear st;
-
-//create multi dimentional struct by insertion
-n1 = 4;
-n2 = 3;
-n3 = 2;
-
-firstnames(n1,n2,n3) = "";
-lastnames(n1,n2,n3) = "";
-emails(n1,n2,n3) = "";
-
-
-for i = 1:(n1*n2*n3)
- sz = string(i);
- firstnames(i) = "firstname_" + sz;
- lastnames(i) = "lastname_" + sz;
- emails(i) = "email_" + sz;
-end
-
-//set dimension to 4x3x2
-st(4,3,2).firstname = firstnames($);
-st(4,3,2).lastname = lastnames($);
-
-//fill struct as vector
-for i = 1:(n1*n2*n3)
- st(i).firstname = firstnames(i);
- st(i).lastname = lastnames(i);
- st(i).email = emails(i);
-end
-
-//check data on each dimension
-for i = 1:n1
- for j = i:n2
- for k = 1:n3
- assert_checkequal(st(i,j,k).firstname, firstnames(i,j,k));
- assert_checkequal(st(i,j,k).lastname, lastnames(i,j,k));
- assert_checkequal(st(i,j,k).email, emails(i,j,k));
- end
- end
-end
-clear firstnames
-clear lastnames
-clear emails
-clear st;
-
-//fields of an empty struct
-fields = getfield(1,struct());
-assert_checkequal(fields(1), "st");
-assert_checkequal(fields(2), "dims");
-
-
<?xml version="1.0" encoding="utf-8"?>
<general title="_(General)">
<body>
- <environment fpe="2" printing-format="v" width="10" recursion-limit="1000">
+ <environment fpe="2" printing-format="v" width="10" recursion-limit="1000" container_disp_max_depth="2">
<fpe code="0" floating-point-exception="_(Produces an error)"/>
<fpe code="1" floating-point-exception="_(Produces a warning)"/>
<fpe code="2" floating-point-exception="_(Produces Inf or NaN)"/>
<action key="" description="_(Preferences)" name="console-prefs"/>
<action key="" description="_(Show/Hide toolbar)" name="console-sh-toolbar"/>
<action key="" description="_(Clear history)" name="console-clear-history"/>
- <action key="" description="_(Resume)" name="console-resume"/>
+ <action key="" description="_(Resume)" name="console-resume"/>
<action key="" description="_(Abort)" name="console-abort"/>
<action key="" description="_(Interrupt)" name="console-interrupt"/>
<action key="" description="_(Launch SciNotes)" name="console-scinotes"/>
<xsl:call-template name="context"/>
</actionPerformed>
</NumericalSpinner>
+ <Label gridx="1" gridy="5" weightx="0" text="_(Containers display depth: )"/>
+ <NumericalSpinner gridx="3" gridy="5"
+ weightx="0"
+ min-value="0"
+ max-value="10"
+ increment="1"
+ length="2"
+ listener="ActionListener"
+ value="{@container_disp_max_depth}">
+ <actionPerformed choose="container_disp_max_depth">
+ <xsl:call-template name="context"/>
+ </actionPerformed>
+ </NumericalSpinner>
</Grid>
</Title>
</xsl:template>
-
+
<xsl:template match="languages">
<xsl:if test="$OS='Windows'">
<VSpace height="10"/>
</Title>
</xsl:if>
</xsl:template>
-
+
<xsl:template match="java-heap-memory" mode="tooltip"> and java heap size.</xsl:template>
<xsl:template match="java-heap-memory">
<VSpace height="10"/>
<xsl:call-template name="context"/>
</actionPerformed>
</Radiobutton>
-
+
<Radiobutton value="{@use}" expected-value="previous" listener="ActionListener" text="_(Use previous working directory)" gridx="1" gridy="2" fill="none" weightx="0" anchor="west">
<actionPerformed choose="use">
<xsl:call-template name="context"/>
</actionPerformed>
</Radiobutton>
-
+
<Radiobutton value="{@use}" expected-value="default" listener="ActionListener" text="_(Use default directory)" gridx="1" gridy="3" fill="none" weightx="0" anchor="west">
<actionPerformed choose="use">
<xsl:call-template name="context"/>
</actionPerformed>
</Radiobutton>
-
+
<FileSelector gridx="2" gridy="3" weightx="1" anchor="above_baseline"
listener="EntryListener"
href="{@default}"
</Grid>
</Title>
</xsl:template>
-
+
<xsl:template match="tools">
<Title text="_(Confirmation dialogs)">
<Grid>
</Grid>
</Title>
</xsl:template>
-
+
<xsl:template match="layouts">
<xsl:variable name="id" select="@id"/>
<Title text="_(Desktop Layout)">
</Grid>
</Title>
</xsl:template>
-
+
<xsl:template match="actions">
<xsl:variable name="name" select="@name"/>
<xsl:variable name="current-item" select="action-folder[@name=$name]/action[number(@item)]"/>
s.num = null();
s.pol = null();
disp(s)
-1x1 struct array with no fields.
+ 1x1 struct with no field
+++ /dev/null
-// =============================================================================
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2010 - DIGITEO - Sylvestre LEDRU
-//
-// This file is distributed under the same license as the Scilab package.
-// =============================================================================
-// <-- ENGLISH IMPOSED -->
-// <-- CLI SHELL MODE -->
-// unit tests for structs
-// =============================================================================
-date_st=struct('jour',25,'mois','DEC','annee',2006);
-if date_st.jour <> 25 then bugmes();quit;end
-if date_st.mois <> 'DEC' then bugmes();quit;end
-if date_st.annee <> 2006 then bugmes();quit;end
-date_st.jour=19;
-if date_st.jour <> 19 then bugmes();quit;end
-date_st.mois='AOU';
-if date_st.mois <> 'AOU' then bugmes();quit;end
-date_st.annee=1973;
-if date_st.annee <> 1973 then bugmes();quit;end
-date_st.semaine=32;
-if date_st.semaine <> 32 then bugmes();quit;end
-// Example from bug #7244
-clear;
-foo(1) = 1;
-foo(2) = 2;
-foo(3) = 3;
-foo = foo([1 3]);
-foo(3) = 2;
-if [1; 3; 2] <> foo then bugmes();quit;end
-clear;
-foo(1) = 1;
-foo(2) = 2;
-foo(3) = 3;
-foo = foo([%T %F %T]);
-foo(3) = 2;
-if or([1; 3; 2] <> foo) then bugmes();quit;end
-clear;
-foo(1).bar = 1;
-foo(2).bar = 2;
-foo(3).bar = 3;
-foo = foo([1 3]);
-foo(3).bar = 2;
-if foo(1).bar <> 1 then bugmes();quit;end
-if foo(2).bar <> 3 then bugmes();quit;end
-if foo(3).bar <> 2 then bugmes();quit;end
-out.a=1;
-out.b=2;
-if size(out,'*') <> 1 then bugmes();quit;end
-out(2,3).b=2;
-if or(size(out) <> [2 3]) then bugmes();quit;end
-s=struct("txt","Hello","num",%pi,"pol",%z^2+1);
-if s.pol <> %z^2+1 then bugmes();quit;end
-if s.txt <> "Hello" then bugmes();quit;end
-s.txt=null();s.num=null();s.pol=null();
-if isfield( s , "txt" ) then bugmes();quit;end
-if isfield( s , "num" ) then bugmes();quit;end
-if isfield( s , "pol" ) then bugmes();quit;end
-if or(isfield( s , ["pol", "num", "txt"] )) then bugmes();quit;end
-if or(size(s) <> [1 1]) then bugmes();quit;end
-z.y = 42;
-y.o = z;
-y.d.e = z;
-y.f.r.h = z;
-y.i.j.k.l = z;
-z.m = y;
-z.m.o.y = z;
-if z.m.o.y.m.i.j.k.l.y <> 42 then bugmes();quit;end
-if ~isfield(z.m.o.y.m.i.j.k.l,"y") then bugmes();quit;end
-z.z = 21;
-z.b = z;
-z.b.c = z;
-if z.z <> 21 then bugmes();quit;end
-if z.b.c.z <> 21 then bugmes();quit;end
-if ~isfield(z,"b") then bugmes();quit;end
-if ~isfield(z.b,"c") then bugmes();quit;end
-z(1).x.x = 1;
-if execstr('z(42).x','errcatch')<>999 then bugmes();quit;end
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2010 - DIGITEO - Sylvestre LEDRU
+// Copyright (C) 2011 - DIGITEO - Antoine ELIAS
//
// This file is distributed under the same license as the Scilab package.
// =============================================================================
// <-- ENGLISH IMPOSED -->
// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
// unit tests for structs
// =============================================================================
z(1).x.x = 1;
if execstr('z(42).x','errcatch')<>999 then pause,end
+
+// -----------------------------------------------------------------
+
+//function struct
+
+firstname = "firstname";
+firstname_new = "firstname_new";
+lastname = "lastname";
+lastname_new = "lastname_new";
+email = "email";
+email_new = "email_new";
+phone_new = "phone_new";
+
+// create a one dimensional struct
+st = struct("firstname", firstname, "lastname", lastname, "email", email);
+
+assert_checkequal(st.firstname, firstname);
+assert_checkequal(st.lastname, lastname);
+assert_checkequal(st.email, email);
+
+//change some values
+st.firstname = firstname_new;
+st.lastname = lastname_new;
+st.email = email_new;
+
+// add a phone field
+st.phone = phone_new;
+
+assert_checkequal(st.firstname, firstname_new);
+assert_checkequal(st.lastname, lastname_new);
+assert_checkequal(st.email, email_new);
+assert_checkequal(st.phone, phone_new);
+clear st;
+
+//create multi-dimentional struct (4x3x2)
+n1 = 4;
+n2 = 3;
+n3 = 2;
+
+firstnames{n1,n2,n3} = [];
+lastnames{n1,n2,n3} = [];
+emails{n1,n2,n3} = [];
+
+
+for i = 1:(n1*n2*n3)
+ sz = string(i);
+ firstnames{i} = "firstname_" + sz;
+ lastnames{i} = "lastname_" + sz;
+ emails{i} = "email_" + sz;
+end
+
+st = struct("firstname", firstnames, "lastname", lastnames, "email", emails);
+
+for i = 1:24
+ if st(i).firstname <> firstnames{i} then pause end
+ if st(i).lastname <> lastnames{i} then pause end
+ if st(i).email <> emails{i} then pause end
+end
+clear firstnames lastnames emails st
+
+//creating one dimensional structure by insertion
+firstname = "firstname";
+lastname = "lastname";
+email = "email";
+
+st.firstname = firstname;
+st.lastname = lastname;
+st.email = email;
+
+assert_checkequal(st.firstname, firstname);
+assert_checkequal(st.lastname, lastname);
+assert_checkequal(st.email, email);
+clear st;
+
+//create multi dimentional struct by insertion
+n1 = 4;
+n2 = 3;
+n3 = 2;
+
+firstnames(n1,n2,n3) = "";
+lastnames(n1,n2,n3) = "";
+emails(n1,n2,n3) = "";
+
+
+for i = 1:(n1*n2*n3)
+ sz = string(i);
+ firstnames(i) = "firstname_" + sz;
+ lastnames(i) = "lastname_" + sz;
+ emails(i) = "email_" + sz;
+end
+
+//set dimension to 4x3x2
+st(4,3,2).firstname = firstnames($);
+st(4,3,2).lastname = lastnames($);
+
+//fill struct as vector
+for i = 1:(n1*n2*n3)
+ st(i).firstname = firstnames(i);
+ st(i).lastname = lastnames(i);
+ st(i).email = emails(i);
+end
+
+//check data on each dimension
+for i = 1:n1
+ for j = i:n2
+ for k = 1:n3
+ assert_checkequal(st(i,j,k).firstname, firstnames(i,j,k));
+ assert_checkequal(st(i,j,k).lastname, lastnames(i,j,k));
+ assert_checkequal(st(i,j,k).email, emails(i,j,k));
+ end
+ end
+end
+clear firstnames lastnames emails st
+
+//fields of an empty struct
+fields = getfield(1,struct());
+assert_checkequal(fields(1), "st");
+assert_checkequal(fields(2), "dims");
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2019, 2020 - Samuel GOUGEON
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// Unitary tests of default display of scalar (nested) structures
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- ENGLISH IMPOSED -->
+oldDepth = xmlGetValues("//general/body/environment","container_disp_max_depth");
+setPreferencesValue("//general/body/environment", ["container_disp_max_depth"; "3"]);
+// ----------------------------------------------------------------
+clear s
+s.f = [%i/%s, %s/(1-%s), 1/(1-%s)^2];
+s.c = {1 3 ; "abc" %z};
+s.ec = {};
+s.b = rand(1,5)<0.5;
+s.iL = $-4:2:$;
+s.fun = linspace;
+s.L = list(rand(2,3),{},(1-%z)^3,,%pi, %t, "abcd");
+s.lib = corelib;
+s.tlist = tlist(["myTlist" "bool" "int" "num" "txt" "list"],..
+ rand(3,4,2)<0.5, int8((rand(3,5)-0.5)*200), ..
+ grand(3,4,"uin",-100,100), ["This" "is" "a" "test"], list(%pi,"number"));
+s.mlist = mlist(["myMlist" "spb" "fun" "pol" "txt"],..
+ sparse(rand(3,4)<0.5), cosd, (1-%z).^(0:4),["Scilab" "6.1"]);
+s.estruct = struct();
+s.withVoid = struct("num",%pi,"v",,"t","text");
+s.struct = struct("a",rand(1,3),"L",list(%e,,"ABC"),"c",{{"GHI",1234}});
+s
+ s =
+ f: [1x3 complex rational] of s
+ c: [2x2 cell]
+ ec = {}
+ b = [%t,%f,%t,%t,%f]
+ iL = -4+$:2:$
+ fun: fptr
+ L: list:
+ (1) : [2x3 constant]
+ (2) = {}
+ (3) = 1-3*%z+3*%z^2-%z^3
+ (4) = (void)
+ (5) = 3.1415927
+ (6) = %t
+ (7) = "abcd"
+ lib: corelib library with 16 functions @ SCI\modules\core\macros\
+ tlist: [myTlist] tlist with fields:
+ bool: [3x4x2 boolean]
+ int: [3x5 int8]
+ num: [3x4 constant]
+ txt = ["This","is","a","test"]
+ list: list:
+ (1) = 3.1415927
+ (2) = "number"
+ mlist: [myMlist] mlist with fields:
+ spb: [3x4 boolean sparse]
+ fun: cosd(x) => [x] (19 lines)
+ pol = [1,1-%z,1-2*%z+%z^2,1-3*%z+3*%z^2-%z^3,1-4*%z+6*%z^2-4*%z^3+%z^4]
+ txt = ["Scilab","6.1"]
+ estruct: [0x0 struct] with no field
+ withVoid: struct with fields:
+ num = 3.1415927
+ v = (void)
+ t = "text"
+ struct: struct with fields:
+ a = [0.9488184,0.3435337,0.3760119]
+ L: list:
+ (1) = 2.7182818
+ (2) = (void)
+ (3) = "ABC"
+ c: [1x2 cell]
+// ----------------------------------------------------------------
+clear s
+s.root = "Hello 0";
+s.L = list(2,"bonjour", list(%i, list(%z,3)));
+s.t.a = "Level 1";
+s.t.r = %pi;
+s.t.tl = tlist(["myTlist" "a" "b" "c"], rand(2,3), %t, list("abc", 123));
+s.t.b.a = "Level 2";
+s.t.b.r = %e;
+s.t.L2 = list("Hello", list(1-%z+%z^2, list(-4,%t)));
+s.t.b.s.a = "Level 3";
+s.t.b.s.p = (1-%z)^3;
+setPreferencesValue("//general/body/environment", ["container_disp_max_depth";"0"]);
+s
+ s =
+ root = "Hello 0"
+ L: list with 3 elements.
+ t: struct with fields:
+ [a, r, tl, b, L2]
+setPreferencesValue("//general/body/environment", ["container_disp_max_depth";"1"]);
+s
+ s =
+ root = "Hello 0"
+ L: list:
+ (1) = 2
+ (2) = "bonjour"
+ (3) : list with 2 elements.
+ t: struct with fields:
+ a = "Level 1"
+ r = 3.1415927
+ tl: [myTlist] tlist with fields:
+ [a, b, c]
+ b: struct with fields:
+ [a, r, s]
+ L2: list with 2 elements.
+setPreferencesValue("//general/body/environment", ["container_disp_max_depth";"2"]);
+s
+ s =
+ root = "Hello 0"
+ L: list:
+ (1) = 2
+ (2) = "bonjour"
+ (3) : list:
+ (1) = %i
+ (2) : list with 2 elements.
+ t: struct with fields:
+ a = "Level 1"
+ r = 3.1415927
+ tl: [myTlist] tlist with fields:
+ a: [2x3 constant]
+ b = %t
+ c: list with 2 elements.
+ b: struct with fields:
+ a = "Level 2"
+ r = 2.7182818
+ s: struct with fields:
+ [a, p]
+ L2: list:
+ (1) = "Hello"
+ (2) : list with 2 elements.
+setPreferencesValue("//general/body/environment", ["container_disp_max_depth";"3"]);
+s
+ s =
+ root = "Hello 0"
+ L: list:
+ (1) = 2
+ (2) = "bonjour"
+ (3) : list:
+ (1) = %i
+ (2) : list:
+ (1) = %z
+ (2) = 3
+ t: struct with fields:
+ a = "Level 1"
+ r = 3.1415927
+ tl: [myTlist] tlist with fields:
+ a: [2x3 constant]
+ b = %t
+ c: list:
+ (1) = "abc"
+ (2) = 123
+ b: struct with fields:
+ a = "Level 2"
+ r = 2.7182818
+ s: struct with fields:
+ a = "Level 3"
+ p = 1-3*%z+3*%z^2-%z^3
+ L2: list:
+ (1) = "Hello"
+ (2) : list:
+ (1) = 1-%z+%z^2
+ (2) : list with 2 elements.
+// ----------------------------------------------------------------
+setPreferencesValue("//general/body/environment", ["container_disp_max_depth"; oldDepth]);
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2019, 2020 - Samuel GOUGEON
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// Unitary tests of default display of scalar (nested) structures
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+// <-- ENGLISH IMPOSED -->
+
+oldDepth = xmlGetValues("//general/body/environment","container_disp_max_depth");
+setPreferencesValue("//general/body/environment", ["container_disp_max_depth"; "3"]);
+
+// ----------------------------------------------------------------
+clear s
+s.f = [%i/%s, %s/(1-%s), 1/(1-%s)^2];
+s.c = {1 3 ; "abc" %z};
+s.ec = {};
+s.b = rand(1,5)<0.5;
+s.iL = $-4:2:$;
+s.fun = linspace;
+s.L = list(rand(2,3),{},(1-%z)^3,,%pi, %t, "abcd");
+s.lib = corelib;
+s.tlist = tlist(["myTlist" "bool" "int" "num" "txt" "list"],..
+ rand(3,4,2)<0.5, int8((rand(3,5)-0.5)*200), ..
+ grand(3,4,"uin",-100,100), ["This" "is" "a" "test"], list(%pi,"number"));
+s.mlist = mlist(["myMlist" "spb" "fun" "pol" "txt"],..
+ sparse(rand(3,4)<0.5), cosd, (1-%z).^(0:4),["Scilab" "6.1"]);
+s.estruct = struct();
+s.withVoid = struct("num",%pi,"v",,"t","text");
+s.struct = struct("a",rand(1,3),"L",list(%e,,"ABC"),"c",{{"GHI",1234}});
+s
+
+// ----------------------------------------------------------------
+clear s
+s.root = "Hello 0";
+s.L = list(2,"bonjour", list(%i, list(%z,3)));
+s.t.a = "Level 1";
+s.t.r = %pi;
+s.t.tl = tlist(["myTlist" "a" "b" "c"], rand(2,3), %t, list("abc", 123));
+s.t.b.a = "Level 2";
+s.t.b.r = %e;
+s.t.L2 = list("Hello", list(1-%z+%z^2, list(-4,%t)));
+s.t.b.s.a = "Level 3";
+s.t.b.s.p = (1-%z)^3;
+
+setPreferencesValue("//general/body/environment", ["container_disp_max_depth";"0"]);
+s
+setPreferencesValue("//general/body/environment", ["container_disp_max_depth";"1"]);
+s
+setPreferencesValue("//general/body/environment", ["container_disp_max_depth";"2"]);
+s
+setPreferencesValue("//general/body/environment", ["container_disp_max_depth";"3"]);
+s
+// ----------------------------------------------------------------
+
+setPreferencesValue("//general/body/environment", ["container_disp_max_depth"; oldDepth]);
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+8// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) INRIA
// Copyright (C) 2010 - DIGITEO - Vincent COUVERT <vincent.couvert@scilab.org>
// Copyright (C) 2012 - 2016 - Scilab Enterprises
// Copyright (C) 2018 - Stéphane MOTTELET
+// Copyright (C) 2019-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.
// along with this program.
function %st_p(s)
+ recursive = 0
+ tmp = xmlGetValues("//general/body/environment","container_disp_max_depth")
+ maxDisplayDepth = evstr(tmp)
+ consoleWidth = lines()(1)
+ //st_p_compacity = ""; // "" vspacing of blocks
+ st_p_compacity = []; // for compact display
+ t = %st_p_inc(s, "st")
+ mprintf(" %s\n", t);
+endfunction
+
+// -------------------------------------------------------------------
- //matlab-like struct display
+function t = %st_p_inc(s, parentType)
+ // Can be called with s = struct | Tlist | list
ll = lines()
t = []
- multi = size(s,"*")
-
- // No fields
- if isempty(fieldnames(s)) then
- t = strcat(string(size(s)), "x") + " struct array with no fields.";
- mprintf("%s", t);
- return
+ indentFields = " "
+ if parentType=="list" then
+ eq = "= "
+ else
+ eq = " = "
end
- // 0x0 struct with fields
- if multi == 0 then
- t = "0x0 struct array with fields:"
- for field = fieldnames(s)'
- t = [t; " "+field]
+ if typeof(s)=="st"
+ // No fields
+ if isempty(fieldnames(s)) then
+ t = msprintf(_("%s struct with no field"), ..
+ strcat(msprintf("%d\n",size(s)'), "x"));
+ return
+ end
+
+ multi = size(s,"*")
+
+ // 0x0 struct with fields
+ if multi == 0 then
+ t = _("0x0 struct with fields:")
+ for field = fieldnames(s)'
+ t = [t ; " "+field]
+ end
+ return
+ end
+
+ // axb struct where a<>0 & b<>0
+ if multi > 1 | recursive > maxDisplayDepth then
+ if ~recursive
+ t = msprintf(_("%s struct with fields:"), ..
+ strcat(msprintf("%d\n", size(s)'), "x"));
+ end
+ tmp = sci2exp(fieldnames(s)', consoleWidth-10)
+ tmp = strsubst(strsubst(tmp, """""", """"), ",", ", ")
+ t = [t ; tmp]
+ return
end
- mprintf("%s", t);
- return
end
- // axb struct where a<>0 & b<>0
- if multi > 1 then
- t = strcat(string(size(s)), "x") + " struct array with fields:";
+ recursive0 = recursive
+ if type(s)==15 then
+ Fields = 1:length(s)
+ else
+ Fields = fieldnames(s)'
end
- for field = fieldnames(s)'
+ // MAIN LOOP
+ // ---------
+ for field = Fields
+ sep = ": " // field_name<sep> ...
+ if type(s)==15 then
+ fieldn = msprintf("(%d) ", field)
+ else
+ fieldn = field
+ end
+ clear value
value = s(field)
- tp = typeof(value)
- if tp == "st" then
- str = "[" + strcat(string(size(value)), "x") + " struct" + "]";
+ if isdef("value","l") then
+ tp = typeof(value)
+ else
+ tp = "void"
+ end
+
+ if tp=="void" then
+ str = _("(void)")
+ sep = eq
+
+ elseif tp == "st" then
+ recursive = recursive + 1
+ str = %st_p_inc(value, "st")
+
+ elseif tp == "implicitlist"
+ str = sci2exp(value)
+ sep = eq
+
+ elseif tp == "function"
+ [out,inp,?] = string(value)
+ if inp==[], inp = "", end
+ if out==[], out = "", end
+ p = macr2tree(value)
+ str = p.name+"("+strcat(inp,",")+") => ["+strcat(out,",")+"] ";
+ str = str + msprintf(_("(%d lines)"),p.nblines)
+ txt = fieldn + ": " + str
+
+ elseif tp == "rational"
+ str = strcat(msprintf("%d\n", size(value)'), "x")
+ tmp = _("rational")
+ if ~isreal(value,0)
+ tmp = _("complex rational")
+ end
+ str = msprintf(_("[%s %s] of %s"), str, tmp, varn(value));
+
+ elseif tp == "ce"
+ if length(value)==0 then
+ str = "{}"
+ txt = fieldn + eq + str
+ else
+ str = strcat(msprintf("%d\n", size(value)'), "x")
+ str = msprintf("[%s %s]", str, _("cell"));
+ txt = fieldn + ": " + str
+ end
+
+ elseif type(value)==15
+ if length(value)==0 then
+ str = _(" empty list()")
+ else
+ if recursive < maxDisplayDepth
+ recursive = recursive + 1
+ tmp = %st_p_inc(value, "list")
+ str = ["list:" ; tmp]
+ else
+ str = msprintf("list with %d elements.\n", length(value))
+ end
+ end
+
+ elseif or(type(value)==[16 17])
+ // Tlists or Mlists
+ Tfields = fieldnames(value);
+ sz = []
+ try
+ sz = size(value)
+ end
+ signature = tp
+ if length(sz) > 1
+ signature = strcat(msprintf("%d\n", sz'), "x") + " " + tp
+ end
+ listType = "tlist"
+ if type(value)==17
+ listType = "mlist"
+ end
+ if Tfields==[]
+ str = msprintf(_("[%s] %s without field."), signature, listType);
+ else
+ str = msprintf(_("[%s] %s with fields:"), signature, listType);
+ if recursive < maxDisplayDepth
+ recursive = recursive + 1
+ tmp = %st_p_inc(value, "mtlist")
+ str = [str ; tmp]
+ else
+ tmp = sci2exp(Tfields', consoleWidth-10)
+ tmp = strsubst(strsubst(tmp, """", ""), ",", ", ")
+ str = [str ; tmp]
+ end
+ end
+
+ elseif type(value)==14 // Library
+ tmp = string(value)
+ p = tmp(1)
+ libname = xmlGetValues("/scilablib","name",p + "lib")
+ str = msprintf("%s library with %d functions @ %s", ..
+ libname, size(tmp,1)-1, p)
+
elseif type(value)> 10 then
str = tp
+
else
sz = size(value)
- // If number of elements in value is greater than ll(1) (current page width)
- // then we do not call sci2exp
- // because the returned value will be ignored at line 64: size(str,"*")==1
- // Note that ll(1)/2 elements could be the max because of colon, semi-colon and brackets added between elements by sci2exp
- if sz(1) == 1 & type(value) <> 9 & prod(sz) < ll(1) then // This line can avoid some memory issues when field contains a big matrix
+ // If number of elements in value is greater than ll(1) (current
+ // page width) then we do not call sci2exp because the returned
+ // value will be ignored at line 68: size(str,"*")==1
+ // Note that ll(1)/2 elements could be the max because of colon,
+ // semi-colon and brackets added between elements by sci2exp
+ if sz(1) <= 1 & type(value) <> 9 & prod(sz) < ll(1) then
+ // This line can avoid some memory issues when
+ // field contains a big matrix
str = sci2exp(value, ll(1))
+ sep = eq
else
- str = "[" + strcat(string(size(value)), "x") + " " + tp + "]"
+ str = "[" + strcat(msprintf("%d\n",sz'), "x") + " " + tp + "]"
end
end
- txt = " " + field
- if multi <= 1 then
- if size(str,"*") == 1 then
- txt = txt + ": " + str
+ // ---------------------------
+ if size(str,"*") == 1 & ..
+ and(tp <> ["st" "function" "rational" "ce"])
+ txt = fieldn + sep + str
+
+ elseif and(tp <> ["function" "ce"])
+ if recursive
+ txt0 = indentFields // indentation for fields list
+ //txt0 = field + "." // to display the chain of parent fields
else
- tp = typeof(value)
- txt = txt + ": " + "[" + strcat(string(size(value)), "x") + " " + tp + "]"
+ txt0 = fieldn
end
- end
- t = [t; txt]
- end
+ if tp == "st"
+ txt = fieldn + ": "
+ if size(value,"*")==0
+ txt = txt + _("[0x0 struct] with no field")
+ else
+ sv = size(value)'
+ if prod(sv)==1 then
+ txt = txt + "struct with fields:"
+ else
+ txt = txt + msprintf(_("[%s struct] with fields:"), ..
+ strcat(msprintf("%d\n", sv), "x"));
+ end
+ txt = [txt ; txt0 + str]
+ if stripblanks(t($)) <> ""
+ txt = [st_p_compacity ; txt]
+ end
+ end
- mprintf("%s\n", t);
+ elseif or(type(value)==[15 16 17])
+ txt = fieldn + ": " + str(1)
+ if size(str,1)>1
+ txt = [txt ; indentFields + str(2:$)]
+ end
+ if stripblanks(t($)) <> ""
+ txt = [st_p_compacity ; txt]
+ end
+ else
+ txt = txt0 + ..
+ ": " + "[" + strcat(msprintf("%d\n",size(value)'), "x") ..
+ + " " + tp + "]"
+ end
+ end
+ t = [t ; txt]
+ recursive = recursive0
+ end
+ // Display a blank line after each field that is a non-empty
+ // struct or tlist:
+ if recursive & stripblanks(t($)) <> ""
+ t = [t ; st_p_compacity]
+ end
endfunction