summaryrefslogtreecommitdiffstats
path: root/scilab/modules/data_structures
diff options
context:
space:
mode:
authorSerge Steer <serge.steer@scilab.org>2010-05-05 15:14:10 +0200
committerPierre MARECHAL <pierre.marechal@scilab.org>2010-05-17 17:57:09 +0200
commitef04d9542457fa640dc1f6cbae352b5cda9d85cf (patch)
tree402ffaae91978431cf8da000675cdd89468a1702 /scilab/modules/data_structures
parentcd6bfae99e7356c848ef08b7ec3dc5d3fc9ae0c4 (diff)
downloadscilab-ef04d9542457fa640dc1f6cbae352b5cda9d85cf.zip
scilab-ef04d9542457fa640dc1f6cbae352b5cda9d85cf.tar.gz
bug 5588 fix
Change-Id: I485e19f2e091384523350bff481db63ffc0c4c2b
Diffstat (limited to 'scilab/modules/data_structures')
-rw-r--r--scilab/modules/data_structures/help/en_US/tlist.xml12
-rw-r--r--scilab/modules/data_structures/help/fr_FR/tlist.xml21
-rw-r--r--scilab/modules/data_structures/src/fortran/followpath.f22
-rw-r--r--scilab/modules/data_structures/src/fortran/insertfield.f2
-rw-r--r--scilab/modules/data_structures/src/fortran/intl_e.f4
-rw-r--r--scilab/modules/data_structures/src/fortran/intl_i.f3
-rw-r--r--scilab/modules/data_structures/src/fortran/udptr.f3
-rw-r--r--scilab/modules/data_structures/tests/nonreg_tests/bug_5588.dia.ref63
-rw-r--r--scilab/modules/data_structures/tests/nonreg_tests/bug_5588.tst75
9 files changed, 179 insertions, 26 deletions
diff --git a/scilab/modules/data_structures/help/en_US/tlist.xml b/scilab/modules/data_structures/help/en_US/tlist.xml
index 30e1199..d54e0ee 100644
--- a/scilab/modules/data_structures/help/en_US/tlist.xml
+++ b/scilab/modules/data_structures/help/en_US/tlist.xml
@@ -61,8 +61,11 @@
61 insertion 61 insertion
62 : <literal>l(i)=a</literal></para> 62 : <literal>l(i)=a</literal></para>
63 <para> 63 <para>
64 deletion 64 deletion : <literal>l(i)=null()</literal> removes the i-th
65 : <literal>l(i)=null()</literal> removes the i-th element of the <literal>tlist l</literal>.</para> 65 element of the <literal>tlist l</literal>. Note that the
66 semantics of <literal>l.x=null()</literal> is undefined, but a
67 definition can be given through the <link
68 linkend="overloading">overloading</link> mechanism.</para>
66 <para> 69 <para>
67 display</para> 70 display</para>
68 <para> 71 <para>
@@ -87,7 +90,7 @@
87 </refsection> 90 </refsection>
88 <refsection> 91 <refsection>
89 <title>Examples</title> 92 <title>Examples</title>
90 <programlisting role="example"><![CDATA[ 93 <programlisting role="example"><![CDATA[
91// tlist creation 94// tlist creation
92t = tlist(["listtype","field1","field2"], [], []); 95t = tlist(["listtype","field1","field2"], [], []);
93t.field1(1) = 10; 96t.field1(1) = 10;
@@ -129,9 +132,6 @@ disp(t)
129 <title>See Also</title> 132 <title>See Also</title>
130 <simplelist type="inline"> 133 <simplelist type="inline">
131 <member> 134 <member>
132 <link linkend="null">null</link>
133 </member>
134 <member>
135 <link linkend="percent">percent</link> 135 <link linkend="percent">percent</link>
136 </member> 136 </member>
137 <member> 137 <member>
diff --git a/scilab/modules/data_structures/help/fr_FR/tlist.xml b/scilab/modules/data_structures/help/fr_FR/tlist.xml
index 905a82e..85e9410 100644
--- a/scilab/modules/data_structures/help/fr_FR/tlist.xml
+++ b/scilab/modules/data_structures/help/fr_FR/tlist.xml
@@ -44,11 +44,11 @@
44 S'il est spécifié, <literal>typ(i)</literal> donne le nom formel de l'élément <literal>i+1</literal> (voir plus bas dans les exemples). 44 S'il est spécifié, <literal>typ(i)</literal> donne le nom formel de l'élément <literal>i+1</literal> (voir plus bas dans les exemples).
45 </para> 45 </para>
46 <para> 46 <para>
47 Les opérations standard sur les listes fonctionnent similairement pour les listes typées (tlist). 47 Les opérations standard sur les listes fonctionnent similairement pour les listes typées (tlist).
48 </para> 48 </para>
49 <para> 49 <para>
50 extraction 50 extraction
51 : <literal>[x,y,z...]=l(v)</literal> ou <literal>v</literal> est un vecteur d'indices; 51 : <literal>[x,y,z...]=l(v)</literal> ou <literal>v</literal> est un vecteur d'indices;
52 <literal>[x,y,z]=l(:)</literal> extrait tous les éléments. 52 <literal>[x,y,z]=l(:)</literal> extrait tous les éléments.
53 </para> 53 </para>
54 <para> 54 <para>
@@ -56,14 +56,19 @@
56 : <literal>l(i)=a</literal> 56 : <literal>l(i)=a</literal>
57 </para> 57 </para>
58 <para> 58 <para>
59 suppression 59 suppression : <literal>l(i)=null()</literal> supprime le i-ème
60 : <literal>l(i)=null()</literal> supprime le i-ème élément de la <literal>tlist l</literal>. 60 élément de la <literal>tlist l</literal>. A noter que la
61 sémantique de <literal>l.x=null()</literal> n'est pas définie,
62 mais qu'il est possible de lui donner un sens par surcharge (voir
63 <link linkend="overloading">overloading</link>).
61 </para> 64 </para>
62 <para> 65 <para>
63 affichage 66 affichage
64 </para> 67 </para>
65 <para> 68 <para>
66 De plus si les composantes <literal>typ(2:n+1)</literal> sont spécifiées, les éléments peuvent être désignés par leur noms formels. 69 De plus si les composantes <literal>typ(2:n+1)</literal> sont
70 spécifiées, les éléments peuvent être désignés par leur noms
71 formels.
67 </para> 72 </para>
68 <para> 73 <para>
69 Voici quelques exemples d'utilisation des liste typées : 74 Voici quelques exemples d'utilisation des liste typées :
@@ -71,7 +76,7 @@
71 <para> 76 <para>
72 Dans Scilab, les systèmes dynamiques linéaires sont définis par une liste typée : 77 Dans Scilab, les systèmes dynamiques linéaires sont définis par une liste typée :
73 le quadruplet <literal>[A,B,C,D]</literal> est représenté par la tlist 78 le quadruplet <literal>[A,B,C,D]</literal> est représenté par la tlist
74 <literal>Sys=tlist(['lss';'A';'B';'C';'D';'X0';'dt'],A,B,C,D,x0,'c')</literal> 79 <literal>Sys=tlist(['lss';'A';'B';'C';'D';'X0';'dt'],A,B,C,D,x0,'c')</literal>
75 et cette tlist spécifique est créée par la fonction <literal>syslin</literal>. 80 et cette tlist spécifique est créée par la fonction <literal>syslin</literal>.
76 </para> 81 </para>
77 <para> 82 <para>
@@ -89,7 +94,7 @@
89 </refsection> 94 </refsection>
90 <refsection> 95 <refsection>
91 <title>Exemples</title> 96 <title>Exemples</title>
92 <programlisting role="example"><![CDATA[ 97 <programlisting role="example"><![CDATA[
93// tlist creation 98// tlist creation
94t = tlist(["listtype","field1","field2"], [], []); 99t = tlist(["listtype","field1","field2"], [], []);
95t.field1(1) = 10; 100t.field1(1) = 10;
diff --git a/scilab/modules/data_structures/src/fortran/followpath.f b/scilab/modules/data_structures/src/fortran/followpath.f
index 8dea9fb..06bad1f 100644
--- a/scilab/modules/data_structures/src/fortran/followpath.f
+++ b/scilab/modules/data_structures/src/fortran/followpath.f
@@ -7,7 +7,7 @@ c you should have received as part of this distribution. The terms
7c are also available at 7c are also available at
8c http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt 8c http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
9 subroutine followpath(indtop,listtop,ilindi,voli,ilp,voll,ind, 9 subroutine followpath(indtop,listtop,ilindi,voli,ilp,voll,ind,
10 $ count,info,lwork) 10 $ count,info,lwork,job)
11c ============================================================= 11c =============================================================
12c given 12c given
13c - a path stored in a "linear" index list ind stored in the 13c - a path stored in a "linear" index list ind stored in the
@@ -35,11 +35,19 @@ c 2 : current index is a matrix index of an mlist
35c 3 : current index is not a single number 35c 3 : current index is not a single number
36c 4 : current index points to a leaf of the L list 36c 4 : current index points to a leaf of the L list
37c 5 : end of index list reached 37c 5 : end of index list reached
38c 6 : current index is 0 or greater than current sublist # of fields 38c 6 : current index is 0 or greater than current sublist # of
39c fields
40c job
41c if job is true and end of index list is reached, the last index is
42c a name and the parent of the deapest object is a tlist or an mlist
43c the procedure returns the pointer and path of the parent instead
44c of the object itself (null insertion).
45
39c ============================================================= 46c =============================================================
40c 47c
41 include 'stack.h' 48 include 'stack.h'
42c 49c
50 logical job
43 integer indtop,listtop,ind(*) 51 integer indtop,listtop,ind(*)
44 integer typi,count,oldcount,voll,voli 52 integer typi,count,oldcount,voll,voli
45 53
@@ -63,16 +71,12 @@ c
63 endif 71 endif
64c 72c
65 illist=iadr(lstk(listtop)) 73 illist=iadr(lstk(listtop))
66c if(istk(illist).lt.0) illist=iadr(istk(illist+1))
67c
68 if(istk(ilind).ne.15) then 74 if(istk(ilind).ne.15) then
69c . special case if ind is not a list 75c . special case if ind is not a list
70 nlist=1 76 nlist=1
71 count=1 77 count=1
72 ilindi=ilind 78 ilindi=ilind
73 ilindir=ilindi 79 ilindir=ilindi
74c voli=lstk(itop+1)-lstk(itop)
75
76 illistir=illist 80 illistir=illist
77 if(istk(illist).lt.0) illist=iadr(istk(illist+1)) 81 if(istk(illist).lt.0) illist=iadr(istk(illist+1))
78 illisti=illist 82 illisti=illist
@@ -80,6 +84,7 @@ c voli=lstk(itop+1)-lstk(itop)
80 84
81 endif 85 endif
82 86
87c nlist is the size of the path index list
83 nlist=istk(ilind+1) 88 nlist=istk(ilind+1)
84 ll=sadr(ilind+3+nlist) 89 ll=sadr(ilind+3+nlist)
85 90
@@ -132,11 +137,14 @@ c . first field may contain the fields names
132 lfn=ilptr+nn 137 lfn=ilptr+nn
133c . look for corresponding index if any 138c . look for corresponding index if any
134 n=strpos(istk(ilptr),nn-1,istk(lfn),istk(ilname),nname) 139 n=strpos(istk(ilptr),nn-1,istk(lfn),istk(ilname),nname)
135
136 if(n.le.0) then 140 if(n.le.0) then
137c . no such name in the field names 141c . no such name in the field names
138 info=1 142 info=1
139 goto 50 143 goto 50
144 elseif(job.and.count.eq.nlist) then
145c . null assignment into a named sublist of an tlist or mlist
146 info=1
147 goto 50
140 endif 148 endif
141 n=n+1 149 n=n+1
142 endif 150 endif
diff --git a/scilab/modules/data_structures/src/fortran/insertfield.f b/scilab/modules/data_structures/src/fortran/insertfield.f
index b7e3b8d..f6ae11e 100644
--- a/scilab/modules/data_structures/src/fortran/insertfield.f
+++ b/scilab/modules/data_structures/src/fortran/insertfield.f
@@ -25,7 +25,7 @@ c
25 integer volfrom,voltos,volto,dvol,ind(*) 25 integer volfrom,voltos,volto,dvol,ind(*)
26 integer typfrom,typto 26 integer typfrom,typto
27 27
28 Integer subptr 28 integer subptr
29 external subptr 29 external subptr
30 30
31 integer iadr,sadr 31 integer iadr,sadr
diff --git a/scilab/modules/data_structures/src/fortran/intl_e.f b/scilab/modules/data_structures/src/fortran/intl_e.f
index f3adb5a..eebf3ad 100644
--- a/scilab/modules/data_structures/src/fortran/intl_e.f
+++ b/scilab/modules/data_structures/src/fortran/intl_e.f
@@ -83,7 +83,7 @@ c
83 endif 83 endif
84c go ahead along the path 84c go ahead along the path
85 call followpath(top1,top2,il1ir,vol1,il2ir,vol2,istk(ilind), 85 call followpath(top1,top2,il1ir,vol1,il2ir,vol2,istk(ilind),
86 $ icount,info,lw) 86 $ icount,info,lw,.false.)
87 if(err.gt.0) return 87 if(err.gt.0) return
88 if(vol2.eq.0) then 88 if(vol2.eq.0) then
89c empty field found 89c empty field found
@@ -231,7 +231,7 @@ c
231c standard matrix extraction 231c standard matrix extraction
232 call createref(il2i,0,vol2) 232 call createref(il2i,0,vol2)
233c 233c
234 34 fin=3 234 fin=3
235c back to allops for standard extraction 235c back to allops for standard extraction
236 if (ptover(1,psiz)) return 236 if (ptover(1,psiz)) return
237 icall=4 237 icall=4
diff --git a/scilab/modules/data_structures/src/fortran/intl_i.f b/scilab/modules/data_structures/src/fortran/intl_i.f
index cec2d16..caebcb0 100644
--- a/scilab/modules/data_structures/src/fortran/intl_i.f
+++ b/scilab/modules/data_structures/src/fortran/intl_i.f
@@ -77,6 +77,7 @@ c get arg2
77 else 77 else
78 vol2=lstk(top+1)-lstk(top) 78 vol2=lstk(top+1)-lstk(top)
79 endif 79 endif
80
80c 81c
81c get arg1 82c get arg1
82 top=top-1 83 top=top-1
@@ -99,7 +100,7 @@ c protect index list
99c go ahead along the path 100c go ahead along the path
100 icount=0 101 icount=0
101 call followpath(top1,top3,il1ir,vol1,il3ir,vol3, 102 call followpath(top1,top3,il1ir,vol1,il3ir,vol3,
102 $ istk(ilind),icount,info,lw) 103 $ istk(ilind),icount,info,lw,istk(il2).eq.0)
103 if(err.gt.0) return 104 if(err.gt.0) return
104 il1i=il1ir 105 il1i=il1ir
105 if(istk(il1i).lt.0) il1i=iadr(istk(il1i+1)) 106 if(istk(il1i).lt.0) il1i=iadr(istk(il1i+1))
diff --git a/scilab/modules/data_structures/src/fortran/udptr.f b/scilab/modules/data_structures/src/fortran/udptr.f
index 98f8392..dc8dcdd 100644
--- a/scilab/modules/data_structures/src/fortran/udptr.f
+++ b/scilab/modules/data_structures/src/fortran/udptr.f
@@ -56,6 +56,7 @@ c
56 sadr(l)=(l/2)+1 56 sadr(l)=(l/2)+1
57c 57c
58 il=ilt 58 il=ilt
59 if(istk(il).lt.0) il=iadr(istk(il+1))
59 if(nind.le.0) goto 30 60 if(nind.le.0) goto 30
60c 61c
61 do 20 k=1,nind 62 do 20 k=1,nind
@@ -64,6 +65,6 @@ c . m : sub-list size
64c . il pointer to ind(k) sub-list entry 65c . il pointer to ind(k) sub-list entry
65 il=iadr(sadr(il+3+m)+istk(il+1+ind(k))-1) 66 il=iadr(sadr(il+3+m)+istk(il+1+ind(k))-1)
66 20 continue 67 20 continue
67 30 subptr=il 68 30 subptr=il
68 end 69 end
69 70
diff --git a/scilab/modules/data_structures/tests/nonreg_tests/bug_5588.dia.ref b/scilab/modules/data_structures/tests/nonreg_tests/bug_5588.dia.ref
new file mode 100644
index 0000000..6f2483c
--- /dev/null
+++ b/scilab/modules/data_structures/tests/nonreg_tests/bug_5588.dia.ref
@@ -0,0 +1,63 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2010 - INRIA - Serge Steer
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7// <-- JVM NOT MANDATORY -->
8// <-- Non-regression test for bug 5588 -->
9//
10// <-- Bugzilla URL -->
11// http://bugzilla.scilab.org/show_bug.cgi?id=5588
12//
13// <-- Short Description -->
14// null() of a tlist() field shifts all remaining values with respect to
15// field names.
16// tlist null assignment indexed by a name
17clear %0_i_a %0_i_A
18t=tlist(["a","b","c"],10,"foo");
19if execstr("t.b=null()","errcatch")==0 then bugmes();quit;end
20function t=%0_i_a(i,void,t)
21 f=getfield(1,t);
22 k=find(f==i);
23 if k<>[] then
24 f(k)=[];
25 setfield(k,null(),t);
26 setfield(1,f,t);
27 end
28endfunction
29if execstr("t.b=null()","errcatch")<>0 then bugmes();quit;end
30if or(t<>tlist(["a","c"],"foo")) then bugmes();quit;end
31// tlist null assignment indexed by a number
32t=tlist(["a","b","c"],10,"foo");
33if execstr("t(2)=null()","errcatch")<>0 then bugmes();quit;end
34if or(t<>tlist(["a","b","c"],"foo")) then bugmes();quit;end
35//struct null assignment indexed by a name
36T.x="foo";T.y=33;
37if execstr("T.dims=null()","errcatch")==0 then bugmes();quit;end
38if execstr("T(1,1)=null()","errcatch")==0 then bugmes();quit;end
39if execstr("T.x=null()","errcatch")<>0 then bugmes();quit;end
40T1.y=33;
41if or(T<>T1) then bugmes();quit;end
42T1.x="foo";
43if execstr("T(1)=null()","errcatch")==0 then bugmes();quit;end
44//cell null assignment
45c=makecell([1,2],1,"xyz");
46if execstr("c(1,1)=null()","errcatch")==0 then bugmes();quit;end
47if execstr("c.dims=null()","errcatch")==0 then bugmes();quit;end
48//sublist null assigment indexed by a name
49L=tlist(["foo","x","y"],mlist(["A","b","c"],10,"zoo"),1:5);
50if execstr("L.x.b=null()","errcatch")==0 then bugmes();quit;end
51%0_i_A=%0_i_a;
52if execstr("L.x.b=null()","errcatch")<>0 then bugmes();quit;end
53if or(L<>tlist(["foo","x","y"],mlist(["A","c"],"zoo"),1:5)) then bugmes();quit;end
54//sublist null assigment indexed by a number
55clear %0_i_A
56L=mlist(["foo","x","y"],tlist(["A","b","c"],10,"zoo"),1:5);
57if execstr("L.x(2)=null()","errcatch")<>0 then bugmes();quit;end
58if or(L<>mlist(["foo","x","y"],tlist(["A","b","c"],"zoo"),1:5)) then bugmes();quit;end
59//try a more complex context
60L=tlist(["foo","x","y"],list(33,mlist(["A","b","c"],10,"zoo")),1:5);
61%0_i_A=%0_i_a;
62if execstr("L.x(2).b=null()","errcatch")<>0 then bugmes();quit;end
63if or(L<>tlist(["foo","x","y"],list(33,mlist(["A","c"],"zoo")),1:5)) then bugmes();quit;end
diff --git a/scilab/modules/data_structures/tests/nonreg_tests/bug_5588.tst b/scilab/modules/data_structures/tests/nonreg_tests/bug_5588.tst
new file mode 100644
index 0000000..2eee84d
--- /dev/null
+++ b/scilab/modules/data_structures/tests/nonreg_tests/bug_5588.tst
@@ -0,0 +1,75 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2010 - INRIA - Serge Steer
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7
8// <-- JVM NOT MANDATORY -->
9
10// <-- Non-regression test for bug 5588 -->
11//
12// <-- Bugzilla URL -->
13// http://bugzilla.scilab.org/show_bug.cgi?id=5588
14//
15// <-- Short Description -->
16// null() of a tlist() field shifts all remaining values with respect to
17// field names.
18
19// tlist null assignment indexed by a name
20clear %0_i_a %0_i_A
21t=tlist(["a","b","c"],10,"foo");
22if execstr("t.b=null()","errcatch")==0 then pause,end
23function t=%0_i_a(i,void,t)
24 f=getfield(1,t);
25 k=find(f==i);
26 if k<>[] then
27 f(k)=[];
28 setfield(k,null(),t);
29 setfield(1,f,t);
30 end
31endfunction
32if execstr("t.b=null()","errcatch")<>0 then pause,end
33if or(t<>tlist(["a","c"],"foo")) then pause,end
34
35// tlist null assignment indexed by a number
36t=tlist(["a","b","c"],10,"foo");
37if execstr("t(2)=null()","errcatch")<>0 then pause,end
38if or(t<>tlist(["a","b","c"],"foo")) then pause,end
39
40//struct null assignment indexed by a name
41T.x="foo";T.y=33;
42if execstr("T.dims=null()","errcatch")==0 then pause,end
43if execstr("T(1,1)=null()","errcatch")==0 then pause,end
44
45if execstr("T.x=null()","errcatch")<>0 then pause,end
46T1.y=33;
47if or(T<>T1) then pause,end
48T1.x="foo";
49if execstr("T(1)=null()","errcatch")==0 then pause,end
50
51
52//cell null assignment
53c=makecell([1,2],1,"xyz");
54if execstr("c(1,1)=null()","errcatch")==0 then pause,end
55if execstr("c.dims=null()","errcatch")==0 then pause,end
56
57//sublist null assigment indexed by a name
58L=tlist(["foo","x","y"],mlist(["A","b","c"],10,"zoo"),1:5);
59if execstr("L.x.b=null()","errcatch")==0 then pause,end
60%0_i_A=%0_i_a;
61if execstr("L.x.b=null()","errcatch")<>0 then pause,end
62if or(L<>tlist(["foo","x","y"],mlist(["A","c"],"zoo"),1:5)) then pause,end
63
64//sublist null assigment indexed by a number
65clear %0_i_A
66L=mlist(["foo","x","y"],tlist(["A","b","c"],10,"zoo"),1:5);
67if execstr("L.x(2)=null()","errcatch")<>0 then pause,end
68if or(L<>mlist(["foo","x","y"],tlist(["A","b","c"],"zoo"),1:5)) then pause,end
69
70//try a more complex context
71L=tlist(["foo","x","y"],list(33,mlist(["A","b","c"],10,"zoo")),1:5);
72%0_i_A=%0_i_a;
73if execstr("L.x(2).b=null()","errcatch")<>0 then pause,end
74
75if or(L<>tlist(["foo","x","y"],list(33,mlist(["A","c"],"zoo")),1:5)) then pause,end