Scicos: fix the "" + [] and 1 + [] 47/17547/4
Clément DAVID [Mon, 7 Dec 2015 12:33:07 +0000 (13:33 +0100)]
Change-Id: Ifa4e6b58fac424d79f7b95555f50d0bf8e3b549a

scilab/modules/scicos/macros/scicos_scicos/c_pass2.sci
scilab/modules/scicos/macros/scicos_scicos/scicos_graphics.sci

index 4025b86..cfc838a 100644 (file)
@@ -438,6 +438,10 @@ endfunction
 
 function uni=merge_mat(m1,m2)
     // for  m1 and m2 with two columns containing >=0 values
+    if isempty(m1) & isempty(m2) then
+        uni=[];
+        return;
+    end
     uni=[m1;m2]
     n=max(uni(:,2))+1;
     [j,ind]=unique(uni(:,1)*n+uni(:,2))
@@ -502,7 +506,11 @@ function ok=is_alg_event_loop(typ_l,clkconnect)
     while i<=n
         i=i+1
         oldvec=vec  // not optimal to use large v
-        vec(lclkconnect(:,2))=vec(lclkconnect(:,1))+1
+        if isempty(vec(lclkconnect(:,1))) then
+            vec(lclkconnect(:,2))=1
+        else
+            vec(lclkconnect(:,2))=vec(lclkconnect(:,1))+1
+        end
         if and(vec==oldvec) then
             ok=%t
             return
@@ -1064,14 +1072,23 @@ function [ordclk,iord,oord,zord,typ_z,ok]=scheduler(inpptr,outptr,clkptr,execlk_
     //critev: vecteur indiquant si evenement est important pour tcrit
     //Donc les blocks indiques sont des blocks susceptibles de produire
     //des discontinuites quand l'evenement se produit
-    maX=max([ext_cord1(:,2);ordclk(:,2)])+1;
-    cordX=ext_cord1(:,1)*maX+ext_cord1(:,2);
+    if isempty(ext_cord1) then
+        if isempty(ordclk) then
+            maX=1;
+        else
+            maX=max(ordclk(:,2))+1;
+        end
+        cordX = [];
+    else
+        maX=max([ext_cord1(:,2);ordclk(:,2)])+1;
+        cordX=ext_cord1(:,1)*maX+ext_cord1(:,2);
+    end
 
     // 1: important; 0:non
     //n=clkptr(nblk+1)-1 //nb d'evenement
     n=size(ordptr,"*")-1 //nb d'evenement
 
-    //a priori tous les evenemets sont non-importants
+    //a priori tous les evenements sont non-importants
     //critev=zeros(n,1)
     for i=1:n
         for hh=ordptr(i):ordptr(i+1)-1
@@ -1341,7 +1358,11 @@ function [lnksz,lnktyp,inplnk,outlnk,clkptr,cliptr,inpptr,outptr,xptr,zptr,..
 
     clkconnect=clkconnect(find(clkconnect(:,1)<>0),:);
 
-    con=clkptr(clkconnect(:,1))+clkconnect(:,2)-1;
+    if isempty(clkconnect) then
+        con=-1;
+    else
+        con=clkptr(clkconnect(:,1))+clkconnect(:,2)-1;
+    end
     [junk,ind]=gsort(-con);con=-junk;
     clkconnect=clkconnect(ind,:);
     //
@@ -2166,8 +2187,12 @@ function [clkconnect,exe_cons]=pak_ersi(connectmat,clkconnect,..
     if show_trace then mprintf("c_pass4445:\t%f\n", timer()),end
 
     [clkr,clkc]=size(clkconnect);
-    mm=max(clkconnect(:,2))+1;
-    cll=clkconnect(:,1)*mm+clkconnect(:,2);
+    if isempty(clkconnect) then
+        cll=[];
+    else
+        mm=max(clkconnect(:,2))+1;
+        cll=clkconnect(:,1)*mm+clkconnect(:,2);
+    end
     [cll,ind]=gsort(-cll);
     clkconnect=clkconnect(ind,:);
     if cll<>[] then mcll=max(-cll)+1, else mcll=1;end
@@ -2406,7 +2431,11 @@ function  [r,ok]=newc_tree3(vec,dep_u,dep_uptr,typ_l)
 endfunction
 
 function  [r,ok]=new_tree4(vec,outoin,outoinptr,typ_r)
-    nd=zeros(size(vec,"*"),(max(outoin(:,2))+1));
+    if isempty(outoin) then
+        nd=zeros(size(vec,"*"),1);
+    else
+        nd=zeros(size(vec,"*"),(max(outoin(:,2))+1));
+    end
     ddd=zeros(typ_r);ddd(typ_r)=1;
     [r1,r2]=sci_tree4(vec,outoin,outoinptr,nd,ddd)
     r=[r1',r2']
@@ -2414,7 +2443,11 @@ function  [r,ok]=new_tree4(vec,outoin,outoinptr,typ_r)
 endfunction
 
 function  [r,ok]=newc_tree4(vec,outoin,outoinptr,typ_r)
-    nd=zeros(size(vec,"*"),(max(outoin(:,2))+1));
+    if isempty(outoin) then
+        nd=zeros(size(vec,"*"),1);
+    else
+        nd=zeros(size(vec,"*"),(max(outoin(:,2))+1));
+    end
     ddd=zeros(typ_r);ddd(typ_r)=1;
     [r1,r2]=ctree4(vec,outoin,outoinptr,nd,ddd)
     r=[r1',r2']
@@ -2424,6 +2457,11 @@ endfunction
 function [critev]=critical_events(connectmat,clkconnect,dep_t,typ_r,..
     typ_l,typ_zx,outoin,outoinptr,clkptr)
 
+    if isempty(clkconnect) then
+        critev = [];
+        return
+    end
+
     typ_c=typ_l<>typ_l;
     typ_r=typ_r|dep_t
 
index 081e2eb..1626665 100644 (file)
@@ -53,7 +53,7 @@ function graphics=scicos_graphics(v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,...
     if exists("out_label","local")==0 then
         out_label=emptystr(pout);
     end
-    if exists("style","local")==0 then style="" + [],end
+    if exists("style","local")==0 then style="", end
 
     graphics=scicos_new(["graphics","orig","sz","flip","theta","exprs","pin",..
     "pout","pein","peout","gr_i","id","in_implicit","out_implicit","in_style","out_style","in_label","out_label","style"],..