]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix executable indicator in file name completion on Windows.
authorEli Zaretskii <eliz@gnu.org>
Tue, 30 Dec 2014 19:14:25 +0000 (21:14 +0200)
committerEli Zaretskii <eliz@gnu.org>
Tue, 30 Dec 2014 19:27:46 +0000 (21:27 +0200)
* complete.c (stat_char) [_WIN32]: Don't use 'access' and X_OK on
Windows, they don't work.  Instead, look at the file-name
extension to determine whether the file is executable.

readline/ChangeLog.gdb
readline/complete.c

index 1218fd7ee2d6613f6a51e3c63216e7eea86ff1aa..26fb2523aae8071293f77781c2344fb40e21a39d 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-30  Eli Zaretskii  <eliz@gnu.org>
+
+       * complete.c (stat_char) [_WIN32]: Don't use 'access' and X_OK on
+       Windows, they don't work.  Instead, look at the file-name
+       extension to determine whether the file is executable.
+
 2013-09-24  Pierre Muller  <muller@sourceware.org>
 
        * readline.c (bind_arrow_keys_internal):
index a9c46dfc15ee9e9c7ffe5468d270eb2a6c3ba79d..a5ce8039e5010ca9ce5193941f2ab386a87f39c2 100644 (file)
@@ -598,8 +598,21 @@ stat_char (filename)
 #endif
   else if (S_ISREG (finfo.st_mode))
     {
+#if defined (_WIN32) && !defined (__CYGWIN__)
+      /* Windows 'access' doesn't support X_OK and on latest Windows
+        versions even invokes an invalid parameter exception.  */
+      char *ext = strrchr (filename, '.');
+
+      if (ext
+         && (_rl_stricmp (ext, ".exe") == 0
+             || _rl_stricmp (ext, ".cmd") == 0
+             || _rl_stricmp (ext, ".bat") == 0
+             || _rl_stricmp (ext, ".com") == 0))
+       character = '*';
+#else
       if (access (filename, X_OK) == 0)
        character = '*';
+#endif
     }
   return (character);
 }