summaryrefslogtreecommitdiffstats
path: root/scilab/modules/data_structures/macros/struct.sci
diff options
context:
space:
mode:
authorVincent COUVERT <vincent.couvert@scilab.org>2010-01-28 16:35:14 +0100
committerVincent COUVERT <vincent.couvert@scilab.org>2010-01-28 16:35:14 +0100
commitad6d59ad324e97774b3fb09e4daf906ddc7126cc (patch)
treea52c5de18daaf2f81429a40afdca16b57baca41c /scilab/modules/data_structures/macros/struct.sci
parente4722f470d54ee7a2785ba56f9a9e193f2a27911 (diff)
downloadscilab-ad6d59ad324e97774b3fb09e4daf906ddc7126cc.zip
scilab-ad6d59ad324e97774b3fb09e4daf906ddc7126cc.tar.gz
Avoid a field to be defined twice
Diffstat (limited to 'scilab/modules/data_structures/macros/struct.sci')
-rw-r--r--scilab/modules/data_structures/macros/struct.sci13
1 files changed, 10 insertions, 3 deletions
diff --git a/scilab/modules/data_structures/macros/struct.sci b/scilab/modules/data_structures/macros/struct.sci
index de41446..1fa4cce 100644
--- a/scilab/modules/data_structures/macros/struct.sci
+++ b/scilab/modules/data_structures/macros/struct.sci
@@ -13,8 +13,6 @@ function s=struct(varargin)
13 13
14rhs=argn(2) 14rhs=argn(2)
15 15
16fields=["st","dims"]
17
18if rhs==0 then 16if rhs==0 then
19 // No Matlab equivalent 17 // No Matlab equivalent
20 s=mlist(fields,int32([0,0])) 18 s=mlist(fields,int32([0,0]))
@@ -22,16 +20,25 @@ if rhs==0 then
22end 20end
23 21
24if floor(rhs/2)*2<>rhs then 22if floor(rhs/2)*2<>rhs then
25 error(msprintf(gettext("%s: Wrong number of input argument(s) : an even number is expected."),"struct")); 23 error(msprintf(gettext("%s: Wrong number of input argument(s) : an even number is expected.\n"),"struct"));
26end 24end
27 25
28nbfields=size(varargin)/2 26nbfields=size(varargin)/2
29 27
30dims=[] 28dims=[]
29fields = [];
31for kf=1:2:size(varargin) 30for kf=1:2:size(varargin)
31 if varargin(kf)=="dims" then
32 error(msprintf(gettext("%s: ''dims'' can not be used as a field name.\n"),"struct"));
33 end
34 if or(varargin(kf)==fields) then
35 error(msprintf(gettext("%s: field name ''%s'' defined twice.\n"),"struct",varargin(kf)));
36 end
32 fields=[fields varargin(kf)] 37 fields=[fields varargin(kf)]
33end 38end
34 39
40fields=["st","dims", fields]
41
35dims=[1 1] 42dims=[1 1]
36// Search struct size 43// Search struct size
37for kf=2:2:size(varargin) 44for kf=2:2:size(varargin)