aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2014-12-30 21:14:25 +0200
committerEli Zaretskii <eliz@gnu.org>2014-12-30 21:14:25 +0200
commit05942d8a1b618e1c850b67ad76374f8c59743df5 (patch)
tree3b7b694a82d3890f6a336a6094c2a18085b92608 /readline
parentRemove "dll-symbols", "add-shared-symbol-files" and assf" commands. (diff)
downloadbinutils-gdb-05942d8a1b618e1c850b67ad76374f8c59743df5.tar.gz
binutils-gdb-05942d8a1b618e1c850b67ad76374f8c59743df5.tar.bz2
binutils-gdb-05942d8a1b618e1c850b67ad76374f8c59743df5.zip
Fix executable indicator in file name completion on Windows.
* 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.
Diffstat (limited to 'readline')
-rw-r--r--readline/ChangeLog.gdb6
-rw-r--r--readline/complete.c13
2 files changed, 19 insertions, 0 deletions
diff --git a/readline/ChangeLog.gdb b/readline/ChangeLog.gdb
index bd082e0fe68..43abd19e11c 100644
--- a/readline/ChangeLog.gdb
+++ b/readline/ChangeLog.gdb
@@ -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.
+
2014-09-22 Chen Gang <gang.chen.5i5j@gmail.com>
Pushed by Joel Brobecker <brobecker@adacore.com>
diff --git a/readline/complete.c b/readline/complete.c
index a9c46dfc15e..a5ce8039e50 100644
--- a/readline/complete.c
+++ b/readline/complete.c
@@ -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);
}