Sync up with r21-4-14-chise-0_21-2.
[chise/xemacs-chise.git] / src / dired-msw.c
index 791ed06..73c5d10 100644 (file)
@@ -173,7 +173,6 @@ mswindows_get_files (char *dirfile, int nowild, Lisp_Object pattern,
   int                          findex, len;
   char                         win32pattern[MAXNAMLEN+3];
   HANDLE                       fh;
-  int                          errm;
 
   /*
    * Much of the following code and comments were taken from dired.c.
@@ -215,8 +214,6 @@ mswindows_get_files (char *dirfile, int nowild, Lisp_Object pattern,
        */
       findex = 0;
       fh = INVALID_HANDLE_VALUE;
-      errm = SetErrorMode (SEM_FAILCRITICALERRORS
-                          | SEM_NOOPENFILEERRORBOX);
 
       while (1)
        {
@@ -229,7 +226,6 @@ mswindows_get_files (char *dirfile, int nowild, Lisp_Object pattern,
              fh = FindFirstFile(win32pattern, &files[findex]);
              if (fh == INVALID_HANDLE_VALUE)
                {
-                 SetErrorMode (errm);
                  report_file_error ("Opening directory",
                                     list1(build_string(dirfile)));
                }
@@ -243,7 +239,6 @@ mswindows_get_files (char *dirfile, int nowild, Lisp_Object pattern,
                      break;
                    }
                  FindClose(fh);
-                 SetErrorMode (errm);
                  report_file_error ("Reading directory",
                                     list1(build_string(dirfile)));
                }
@@ -282,8 +277,6 @@ mswindows_get_files (char *dirfile, int nowild, Lisp_Object pattern,
       *nfiles = findex;
       break;
     }
-
-  SetErrorMode (errm);
   return (files);
 }
 
@@ -435,8 +428,9 @@ switches do not contain `d', so that a full listing is expected.
        (file, switches, wildcard, full_directory_p))
 {
   Lisp_Object          result, handler, wildpat, fns, basename;
+  char                 *filename;
   char                 *switchstr;
-  int                  nfiles, i;
+  int                  len, nfiles, i;
   int                  hide_system, hide_dot, reverse, display_size;
   WIN32_FIND_DATA      *files, **sorted_files;
   enum mswindows_sortby        sort_by;
@@ -501,11 +495,28 @@ switches do not contain `d', so that a full listing is expected.
            }
        }
 
+      /*
+       * Sometimes we get ".../foo* /" as FILE (without the space).
+       * While the shell and `ls' don't mind, we certainly do,
+       * because it makes us think there is no wildcard, only a
+       * directory name.
+       */
+      if (!NILP(Fstring_match(build_string("[[?*]"), file, Qnil, Qnil)))
+       {
+         wildcard = Qt;
+         filename = XSTRING_DATA(file);
+         len = strlen(filename);
+         if (len > 0 && (filename[len - 1] == '\\' ||
+                         filename[len - 1] == '/'))
+           {
+             filename[len - 1] = '\0';
+           }
+         file = build_string(filename);
+       }
       if (!NILP(wildcard))
        {
          Lisp_Object   newfile;
 
-         file = Fdirectory_file_name (file);
          basename = Ffile_name_nondirectory(file);
          fns = intern("wildcard-to-regexp");
          wildpat = call1(fns, basename);