public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Chet Ramey <chet.ramey@case.edu>,
		"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: File-name completer marks all files as executable on MS-Windows
Date: Sat, 27 Dec 2014 22:00:00 -0000	[thread overview]
Message-ID: <CA+=Sn1=G8PSmQtGmVmtOqxYvB+Gt_WUOxOE0v1=vyWx3keZcHQ@mail.gmail.com> (raw)
In-Reply-To: <83egrklxde.fsf@gnu.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.

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);
>  }

  reply	other threads:[~2014-12-27 22:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-27 19:13 Eli Zaretskii
2014-12-27 22:00 ` Andrew Pinski [this message]
2014-12-28  3:38   ` Eli Zaretskii
2014-12-29 15:38 ` Chet Ramey
2014-12-29 16:22   ` Eli Zaretskii
2014-12-29 16:46     ` Chet Ramey
2014-12-29 17:34       ` Eli Zaretskii
2014-12-29 19:00     ` Pedro Alves
2014-12-30 19:30       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+=Sn1=G8PSmQtGmVmtOqxYvB+Gt_WUOxOE0v1=vyWx3keZcHQ@mail.gmail.com' \
    --to=pinskia@gmail.com \
    --cc=chet.ramey@case.edu \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).