* Bug 15067 fixed: adds D&D of XMI files 93/20893/7
Samuel GOUGEON [Fri, 1 Mar 2019 20:08:16 +0000 (21:08 +0100)]
  http://bugzilla.scilab.org/15067

  "*.xmi" added to the Console: File => Open file" selector
   at https://codereview.scilab.org/20895 (merged)

Change-Id: I9bea5666fb944eafab2677300a8b9e8186f4b59d

scilab/CHANGES.md
scilab/modules/console/src/c/dropFiles.c

index 1943026..7384bb0 100644 (file)
@@ -334,6 +334,7 @@ Bug Fixes
 * [#14900](https://bugzilla.scilab.org/14900): In Scilab 6.0, the new overloading code `function` replacing `mc` for functions in Scilab language was not documented.
 * [#14982](https://bugzilla.scilab.org/14982): `msprintf` segmentation fault was caught due to wrong size
 * [#14985](https://bugzilla.scilab.org/14985): Scilab crashed if a .bin file was not found.
+* [#15067](https://bugzilla.scilab.org/15067): `.xmi` files saved from Xcos could not be opened by drag & dropping them into the console.
 * [#15068](https://bugzilla.scilab.org/15068): `size(sum(ones(2,3,4,5),4))` was [4 2 3] instead of [2 3 4].
 * [#15087](https://bugzilla.scilab.org/15087): Deleting rows or columns from a matrix is slow (regression)
 * [#15200](https://bugzilla.scilab.org/15200): `weekday` yielded an error for some row of input dates.
index 2d506b8..f1e1314 100644 (file)
 #define BIN_EXTENSION_FILE ".bin"
 #define SAV_EXTENSION_FILE ".sav"
 #define COS_EXTENSION_FILE ".cos"
-#define XCOS_EXTENSION_FILE ".xcos"
 #define COSF_EXTENSION_FILE ".cosf"
+#define ZCOS_EXTENSION_FILE ".zcos"
+#define XCOS_EXTENSION_FILE ".xcos"
+#define XMI_EXTENSION_FILE ".xmi"
 #define SCI_EXTENSION_FILE ".sci"
 #define SCE_EXTENSION_FILE ".sce"
 #define TST_EXTENSION_FILE ".tst"
 #define DEM_EXTENSION_FILE ".dem"
 #define SCG_EXTENSION_FILE ".scg"
-#define ZCOS_EXTENSION_FILE ".zcos"
 #define SOD_EXTENSION_FILE ".sod"
 /*--------------------------------------------------------------------------*/
-#define FORMAT_BIN_SCE_EXTENSION_FILES "load('%s');"
-#define FORMAT_COS_COSF_XCOS_EXTENSION_FILES "xcos('%s');"
-#define FORMAT_SCI_EXTENSION_FILES "exec('%s');"
-#define FORMAT_SCE_TST_EXTENSION_FILES "exec('%s');"
-#define FORMAT_SCG_EXTENSION_FILES "load('%s');"
+#define FORMAT_LOAD_FILES "load('%s');"
+#define FORMAT_XCOS_FILES "xcos('%s');"
+#define FORMAT_EXEC_FILES "exec('%s');"
 #define FORMAT_UNKNOW_EXTENSION_FILES "disp(gettext('Unknown file type : %s'));"
 #define XCOS_NOT_INSTALLED "disp(gettext('Please install xcos module.'))"
 /*--------------------------------------------------------------------------*/
@@ -112,37 +111,34 @@ static char *getCommandByFileExtension(char *File, char *FileExtension)
 
     if (FileExtension)
     {
-        if ( (stricmp(FileExtension, BIN_EXTENSION_FILE) == 0) ||
-                (stricmp(FileExtension, SAV_EXTENSION_FILE) == 0) ||
-                (stricmp(FileExtension, SOD_EXTENSION_FILE) == 0))
+        if (stricmp(FileExtension, BIN_EXTENSION_FILE) == 0 ||
+            stricmp(FileExtension, SAV_EXTENSION_FILE) == 0 ||
+            stricmp(FileExtension, SOD_EXTENSION_FILE) == 0 ||
+            stricmp(FileExtension, SCG_EXTENSION_FILE) == 0)
         {
-            command = buildCommand(FORMAT_BIN_SCE_EXTENSION_FILES, File);
+            command = buildCommand(FORMAT_LOAD_FILES, File);
         }
-        else if ( (stricmp(FileExtension, COS_EXTENSION_FILE) == 0) ||
-                  (stricmp(FileExtension, COSF_EXTENSION_FILE) == 0) ||
-                  (stricmp(FileExtension, ZCOS_EXTENSION_FILE) == 0) ||
-                  (stricmp(FileExtension, XCOS_EXTENSION_FILE) == 0))
+        else if (stricmp(FileExtension, COS_EXTENSION_FILE) == 0 ||
+                 stricmp(FileExtension, COSF_EXTENSION_FILE) == 0 ||
+                 stricmp(FileExtension, ZCOS_EXTENSION_FILE) == 0 ||
+                 stricmp(FileExtension, XCOS_EXTENSION_FILE) == 0 ||
+                 stricmp(FileExtension, XMI_EXTENSION_FILE) == 0)
         {
             if (with_module(L"xcos"))
             {
-                command = buildCommand(FORMAT_COS_COSF_XCOS_EXTENSION_FILES, File);
+                command = buildCommand(FORMAT_XCOS_FILES, File);
             }
             else
             {
                 command = os_strdup(XCOS_NOT_INSTALLED);
             }
         }
-        else if (stricmp(FileExtension, SCI_EXTENSION_FILE) == 0)
-        {
-            command = buildCommand(FORMAT_SCI_EXTENSION_FILES, File);
-        }
-        else if ( (stricmp(FileExtension, SCE_EXTENSION_FILE) == 0) || (stricmp(FileExtension, TST_EXTENSION_FILE) == 0) || (stricmp(FileExtension, DEM_EXTENSION_FILE) == 0) )
-        {
-            command = buildCommand(FORMAT_SCE_TST_EXTENSION_FILES, File);
-        }
-        else if (stricmp(FileExtension, SCG_EXTENSION_FILE) == 0)
+        else if (stricmp(FileExtension, SCI_EXTENSION_FILE) == 0 ||
+                 stricmp(FileExtension, SCE_EXTENSION_FILE) == 0 ||
+                 stricmp(FileExtension, TST_EXTENSION_FILE) == 0 ||
+                 stricmp(FileExtension, DEM_EXTENSION_FILE) == 0)
         {
-            command = buildCommand(FORMAT_SCG_EXTENSION_FILES, File);
+            command = buildCommand(FORMAT_EXEC_FILES, File);
         }
         else
         {