bug 12869 fix 90/12390/4
Serge Steer [Fri, 30 Aug 2013 13:39:03 +0000 (15:39 +0200)]
Change-Id: I500de973edad9657f514b017718a17be5c40accf

scilab/CHANGES_5.5.X
scilab/modules/scicos/macros/scicos_scicos/do_compile_superblock42.sci
scilab/modules/xcos/tests/nonreg_tests/bug_12869.tst [new file with mode: 0644]
scilab/modules/xcos/tests/nonreg_tests/bug_12869.zcos [new file with mode: 0644]

index 22e4257..ff280e9 100644 (file)
@@ -199,6 +199,8 @@ Xcos
 
 * Bug #12868 fixed - There were several problems with PULSE_SC block.
 
+* Bug #12869 fixed - min and max were not defined but used in Xcos generated code.
+
 * Bug #12873 fixed - Scicos_flat produced an unexpected error after a diagram
                      load.
 
index cb35d28..9e8d1c4 100644 (file)
@@ -1084,70 +1084,70 @@ function ok=gen_gui42();
     clkinput=ones(clkIN)';
     clkoutput=ones(clkOUT)';
     for i=1:length(bllst)
-      deput=[%t,%f]
-      if (bllst(i).dep_ut(2) == %t) then
-        deput(1,2)=%t;
-        break;
-      end
+        deput=[%t,%f]
+        if (bllst(i).dep_ut(2) == %t) then
+            deput(1,2)=%t;
+            break;
+        end
     end
     Code=["function [sciblk, s1, s2] = "+rdnom+"_c(job,sciblk,e1)"
-          "// Interfacing function  of generated Xcos block "+rdnom
-          "//    Generated by the Xcos Code_Generation tool with "+getversion();
-          "//    Date : "+date();
-          "//"
-          "  s1= []; s2 = [];"
-          "  select job";
-          "  case ""set"" then";
-          "  case ""define"" then"
-          "    "+sci2exp(capt(:,3),"in",70); //input ports sizes 1
-          "    "+sci2exp(capt(:,4),"in2",70); //input ports sizes 2
-          "    "+sci2exp(scs_c_nb2scs_nb(capt(:,5)),"intyp",70); //input ports type
-          "    "+sci2exp(actt(:,3),"out",70); //output ports sizes 1
-          "    "+sci2exp(actt(:,4),"out2",70); //output ports sizes 2
-          "    "+sci2exp(scs_c_nb2scs_nb(actt(:,5)),"outtyp",70); //output ports type
-          "    "+sci2exp(cpr.state.x,"x",70); //initial continuous state
-          "    "+sci2exp(cpr.state.z,"z",70); //initial discrete state
-          "    work=zeros("+string(nblk)+",1)";
-          "    Z=[z;work]";
-          "    "+sci2exp(lstcat(cpr.state.oz,cpr.state.outtb),"odstate",70);
-          "    "+sci2exp(cpr.sim.rpar,"rpar",70); //real parameters
-          "    "+sci2exp(cpr.sim.ipar,"ipar",70); //integer parameters
-          "    "+sci2exp(cpr.sim.opar,"opar",70); //object parameters
-          "    "+sci2exp(clkinput,"clkinput",70);
-          "    "+sci2exp(clkoutput,"clkoutput",70);
-          "    "+sci2exp(FIRING,"firing",70);
-          "    nzcross="+string(sum(cpr.sim.zcptr(2:$)-cpr.sim.zcptr(1:$-1)))';
-          "    nmode="+string(sum(cpr.sim.modptr(2:$)-cpr.sim.modptr(1:$-1)))';
-          "    "+sci2exp(deput,"dep_ut",70);
-          "    model=scicos_model(sim=list(''"+rdnom+"'',4),...";
-          "                       in=in,..."
-          "                       in2=in2,..."
-          "                       intyp=intyp,..."
-          "                       out=out,..."
-          "                       out2=out2,..."
-          "                       outtyp=outtyp,..."
-          "                       evtin=clkinput,..."
-          "                       evtout=clkoutput,..."
-          "                       firing=firing,..."
-          "                       state=x,..."
-          "                       dstate=Z,..."
-          "                       odstate=odstate,..."
-          "                       rpar=rpar,..."
-          "                       ipar=ipar,..."
-          "                       opar=opar,..."
-          "                       blocktype=''c'',..."
-          "                       dep_ut=dep_ut,..."
-          "                       nzcross=nzcross,..."
-          "                       nmode=nmode)";
-          "    gr_i=""xstringb(orig(1),orig(2),"""""+rdnom+""""",sz(1),sz(2),""""fill"""")""";
-          "    sciblk = standard_define([2 2],model,[],gr_i);";
-          "    style_properties = [""blockWithLabel"";";
-          "                        ""verticalLabelPosition=middle"";";
-          "                        ""verticalAlign=middle"";";
-          "                        ""displayedLabel="+rdnom+"""];";
-          "    sciblk.graphics.style = strcat(style_properties,"";"");";
-          "  end"
-          "endfunction"];
+    "// Interfacing function  of generated Xcos block "+rdnom
+    "//    Generated by the Xcos Code_Generation tool with "+getversion();
+    "//    Date : "+date();
+    "//"
+    "  s1= []; s2 = [];"
+    "  select job";
+    "  case ""set"" then";
+    "  case ""define"" then"
+    "    "+sci2exp(capt(:,3),"in",70); //input ports sizes 1
+    "    "+sci2exp(capt(:,4),"in2",70); //input ports sizes 2
+    "    "+sci2exp(scs_c_nb2scs_nb(capt(:,5)),"intyp",70); //input ports type
+    "    "+sci2exp(actt(:,3),"out",70); //output ports sizes 1
+    "    "+sci2exp(actt(:,4),"out2",70); //output ports sizes 2
+    "    "+sci2exp(scs_c_nb2scs_nb(actt(:,5)),"outtyp",70); //output ports type
+    "    "+sci2exp(cpr.state.x,"x",70); //initial continuous state
+    "    "+sci2exp(cpr.state.z,"z",70); //initial discrete state
+    "    work=zeros("+string(nblk)+",1)";
+    "    Z=[z;work]";
+    "    "+sci2exp(lstcat(cpr.state.oz,cpr.state.outtb),"odstate",70);
+    "    "+sci2exp(cpr.sim.rpar,"rpar",70); //real parameters
+    "    "+sci2exp(cpr.sim.ipar,"ipar",70); //integer parameters
+    "    "+sci2exp(cpr.sim.opar,"opar",70); //object parameters
+    "    "+sci2exp(clkinput,"clkinput",70);
+    "    "+sci2exp(clkoutput,"clkoutput",70);
+    "    "+sci2exp(FIRING,"firing",70);
+    "    nzcross="+string(sum(cpr.sim.zcptr(2:$)-cpr.sim.zcptr(1:$-1)))';
+    "    nmode="+string(sum(cpr.sim.modptr(2:$)-cpr.sim.modptr(1:$-1)))';
+    "    "+sci2exp(deput,"dep_ut",70);
+    "    model=scicos_model(sim=list(''"+rdnom+"'',4),...";
+    "                       in=in,..."
+    "                       in2=in2,..."
+    "                       intyp=intyp,..."
+    "                       out=out,..."
+    "                       out2=out2,..."
+    "                       outtyp=outtyp,..."
+    "                       evtin=clkinput,..."
+    "                       evtout=clkoutput,..."
+    "                       firing=firing,..."
+    "                       state=x,..."
+    "                       dstate=Z,..."
+    "                       odstate=odstate,..."
+    "                       rpar=rpar,..."
+    "                       ipar=ipar,..."
+    "                       opar=opar,..."
+    "                       blocktype=''c'',..."
+    "                       dep_ut=dep_ut,..."
+    "                       nzcross=nzcross,..."
+    "                       nmode=nmode)";
+    "    gr_i=""xstringb(orig(1),orig(2),"""""+rdnom+""""",sz(1),sz(2),""""fill"""")""";
+    "    sciblk = standard_define([2 2],model,[],gr_i);";
+    "    style_properties = [""blockWithLabel"";";
+    "                        ""verticalLabelPosition=middle"";";
+    "                        ""verticalAlign=middle"";";
+    "                        ""displayedLabel="+rdnom+"""];";
+    "    sciblk.graphics.style = strcat(style_properties,"";"");";
+    "  end"
+    "endfunction"];
     //Create file
     ierr=execstr("mputl(Code,rpat+""/""+rdnom+""_c.sci"")","errcatch")
     if ierr<>0 then
@@ -1801,6 +1801,8 @@ function  [ok,XX,alreadyran,flgcdgen,szclkINTemp,freof] = do_compile_superblock4
         //Change diagram superblock to new generated block
         XX=update_block(XX);
         execstr(rdnom+"_c=resume("+rdnom+"_c)")
+    else
+        message([_("Generated block cannot be linked with Scilab.")])
     end
 
 endfunction
@@ -2254,16 +2256,12 @@ function make_computational42(filename)
     "#include ""scicos.h"" "
     "#include ""scicos_malloc.h"" "
     "#include ""scicos_free.h"" "
-    ""], fd);
-
-    if getos() == "Windows" then
-
-        mputl([" "
-        "#define max(a,b) ((a) >= (b) ? (a) : (b))"
-        "#define min(a,b) ((a) <= (b) ? (a) : (b))"
-        " "
-        ], fd);
-    end
+    "#ifndef max"
+    "#define max(a,b) ((a) >= (b) ? (a) : (b))"
+    "#endif"
+    "#ifndef min"
+    "#define min(a,b) ((a) <= (b) ? (a) : (b))"
+    "#endif"], fd);
 
     mputl([Protos ; ""], fd);
 
@@ -3408,19 +3406,18 @@ function make_standalone42(filename)
     "#include <memory.h>"
     "#include '"scicos_block4.h'""
     "#include '"machine.h'""
+    "#ifndef max"
+    "#define max(a,b) ((a) >= (b) ? (a) : (b))"
+    "#endif"
+    "#ifndef min"
+    "#define min(a,b) ((a) <= (b) ? (a) : (b))"
+    "#endif"
     ""
     "/* ---- Internals functions declaration ---- */"
     "int "+rdnom+"_sim(double, double, double, int);"
     Protostalone
     ""], fd);
 
-    if getos() == "Windows" then
-        mputl([" "
-        "#define max(a,b) ((a) >= (b) ? (a) : (b))"
-        "#define min(a,b) ((a) <= (b) ? (a) : (b))"
-        " "
-        ], fd);
-    end
 
 
     if x<>[] then
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_12869.tst b/scilab/modules/xcos/tests/nonreg_tests/bug_12869.tst
new file mode 100644 (file)
index 0000000..ee2a06e
--- /dev/null
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - INRIA - Serge Steer
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- XCOS TEST -->
+// <-- INTERACTIVE TEST -->
+//
+// <-- Non-regression test for bug 12869 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12869
+//
+// <-- Short Description -->
+// min and max used in the generated codes are not defined
+xcos SCI/modules/xcos/tests/nonreg_tests/bug_12869.zcos
+//Generate code for the Test super block. Ok if the Test block icon changes.
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_12869.zcos b/scilab/modules/xcos/tests/nonreg_tests/bug_12869.zcos
new file mode 100644 (file)
index 0000000..f248fde
Binary files /dev/null and b/scilab/modules/xcos/tests/nonreg_tests/bug_12869.zcos differ