Merge remote-tracking branch 'origin/master' into YaSp 72/16572/1
Vincent COUVERT [Tue, 2 Jun 2015 08:33:59 +0000 (10:33 +0200)]
Conflicts:
scilab/modules/fftw/src/c/fftw_utilities.c
scilab/modules/overloading/macros/%hm_prod.sci
scilab/modules/overloading/macros/%hm_sum.sci

Change-Id: I82b54e5c917e07e8637b561ddec9949fd0bcb038

24 files changed:
scilab/CHANGES_5.5.X
scilab/checkstyle/scilab_checkstyle_convention.xml
scilab/modules/commons/src/java/org/scilab/modules/commons/xml/ScilabXPathFactory.java [new file with mode: 0644]
scilab/modules/commons/src/java/org/scilab/modules/commons/xml/XConfiguration.java
scilab/modules/external_objects_java/src/java/org/scilab/modules/external_objects_java/ScilabJavaCompiler.java
scilab/modules/fftw/tests/nonreg_tests/bug_13866.dia.ref [new file with mode: 0644]
scilab/modules/fftw/tests/nonreg_tests/bug_13866.tst [new file with mode: 0644]
scilab/modules/graphics/macros/datatips/datatipRemoveAll.sci
scilab/modules/graphics/tests/nonreg_tests/bug_13881.dia.ref [new file with mode: 0644]
scilab/modules/graphics/tests/nonreg_tests/bug_13881.tst [new file with mode: 0644]
scilab/modules/gui/src/java/org/scilab/modules/gui/utils/WindowsConfigurationManager.java
scilab/modules/jvm/src/java/org/scilab/modules/jvm/LoadClassPath.java
scilab/modules/overloading/tests/nonreg_tests/bug_13829.dia.ref
scilab/modules/overloading/tests/nonreg_tests/bug_13829.tst
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/SciNotesOptions.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/ScilabContext.java
scilab/modules/xcos/demos/ModelicaBlocks/Heat_conduction.zcos [new file with mode: 0644]
scilab/modules/xcos/demos/ModelicaBlocks/Rotational_system.zcos [new file with mode: 0644]
scilab/modules/xcos/demos/ModelicaBlocks/modelica_heat_conduction.dem.sce [new file with mode: 0644]
scilab/modules/xcos/demos/ModelicaBlocks/modelica_rotational_system.dem.sce [new file with mode: 0644]
scilab/modules/xcos/demos/modelica_demos.dem.gateway.sce
scilab/modules/xcos/src/java/org/scilab/modules/xcos/graph/XcosDiagram.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/codec/XcosDiagramCodec.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/spec/XcosPackage.java

index a3e15bc..8a07333 100644 (file)
@@ -6,6 +6,12 @@ Scilab Bug Fixes
 
 * Bug #13829 fixed - mean and sum functions returned wrong results for hypermatrices.
 
+* Bug #13854 fixed - On some operating systems, SciNotes did not initialize a new document at startup.
+
+* Bug #13866 fixed - There were some issues with FFTW3 library.
+
+* Bug #13881 fixed - datatipRemoveAll did not work.
+
 
 
                      Changes between version 5.5.1 and 5.5.2
@@ -20,6 +26,7 @@ Graphics Evolutions
 
 * New contour2dm function.
 
+
 Toolbox Skeleton
 =================
 
index 935f7b2..734f402 100644 (file)
@@ -57,7 +57,6 @@ Description:
             <module name="NeedBraces"/>
             <module name="RightCurly"/>
             <module name="AvoidInlineConditionals"/>
-            <module name="DoubleCheckedLocking"/>
             <module name="EmptyStatement"/>
             <module name="EqualsHashCode"/>
             <module name="HiddenField">
@@ -67,7 +66,6 @@ Description:
             <module name="InnerAssignment"/>
             <module name="MagicNumber"/>
             <module name="MissingSwitchDefault"/>
-            <module name="RedundantThrows"/>
             <module name="SimplifyBooleanExpression"/>
             <module name="SimplifyBooleanReturn"/>
             <module name="DesignForExtension">
diff --git a/scilab/modules/commons/src/java/org/scilab/modules/commons/xml/ScilabXPathFactory.java b/scilab/modules/commons/src/java/org/scilab/modules/commons/xml/ScilabXPathFactory.java
new file mode 100644 (file)
index 0000000..dbfc89d
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2015 - Scilab Enteprises - Clement DAVID
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+package org.scilab.modules.commons.xml;
+
+import javax.xml.xpath.XPathFactory;
+
+/**
+ * Class to provide a way to be sure that the default PathFactory provided by Java framework will be used.
+ */
+public class ScilabXPathFactory {
+
+    private static final String XPATHFACTORYPROPERTY = "javax.xml.xpath.XPathFactory";
+    private static final String XPATHFACTORYIMPL = "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl";
+
+    /**
+     * Use default internal XPathFactoryImpl
+     * @return the key corresponding to the currently used implementation
+     */
+    public static String useDefaultTransformerFactoryImpl() {
+        String factory = System.getProperty(XPATHFACTORYPROPERTY);
+        System.setProperty(XPATHFACTORYPROPERTY, XPATHFACTORYIMPL);
+
+        return factory;
+    }
+
+    /**
+     * Restore the previous factory
+     * @param factory the key as returned by useDefaultPathFactoryImpl
+     */
+    public static void restoreTransformerFactoryImpl(String factory) {
+        if (factory == null) {
+            System.clearProperty(XPATHFACTORYPROPERTY);
+        } else {
+            System.setProperty(XPATHFACTORYPROPERTY, factory);
+        }
+    }
+
+    /**
+     * @return a new instance using the default XPathFactory implementation
+     */
+    public static XPathFactory newInstance() {
+        String factory = useDefaultTransformerFactoryImpl();
+        XPathFactory xpf = XPathFactory.newInstance();
+        restoreTransformerFactoryImpl(factory);
+
+        return xpf;
+    }
+}
index 1c6c8f0..41dfc62 100644 (file)
@@ -79,7 +79,7 @@ public class XConfiguration {
     private static final String SEVERE_ERROR = Messages.gettext("A severe error occurred: cannot load the preferences file.");
     private static final String PARSING_ERROR = Messages.gettext("An error occurred when loading the preferences file, try to reload the default one.");
 
-    private static final XPathFactory xpathFactory = XPathFactory.newInstance();
+    private static final XPathFactory xpathFactory = ScilabXPathFactory.newInstance();
     private static final Map < Class<?>, StringParser > conv = new HashMap < Class<?>, StringParser > ();
 
     private static final EventListenerList listenerList = new EventListenerList();
index 5e303ca..da636d2 100644 (file)
@@ -232,27 +232,32 @@ public class ScilabJavaCompiler {
         int cpt = 1;
         buffer.append("----------\n");
         for (Diagnostic <? extends JavaFileObject > d : diagnostics.getDiagnostics()) {
-            buffer.append(Integer.toString(cpt++)).append(". ").append(d.getKind()).append(" in ").append(d.getSource().toUri().getPath()).append(" (at line ").append(Long.toString(d.getLineNumber())).append(")\n");
-
-            Reader reader = null;
-            try {
-                reader = d.getSource().openReader(true);
-                reader.skip(d.getStartPosition());
-                char[] data = new char[(int) (d.getEndPosition() - d.getStartPosition() + 1)];
-                reader.read(data);
-                buffer.append("        ").append(data).append('\n');
-                Arrays.fill(data, '^');
-                buffer.append("        ").append(data).append('\n');
-            } catch (IOException e) {
-
-            } finally {
-                if (reader != null) {
-                    try {
-                        reader.close();
-                    } catch (IOException e) { }
+            buffer.append(Integer.toString(cpt++)).append(". ").append(d.getKind());
+            if (d.getSource() != null) {
+                buffer.append(" in ").append(d.getSource().toUri().getPath()).append(" (at line ").append(Long.toString(d.getLineNumber())).append(")\n");
+
+                Reader reader = null;
+                try {
+                    reader = d.getSource().openReader(true);
+                    reader.skip(d.getStartPosition());
+                    char[] data = new char[(int) (d.getEndPosition() - d.getStartPosition() + 1)];
+                    reader.read(data);
+                    buffer.append("        ").append(data).append('\n');
+                    Arrays.fill(data, '^');
+                    buffer.append("        ").append(data).append('\n');
+                } catch (IOException e) {
+
+                } finally {
+                    if (reader != null) {
+                        try {
+                            reader.close();
+                        } catch (IOException e) { }
+                    }
                 }
+            } else {
+                // this is not a file related error
+                buffer.append('\n');
             }
-
             buffer.append(d.getMessage(Locale.getDefault())).append('\n');
         }
 
diff --git a/scilab/modules/fftw/tests/nonreg_tests/bug_13866.dia.ref b/scilab/modules/fftw/tests/nonreg_tests/bug_13866.dia.ref
new file mode 100644 (file)
index 0000000..1024288
--- /dev/null
@@ -0,0 +1,49 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Vincent COUVERT
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 13866 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13866
+//
+// <-- Short Description -->
+// weird behaviour of fft(real(S))
+s=zeros(100,1);
+s(4)=1;
+S=fft(s,-1);
+CC=cos(2*%pi*[0:99]'*3/100);
+CS=-sin(2*%pi*[0:99]'*3/100);
+assert_checkalmostequal(real(S), CC, [], 10*%eps);
+// With fresh plan creation
+fft([1;0;0],-1); // Force the creation of a new plan at next line
+rs=fft(real(S),-1);
+is=fft(imag(S),-1);
+assert_checkalmostequal(real(rs), real(fft(CC,-1)), [], 100*%eps);
+rs2=fft(real(S),-1,dim=100,incr=1); // dim + incr forced
+assert_checkequal(real(rs), real(rs2));
+assert_checkalmostequal(imag(is), imag(fft(CS,-1)), [], 100*%eps);
+// Without fresh plan creation (1)
+fft(eye(100,1),-1); // Plan with same size => no new plan creation at next line
+rs=fft(real(S),-1);
+is=fft(imag(S),-1);
+assert_checkalmostequal(real(rs), real(fft(CC,-1)), [], 100*%eps);
+rs2=fft(real(S),-1,dim=100,incr=1); // dim + incr forced
+assert_checkequal(real(rs), real(rs2));
+assert_checkalmostequal(imag(is), imag(fft(CS,-1)), [], 100*%eps);
+// Without fresh plan creation (2)
+rs=fft(real(S),-1);
+is=fft(imag(S),-1);
+assert_checkalmostequal(real(rs), real(fft(CC,-1)), [], 100*%eps);
+rs2=fft(real(S),-1,dim=100,incr=1); // dim + incr forced
+assert_checkequal(real(rs), real(rs2));
+assert_checkalmostequal(imag(is), imag(fft(CS,-1)), [], 100*%eps);
+// convol test
+t=rand(1,100);
+r=convol(eye(50,1)',t);
+assert_checkalmostequal(t(1:10),r(1:10), [], 100*%eps);
diff --git a/scilab/modules/fftw/tests/nonreg_tests/bug_13866.tst b/scilab/modules/fftw/tests/nonreg_tests/bug_13866.tst
new file mode 100644 (file)
index 0000000..84857c7
--- /dev/null
@@ -0,0 +1,65 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Vincent COUVERT
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 13866 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13866
+//
+// <-- Short Description -->
+// weird behaviour of fft(real(S))
+
+s=zeros(100,1);
+s(4)=1;
+S=fft(s,-1);
+CC=cos(2*%pi*[0:99]'*3/100);
+CS=-sin(2*%pi*[0:99]'*3/100);
+assert_checkalmostequal(real(S), CC, [], 10*%eps);
+
+// With fresh plan creation
+fft([1;0;0],-1); // Force the creation of a new plan at next line
+rs=fft(real(S),-1);
+is=fft(imag(S),-1);
+
+assert_checkalmostequal(real(rs), real(fft(CC,-1)), [], 100*%eps);
+
+rs2=fft(real(S),-1,dim=100,incr=1); // dim + incr forced
+assert_checkequal(real(rs), real(rs2));
+
+assert_checkalmostequal(imag(is), imag(fft(CS,-1)), [], 100*%eps);
+
+
+// Without fresh plan creation (1)
+fft(eye(100,1),-1); // Plan with same size => no new plan creation at next line
+rs=fft(real(S),-1);
+is=fft(imag(S),-1);
+
+assert_checkalmostequal(real(rs), real(fft(CC,-1)), [], 100*%eps);
+
+rs2=fft(real(S),-1,dim=100,incr=1); // dim + incr forced
+assert_checkequal(real(rs), real(rs2));
+
+assert_checkalmostequal(imag(is), imag(fft(CS,-1)), [], 100*%eps);
+
+
+// Without fresh plan creation (2)
+rs=fft(real(S),-1);
+is=fft(imag(S),-1);
+
+assert_checkalmostequal(real(rs), real(fft(CC,-1)), [], 100*%eps);
+
+rs2=fft(real(S),-1,dim=100,incr=1); // dim + incr forced
+assert_checkequal(real(rs), real(rs2));
+
+assert_checkalmostequal(imag(is), imag(fft(CS,-1)), [], 100*%eps);
+
+// convol test
+t=rand(1,100);
+r=convol(eye(50,1)',t);
+assert_checkalmostequal(t(1:10),r(1:10), [], 100*%eps);
\ No newline at end of file
index eb98cf5..0df8a75 100644 (file)
@@ -1,5 +1,6 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+// Copyright (C) 2015 - Samuel GOUGEON : http://bugzilla.scilab.org/13881
 //
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
 function datatipRemoveAll(curve_handles)
     //remove all the datatips for the given curves
     if argn(2)<>1 then //search for curves in the current axes
-        ax=gca()
-        curve_handles=datatipGetEntities(ax)
+        ax = gca()
+        curve_handles = datatipGetEntities(ax)
     elseif type(curve_handles)<>9 then
         error(msprintf(_("%s: Wrong type for input argument #%d: an array of graphic handle expected.\n"),"datatipRemoveAll",1))
-    elseif size(curve_handles,"*")==1&curve_handles.type=="Axes" then
+    elseif size(curve_handles,"*")==1 & curve_handles.type=="Axes" then
         //the argument is a handle on an axes, search for curves in it
-        ax=curve_handles
-        curve_handles=datatipGetEntities(ax)
-    elseif and(curve_handles<>"Figure") then
+        ax = curve_handles
+        curve_handles = datatipGetEntities(ax)
+    elseif and(curve_handles.type<>"Figure") then
         //check for a common axes entity for parent
-        ax=[]
+        ax = []
         for k=1:size(curve_handles,"*")
-            a=curve_handles(k)
-            while a.type<>"Axes" then a=a.parent,end
-            if ax<>[]&a<>ax then
+            a = curve_handles(k)
+            while a.type<>"Axes" then a = a.parent,end
+            if ax<>[] & a<>ax then
                 error(msprintf(_("%s: Wrong value for input argument #%d: the handles must have the same parent.\n"),"datatipRemoveAll",1))
             end
-            ax=a
+            ax = a
         end
     else
         error(msprintf(_("%s: Wrong type for input argument #%d: handle on axes or axes children expected.\n"),"datatipRemoveAll",1))
     end
-
-    fig=ax.parent
-    id=fig.immediate_drawing;
-    fig.immediate_drawing="off"
-    for k=1:size(curve_handles,"*")
-        ck=curve_handles(k);
-
-        num = 1;
-        for t=1:size(ck.children,"*")
-            tip = ck.children(num);
-            if tip.type == "Datatip" then
-                datatipRemove(tip);
-            else
-                num = num + 1;
-            end
+    fig = ax.parent
+    id = fig.immediate_drawing;
+    fig.immediate_drawing = "off"
+    for k = 1:size(curve_handles,"*")
+        tips = curve_handles(k).datatips
+        for i = 1:size(tips,"*")
+            datatipRemove(tips(i))
         end
     end
-    fig.immediate_drawing=id
+    fig.immediate_drawing = id
 endfunction
diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_13881.dia.ref b/scilab/modules/graphics/tests/nonreg_tests/bug_13881.dia.ref
new file mode 100644 (file)
index 0000000..41e06fc
--- /dev/null
@@ -0,0 +1,33 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Vincent COUVERT
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+// <-- Non-regression test for bug 13881 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13881
+//
+// <-- Short Description -->
+// datatipRemoveAll does nothing
+x = linspace(0,1,100)';
+clf()
+plot(x,x.^3,"b",x,x.^2,"r");
+e = gce();
+e = e.children;
+datatipCreate(e(1),50);
+datatipCreate(e(2),20);
+datatipRemoveAll(e);
+assert_checktrue(size(e(1).datatips, "*")==0);
+assert_checktrue(size(e(2).datatips, "*")==0);
+clf
+plot(x,x.^3,"b",x,x.^2,"r");
+e = gce();
+e = e.children;
+datatipCreate(e(1),50);
+datatipCreate(e(2),20);
+datatipRemoveAll();
+assert_checktrue(size(e(1).datatips, "*")==0);
+assert_checktrue(size(e(2).datatips, "*")==0);
diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_13881.tst b/scilab/modules/graphics/tests/nonreg_tests/bug_13881.tst
new file mode 100644 (file)
index 0000000..c9ab2e3
--- /dev/null
@@ -0,0 +1,37 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Vincent COUVERT
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- TEST WITH GRAPHIC -->
+
+// <-- Non-regression test for bug 13881 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13881
+//
+// <-- Short Description -->
+// datatipRemoveAll does nothing
+
+x = linspace(0,1,100)';
+clf()
+plot(x,x.^3,"b",x,x.^2,"r");
+e = gce();
+e = e.children;
+datatipCreate(e(1),50);
+datatipCreate(e(2),20);
+datatipRemoveAll(e);
+assert_checktrue(size(e(1).datatips, "*")==0);
+assert_checktrue(size(e(2).datatips, "*")==0);
+
+clf
+plot(x,x.^3,"b",x,x.^2,"r");
+e = gce();
+e = e.children;
+datatipCreate(e(1),50);
+datatipCreate(e(2),20);
+datatipRemoveAll();
+assert_checktrue(size(e(1).datatips, "*")==0);
+assert_checktrue(size(e(2).datatips, "*")==0);
index 1657d7a..babdebd 100644 (file)
@@ -18,7 +18,6 @@ import java.awt.GraphicsEnvironment;
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.io.File;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -32,7 +31,6 @@ import java.util.UUID;
 import javax.swing.SwingUtilities;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathFactory;
 
 import org.flexdock.docking.Dockable;
 import org.flexdock.docking.DockingManager;
@@ -42,11 +40,14 @@ import org.flexdock.perspective.persist.xml.LayoutNodeSerializer;
 import org.flexdock.perspective.persist.xml.PersistenceConstants;
 import org.scilab.modules.commons.ScilabCommonsUtils;
 import org.scilab.modules.commons.ScilabConstants;
+import org.scilab.modules.commons.xml.ScilabXPathFactory;
 import org.scilab.modules.commons.xml.ScilabXMLUtilities;
 import org.scilab.modules.commons.xml.XConfiguration;
 import org.scilab.modules.commons.xml.XConfigurationEvent;
 import org.scilab.modules.commons.xml.XConfigurationListener;
+
 import static org.scilab.modules.commons.xml.XConfiguration.XConfAttribute;
+
 import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel;
 import org.scilab.modules.gui.bridge.window.SwingScilabWindow;
 import org.scilab.modules.gui.console.ScilabConsole;
@@ -167,7 +168,7 @@ public class WindowsConfigurationManager implements XConfigurationListener {
         try {
             Document doc = XConfiguration.getXConfigurationDocument();
             if (doc != null) {
-                XPath xp = XPathFactory.newInstance().newXPath();
+                XPath xp = ScilabXPathFactory.newInstance().newXPath();
                 NodeList nodes = (NodeList) xp.compile(LAYOUT_PATH + "/layout[@id=../@id]/@path").evaluate(doc, XPathConstants.NODESET);
                 if (nodes != null && nodes.getLength() > 0) {
                     return nodes.item(0).getNodeValue().replace("$SCI", System.getenv(SCI));
@@ -869,7 +870,7 @@ public class WindowsConfigurationManager implements XConfigurationListener {
     private static final void validateWindows() {
         // We remove all the blanks and carriage return
         try {
-            XPath xp = XPathFactory.newInstance().newXPath();
+            XPath xp = ScilabXPathFactory.newInstance().newXPath();
             NodeList nodes = (NodeList) xp.compile("//text()").evaluate(doc, XPathConstants.NODESET);
             for (int i = 0; i < nodes.getLength(); i++) {
                 nodes.item(i).getParentNode().removeChild(nodes.item(i));
index 5649ef6..404218c 100644 (file)
@@ -30,8 +30,9 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
-
 import org.scilab.modules.commons.xml.ScilabDocumentBuilderFactory;
+import org.scilab.modules.commons.xml.ScilabXPathFactory;
+import org.scilab.modules.commons.xml.ScilabXMLUtilities;
 
 /**
  * Utility class to ease the jar loading management.
@@ -63,7 +64,7 @@ public final class LoadClassPath {
         String xpathExpression = XPATH_EXPRS + "[@on='" + module + "']";
 
         // Initialize xpath
-        XPathFactory factory = XPathFactory.newInstance();
+        XPathFactory factory = ScilabXPathFactory.newInstance();
         XPath xpath = factory.newXPath();
 
         // initialize document factory
index 4d53383..b773b0f 100644 (file)
@@ -19,3 +19,8 @@ a = ones(1,2,3,4);
 m = mean(a,4);
 ref = ones(1,2,3,1);
 assert_checkequal(m, ref);
+// Bug #10059 (duplicate)
+a = matrix(1:12, [4, 1, 3]);
+assert_checkequal(sum(a, 3), [15;18;21;24]);
+a = matrix(1:24, [4, 2, 3]);
+assert_checkequal(sum(a, 3), [27 39;30 42;33 45;36 48]);
index ce244bd..f8779a8 100644 (file)
@@ -21,4 +21,11 @@ assert_checkequal(s, ref);
 a = ones(1,2,3,4);
 m = mean(a,4);
 ref = ones(1,2,3,1);
-assert_checkequal(m, ref);
\ No newline at end of file
+assert_checkequal(m, ref);
+
+// Bug #10059 (duplicate)
+a = matrix(1:12, [4, 1, 3]);
+assert_checkequal(sum(a, 3), [15;18;21;24]);
+
+a = matrix(1:24, [4, 2, 3]);
+assert_checkequal(sum(a, 3), [27 39;30 42;33 45;36 48]);
\ No newline at end of file
index 1b04857..ac572c1 100644 (file)
@@ -22,9 +22,11 @@ import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
 
 import org.w3c.dom.Document;
-
 import org.scilab.modules.commons.OS;
+
 import static org.scilab.modules.commons.xml.XConfiguration.XConfAttribute;
+
+import org.scilab.modules.commons.xml.ScilabXPathFactory;
 import org.scilab.modules.commons.xml.XConfiguration;
 
 /**
@@ -71,12 +73,12 @@ public class SciNotesOptions {
 
             if (eol.equals("")) {
                 switch (OS.get()) {
-                case WINDOWS:
-                    this.eol = ScilabDocument.EOLWIN;
-                    break;
-                default:
-                    this.eol = ScilabDocument.EOLUNIX;
-                    break;
+                    case WINDOWS:
+                        this.eol = ScilabDocument.EOLWIN;
+                        break;
+                    default:
+                        this.eol = ScilabDocument.EOLUNIX;
+                        break;
                 }
             } else if (eol.startsWith("Windows")) {
                 this.eol = ScilabDocument.EOLWIN;
@@ -212,7 +214,7 @@ public class SciNotesOptions {
         private void set(boolean enable) {
             this.enable = enable;
             if (enable) {
-                XPathFactory xpathFactory = XPathFactory.newInstance();
+                XPathFactory xpathFactory = ScilabXPathFactory.newInstance();
                 XPath xp = xpathFactory.newXPath();
                 try {
                     header = (String) xp.compile("string(" + HEADERPATH + ")").evaluate(doc, XPathConstants.STRING);
index 641993a..0fca867 100644 (file)
@@ -16,10 +16,7 @@ package org.scilab.modules.scinotes;
 import java.awt.Color;
 import java.awt.Font;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 import javax.swing.text.ViewFactory;
 import javax.swing.text.View;
@@ -34,6 +31,7 @@ import org.w3c.dom.NodeList;
 
 import static org.scilab.modules.commons.xml.XConfiguration.XConfAttribute;
 
+import org.scilab.modules.commons.xml.ScilabXPathFactory;
 import org.scilab.modules.commons.xml.XConfiguration;
 import org.scilab.modules.gui.utils.ScilabFontUtils;
 
@@ -92,7 +90,7 @@ public class ScilabContext implements ViewFactory {
 
 
     public static void saveFont(Font font) {
-        XPathFactory xpathFactory = XPathFactory.newInstance();
+        XPathFactory xpathFactory = ScilabXPathFactory.newInstance();
         XPath xp = xpathFactory.newXPath();
         NodeList nodes;
         Document doc = XConfiguration.getXConfigurationDocument();
diff --git a/scilab/modules/xcos/demos/ModelicaBlocks/Heat_conduction.zcos b/scilab/modules/xcos/demos/ModelicaBlocks/Heat_conduction.zcos
new file mode 100644 (file)
index 0000000..2f03405
Binary files /dev/null and b/scilab/modules/xcos/demos/ModelicaBlocks/Heat_conduction.zcos differ
diff --git a/scilab/modules/xcos/demos/ModelicaBlocks/Rotational_system.zcos b/scilab/modules/xcos/demos/ModelicaBlocks/Rotational_system.zcos
new file mode 100644 (file)
index 0000000..4d4d807
Binary files /dev/null and b/scilab/modules/xcos/demos/ModelicaBlocks/Rotational_system.zcos differ
diff --git a/scilab/modules/xcos/demos/ModelicaBlocks/modelica_heat_conduction.dem.sce b/scilab/modules/xcos/demos/ModelicaBlocks/modelica_heat_conduction.dem.sce
new file mode 100644 (file)
index 0000000..e2114e2
--- /dev/null
@@ -0,0 +1,6 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Paul Bignier
+//
+// This file is released under the 3-clause BSD license. See COPYING-BSD.
+
+xcos("SCI/modules/xcos/demos/ModelicaBlocks/Heat_conduction.zcos");
diff --git a/scilab/modules/xcos/demos/ModelicaBlocks/modelica_rotational_system.dem.sce b/scilab/modules/xcos/demos/ModelicaBlocks/modelica_rotational_system.dem.sce
new file mode 100644 (file)
index 0000000..4137a82
--- /dev/null
@@ -0,0 +1,6 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Paul Bignier
+//
+// This file is released under the 3-clause BSD license. See COPYING-BSD.
+
+xcos("SCI/modules/xcos/demos/ModelicaBlocks/Rotational_system.zcos");
index dbeca02..4fda6af 100644 (file)
@@ -10,7 +10,9 @@ if with_modelica_compiler() then
     _("Bouncing Ball")          , "ModelicaBlocks/modelica_bouncing_ball.dem.sce"  ; ..
     _("Chaos Modelica")         , "ModelicaBlocks/modelica_chaos.dem.sce"          ; ..
     _("Hydraulics blocks")      , "ModelicaBlocks/modelica_hydraulics.dem.sce"     ; ..
-    _("RLC circuit")            , "ModelicaBlocks/modelica_rlc_circuit.dem.sce"
+    _("RLC circuit")            , "ModelicaBlocks/modelica_rlc_circuit.dem.sce"    ; ..
+    _("Heat conduction in a rod")              , "ModelicaBlocks/modelica_heat_conduction.dem.sce"; ..
+    _("Second order rotational system")        , "ModelicaBlocks/modelica_rotational_system.dem.sce"
     ];
 
     subdemolist(:,2) = SCI + "/modules/xcos/demos/" + subdemolist(:,2);
index 58f8075..830eeea 100644 (file)
@@ -1717,6 +1717,10 @@ public class XcosDiagram extends ScilabGraph {
      * @return the identifier cell
      */
     public mxCell getOrCreateCellIdentifier(final mxCell cell) {
+        if (cell.getId().endsWith(HASH_IDENTIFIER)) {
+            return cell;
+        }
+
         final mxGraphModel graphModel = (mxGraphModel) getModel();
 
         final mxCell identifier;
index ecd0c14..c28ea71 100644 (file)
@@ -196,9 +196,15 @@ public class XcosDiagramCodec extends ScilabGraphCodec {
 
     /**
      * {@inheritDoc}
+     * <BR>
+     * <BR>
+     * <B>UPDATED TO COVER</B>
      *
-     * Strip out any node with an invalid parent id. (5.3.1 diagrams may
-     * contains invalid default parents, remove them.)
+     * <UL>
+     * <LI>Strip out any node with an invalid parent id. (5.3.1 diagrams may
+     * contains invalid default parents, remove them.)</LI>
+     * <LI>Remove cell where id end with "#identifier#identifier"</LI>
+     * </UL>
      */
     @Override
     public Node beforeDecode(mxCodec dec, Node node, Object obj) {
@@ -239,14 +245,20 @@ public class XcosDiagramCodec extends ScilabGraphCodec {
      */
     private void cleanUpNode(final Set<String> ids, final Collection<Node> trash, Node cell) {
         final Node id = cell.getAttributes().getNamedItem("id");
+        final String idValue = id.getNodeValue();
         final Node parent = cell.getAttributes().getNamedItem("parent");
 
         if (id instanceof Element) {
-            ids.add(id.getNodeValue());
+            ids.add(idValue);
         }
         if (parent instanceof Element && !ids.contains(parent.getNodeValue())) {
             trash.add(parent);
         }
+
+        // remove dual identifier cells
+        if (idValue.endsWith(XcosDiagram.HASH_IDENTIFIER + XcosDiagram.HASH_IDENTIFIER)) {
+            trash.add(cell);
+        }
     }
 
     /**
index a1c4600..14b54e7 100644 (file)
@@ -43,6 +43,7 @@ import javax.xml.xpath.XPathFactory;
 
 import org.scilab.modules.commons.xml.ScilabDocumentBuilderFactory;
 import org.scilab.modules.commons.xml.ScilabTransformerFactory;
+import org.scilab.modules.commons.xml.ScilabXPathFactory;
 import org.scilab.modules.types.ScilabList;
 import org.scilab.modules.xcos.graph.XcosDiagram;
 import org.w3c.dom.Document;
@@ -397,7 +398,7 @@ public class XcosPackage {
     public String getPackageVersion() {
         // cache the xpath expression
         if (XPATH_VERSION == null) {
-            final XPathFactory factory = XPathFactory.newInstance();
+            final XPathFactory factory = ScilabXPathFactory.newInstance();
             final XPath xpath = factory.newXPath();
 
             try {