This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
File-name completer marks all files as executable on MS-Windows
- From: Eli Zaretskii <eliz at gnu dot org>
- To: Chet Ramey <chet dot ramey at case dot edu>
- Cc: gdb-patches at sourceware dot org
- Date: Sat, 27 Dec 2014 21:13:17 +0200
- Subject: File-name completer marks all files as executable on MS-Windows
- Authentication-results: sourceware.org; auth=none
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
I discovered that completing on file names in GDB on MS-Windows marks
every file as executable. This is because Readline uses 'access' and
X_OK to determine that, which doesn't work on Windows.
Suggested patch is below.
2014-12-27 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.
--- readline/complete.c~0 2014-06-11 19:34:41.000000000 +0300
+++ readline/complete.c 2014-12-27 21:06:38.255053100 +0200
@@ -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);
}