From patchwork Sat Dec 27 19:13:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Zaretskii X-Patchwork-Id: 4443 Received: (qmail 3649 invoked by alias); 27 Dec 2014 19:13:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 3638 invoked by uid 89); 27 Dec 2014 19:13:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, HDRS_LCASE, RCVD_IN_DNSWL_NONE, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mtaout20.012.net.il Received: from mtaout20.012.net.il (HELO mtaout20.012.net.il) (80.179.55.166) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 27 Dec 2014 19:13:31 +0000 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0NH900F00901ZG00@a-mtaout20.012.net.il> for gdb-patches@sourceware.org; Sat, 27 Dec 2014 21:13:28 +0200 (IST) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NH900FEO9EFX450@a-mtaout20.012.net.il>; Sat, 27 Dec 2014 21:13:28 +0200 (IST) Date: Sat, 27 Dec 2014 21:13:17 +0200 From: Eli Zaretskii Subject: File-name completer marks all files as executable on MS-Windows To: Chet Ramey Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83egrklxde.fsf@gnu.org> X-IsSubscribed: yes 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 * 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); }