Message ID | 83egrklxde.fsf@gnu.org |
---|---|
State | New, archived |
Headers |
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: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> 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 <eliz@gnu.org> Subject: File-name completer marks all files as executable on MS-Windows To: Chet Ramey <chet.ramey@case.edu> Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii <eliz@gnu.org> Message-id: <83egrklxde.fsf@gnu.org> X-IsSubscribed: yes |
Commit Message
Eli Zaretskii
Dec. 27, 2014, 7:13 p.m. UTC
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.
Comments
On Sat, Dec 27, 2014 at 11:13 AM, Eli Zaretskii <eliz@gnu.org> 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 <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); > }
> Date: Sat, 27 Dec 2014 14:00:45 -0800 > From: Andrew Pinski <pinskia@gmail.com> > Cc: Chet Ramey <chet.ramey@case.edu>, > "gdb-patches@sourceware.org" <gdb-patches@sourceware.org> > > On Sat, Dec 27, 2014 at 11:13 AM, Eli Zaretskii <eliz@gnu.org> 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. That's why I CC'ed Chet.
On 12/27/14 2:13 PM, 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. Ugh, really? Thanks for the patch. Chet
> Date: Mon, 29 Dec 2014 10:38:45 -0500 > From: Chet Ramey <chet.ramey@case.edu> > CC: chet.ramey@case.edu, gdb-patches@sourceware.org > > On 12/27/14 2:13 PM, 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. > > Ugh, really? Thanks for the patch. Thanks for reviewing it. Joel, Pedro, others: can I now commit this to the GDB repository? Branch too?
On 12/29/14 11:22 AM, Eli Zaretskii wrote: >> Date: Mon, 29 Dec 2014 10:38:45 -0500 >> From: Chet Ramey <chet.ramey@case.edu> >> CC: chet.ramey@case.edu, gdb-patches@sourceware.org >> >> On 12/27/14 2:13 PM, 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. >> >> Ugh, really? Thanks for the patch. > > Thanks for reviewing it. > > Joel, Pedro, others: can I now commit this to the GDB repository? I am not certain of the exact vintage of the copy of readline in the GDB repository, but you should probably audit it and see whether or not this patch should use `fn' instead of `filename'.
> Date: Mon, 29 Dec 2014 11:46:48 -0500 > From: Chet Ramey <chet.ramey@case.edu> > CC: chet.ramey@case.edu, gdb-patches@sourceware.org > > I am not certain of the exact vintage of the copy of readline in the GDB > repository, but you should probably audit it and see whether or not this > patch should use `fn' instead of `filename'. OK, will do. Thanks.
On 12/29/2014 04:22 PM, Eli Zaretskii wrote: >> Date: Mon, 29 Dec 2014 10:38:45 -0500 >> From: Chet Ramey <chet.ramey@case.edu> >> CC: chet.ramey@case.edu, gdb-patches@sourceware.org >> >> On 12/27/14 2:13 PM, 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. >> >> Ugh, really? Thanks for the patch. > > Thanks for reviewing it. > > Joel, Pedro, others: can I now commit this to the GDB repository? > Branch too? Fine with me. Thanks, Pedro Alves
> Date: Mon, 29 Dec 2014 18:59:48 +0000 > From: Pedro Alves <palves@redhat.com> > CC: gdb-patches@sourceware.org > > On 12/29/2014 04:22 PM, Eli Zaretskii wrote: > >> Date: Mon, 29 Dec 2014 10:38:45 -0500 > >> From: Chet Ramey <chet.ramey@case.edu> > >> CC: chet.ramey@case.edu, gdb-patches@sourceware.org > >> > >> On 12/27/14 2:13 PM, 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. > >> > >> Ugh, really? Thanks for the patch. > > > > Thanks for reviewing it. > > > > Joel, Pedro, others: can I now commit this to the GDB repository? > > Branch too? > > Fine with me. Thanks, done.
--- 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); }