From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26609 invoked by alias); 27 Dec 2014 22:00:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 26594 invoked by uid 89); 27 Dec 2014 22:00:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-lb0-f179.google.com Received: from mail-lb0-f179.google.com (HELO mail-lb0-f179.google.com) (209.85.217.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 27 Dec 2014 22:00:49 +0000 Received: by mail-lb0-f179.google.com with SMTP id z11so9454719lbi.24 for ; Sat, 27 Dec 2014 14:00:46 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.152.228.164 with SMTP id sj4mr47641062lac.98.1419717645929; Sat, 27 Dec 2014 14:00:45 -0800 (PST) Received: by 10.25.21.9 with HTTP; Sat, 27 Dec 2014 14:00:45 -0800 (PST) In-Reply-To: <83egrklxde.fsf@gnu.org> References: <83egrklxde.fsf@gnu.org> Date: Sat, 27 Dec 2014 22:00:00 -0000 Message-ID: Subject: Re: File-name completer marks all files as executable on MS-Windows From: Andrew Pinski To: Eli Zaretskii Cc: Chet Ramey , "gdb-patches@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-12/txt/msg00644.txt.bz2 On Sat, Dec 27, 2014 at 11:13 AM, Eli Zaretskii wrote: > 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. Has this gone upstream to readline? Maybe it should go upstream first. Thanks, Andrew Pinski > > 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); > }