* Bug #15472 fixed - mdelete('test') worked like mdelete('test.*') under Windows 43/19843/5
Adeline CARNIS [Mon, 12 Mar 2018 15:20:30 +0000 (16:20 +0100)]
Change-Id: Idf64b0a3b24187f92f70221598b1992e4d98b18e

scilab/CHANGES.md
scilab/modules/fileio/help/en_US/listfiles.xml
scilab/modules/fileio/help/ja_JP/listfiles.xml
scilab/modules/fileio/help/ru_RU/listfiles.xml
scilab/modules/fileio/macros/listfiles.sci
scilab/modules/fileio/tests/nonreg_tests/bug_15472.tst [new file with mode: 0644]

index 23267aa..e1a5f77 100644 (file)
@@ -565,6 +565,7 @@ Known issues
 * [#15458](http://bugzilla.scilab.org/show_bug.cgi?id=15458): `hist3d` rendering was wrong.
 * [#15464](http://bugzilla.scilab.org/show_bug.cgi?id=15464): Xcos C-blocks could not link dlls on Windows.
 * [#15468](http://bugzilla.scilab.org/show_bug.cgi?id=15468): Xcos saved file used non UTF-8 characters which lead to invalid file loading later.
+* [#15472](http://bugzilla.scilab.org/show_bug.cgi?id=15472): mdelete("test") worked like mdelete("test.*") under Windows 
 * [#15476](http://bugzilla.scilab.org/show_bug.cgi?id=15476): In the Electrical palette, the Resistor, Inductor, Capacitor, and ConstantVoltage icons did not show the parameter's value.
 * [#15484](http://bugzilla.scilab.org/show_bug.cgi?id=15484): On Windows, `isdir("w:")`, `isdir("w:/")`, and `isdir("w:\")` returned %T whenever the W: drive does not exist.
 * [#15489](http://bugzilla.scilab.org/show_bug.cgi?id=15489): Help pages of `covStart`, `covStop`, `covWrite` and `covMerge` were not built for the fr, ja, pt and ru languages, and were unreachable from a session in non `en_US` language.
index 1653e78..f01735e 100644 (file)
  * along with this program.
  *
  -->
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="listfiles">
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
+          xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
+          xml:lang="en" xml:id="listfiles">
     <refnamediv>
         <refname>listfiles</refname>
         <refpurpose>list of files</refpurpose>
@@ -87,15 +90,6 @@ files=listfiles(['SCI/modules/core/macros/*.sci';'SCI/modules/core/macros/*.bin'
  ]]>
         </programlisting>
     </refsection>
-    <refsection>
-        <title>History</title>
-        <revhistory>
-            <revision>
-                <revnumber>5.4.0</revnumber>
-                <revremark>If paths is not a single string, all returned files are homogenized with the absolute path form.</revremark>
-            </revision>
-        </revhistory>
-    </refsection>
     <refsection role="see also">
         <title>See also</title>
         <simplelist type="inline">
@@ -110,4 +104,20 @@ files=listfiles(['SCI/modules/core/macros/*.sci';'SCI/modules/core/macros/*.bin'
             </member>
         </simplelist>
     </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.4.0</revnumber>
+                <revremark>If paths is not a single string, all returned files are homogenized with the absolute path form.</revremark>
+            </revision>
+            <revision>
+                <revnumber>6.0.2</revnumber>
+                <revremark>
+                    Under Windows, up to 6.0.1, <literal>listfile("test")</literal> actually
+                    performed <literal>listfile("test.*")</literal>. It is no longer the case.
+                </revremark>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index 6fe6c92..60ce79f 100644 (file)
  *
  -->
 
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="ja" xml:id="listfiles">
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
+          xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
+          xml:lang="ja" xml:id="listfiles">
 
     <refnamediv>
 
@@ -223,6 +226,24 @@ files=listfiles(['SCI/modules/core/macros/*.sci';'SCI/modules/core/macros/*.bin'
         </simplelist>
 
     </refsection>
+    <refsection>
+        <title>履歴</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.4.0</revnumber>
+                <revremark>If paths is not a single string, all returned files are homogenized
+                  with the absolute path form.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>6.0.2</revnumber>
+                <revremark>
+                    Under Windows, up to 6.0.1, <literal>listfile("test")</literal> actually
+                    performed <literal>listfile("test.*")</literal>. It is no longer the case.
+                </revremark>
+            </revision>
+        </revhistory>
+    </refsection>
 
 </refentry>
 
index 1335a1a..09a8ce4 100644 (file)
  * along with this program.
  *
  -->
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="ru" xml:id="listfiles">
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
+          xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
+          xml:lang="ru" xml:id="listfiles">
     <refnamediv>
         <refname>listfiles</refname>
         <refpurpose>список файлов</refpurpose>
@@ -78,7 +81,9 @@
             файлов <varname>files</varname> относятся к этой директории.
         </para>
         <para>
-            Если входные пути содержат шаблон (например <literal>"/*"</literal>, <literal>"*.c"</literal>), то к возвращаемым именам файлов <varname>files</varname> добавляется начало входного пути.
+            Если входные пути содержат шаблон (например <literal>"/*"</literal>,
+            <literal>"*.c"</literal>), то к возвращаемым именам файлов <varname>files</varname>
+            добавляется начало входного пути.
         </para>
     </refsection>
     <refsection>
@@ -89,17 +94,6 @@ files=listfiles(['SCI/modules/core/macros/*.sci';'SCI/modules/core/macros/*.bin'
  ]]>
         </programlisting>
     </refsection>
-    <refsection>
-        <title>История</title>
-        <revhistory>
-            <revision>
-                <revnumber>5.4.0</revnumber>
-                <revremark>
-                    Если пути не являются одиночной строкой, то все возвращаемые файлы представляются единообразно в форме абсолютного пути.
-                </revremark>
-            </revision>
-        </revhistory>
-    </refsection>
     <refsection role="see also">
         <title>Смотрите также</title>
         <simplelist type="inline">
@@ -114,5 +108,24 @@ files=listfiles(['SCI/modules/core/macros/*.sci';'SCI/modules/core/macros/*.bin'
             </member>
         </simplelist>
     </refsection>
+    <refsection>
+        <title>История</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.4.0</revnumber>
+                <revremark>
+                    Если пути не являются одиночной строкой, то все возвращаемые файлы
+                    представляются единообразно в форме абсолютного пути.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>6.0.2</revnumber>
+                <revremark>
+                    Under Windows, up to 6.0.1, <literal>listfile("test")</literal> actually
+                    performed <literal>listfile("test.*")</literal>. It is no longer the case.
+                </revremark>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
 
index e5df196..d16c225 100644 (file)
@@ -49,28 +49,19 @@ function files= listfiles(paths,flag,flagexpand)
     end
 
     for i=1:size(paths,"*")  // Loop on the file/path list
-        [path,fname,extension]=fileparts(paths(i)); // Retrieve the information
-        // about the file
         if isdir(paths(i)) then // It is a directory then returns all the file in the dir
             path = paths(i) + filesep();
-            fname="*";
-            if bMulti then
-                if getos() == "Windows" // Don't want this case under Linux/Unix
-                    // Windows will return the file toto even if you provided toto.*
-                    extension=".*";
-                end
-            else
-                extension="";
+            fname = "*";
+            extension = "";
+        else //isfile
+            [path, fname, extension] = fileparts(paths(i)); // Retrieve the information
+            if path == "" then
+                path = "./";
             end
-        else
-            // It is a file
-            if path == "" then path="./",end;
-            if getos() == "Windows" // Don't want this case under Linux/Unix
-                // Windows will return the file toto even if you provided toto.*
-                if extension == "" then extension=".*",end;
+            
+            if fname == "" then
+                fname = "*";
             end
-
-            if fname == "" then fname="*",end;
         end
 
         filesi=findfiles(path,fname+extension);
diff --git a/scilab/modules/fileio/tests/nonreg_tests/bug_15472.tst b/scilab/modules/fileio/tests/nonreg_tests/bug_15472.tst
new file mode 100644 (file)
index 0000000..1206d97
--- /dev/null
@@ -0,0 +1,40 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2018 - ESI Group - Adeline CARNIS
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+//
+// <-- Non-regression test for bug 15472 -->
+//
+// http://bugzilla.scilab.org/show_bug.cgi?id=15472
+//
+// <-- Short Description -->
+// mdelete("test") worked like mdelete("test.*") under Windows 
+// =============================================================================
+// bug is in "listfiles" function and not directly mdelete.
+
+cd(TMPDIR);
+mputl("", "test");
+mputl("", "test2");
+mputl("", "test.sci");
+assert_checkequal(isfile(["test" "test2" "test.sci"]), [%t %t %t]);
+x = listfiles("test");
+assert_checkequal(x, "test");
+
+createdir("dir1");
+mputl("", "dir1/test");
+createdir("dir2");
+mputl("", "dir2/test");
+createdir("dir3");
+mputl("", "dir3/test");
+
+ref = [ fullfile("dir1", "test")
+        fullfile("dir2", "test")
+        fullfile("dir2", "test")]
+    
+x = listfiles(ref);
+assert_checkequal(x, ref);