Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Fernando Nasser <fnasser@cygnus.com>
To: Eli Zaretskii <eliz@is.elta.co.il>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] File-name completion improvements
Date: Wed, 14 Feb 2001 10:35:00 -0000	[thread overview]
Message-ID: <3A8ACFD3.7700B474@cygnus.com> (raw)
In-Reply-To: <Pine.SUN.3.91.1010212095532.12969N-100000@is>

It is hard to imagine why 
list = (*c->completer) (p, word);
was before the break character list was set.  
Really weird.


Thanks for catching this.


Before committing, would you mind simplifying it a little bit.
Instead of changing this:
rl_completer_word_break_characters =
                         gdb_completer_file_name_break_characters;
into this:
char *fbc = gdb_completer_file_name_break_characters;
rl_completer_word_break_characters = fbc;
so you can use the shorthand here:
p > tmp_command && strchr (fbc, p[-1]) == NULL;
just use the full name:
p > tmp_command && strchr (gdb_completer_file_name_break_characters, \
                           p[-1]) == NULL;

I know, it is an awful long variable name.


After committing, please post the final version so it makes into the list archives.


Thanks again for the patch.
Fernando


Eli Zaretskii wrote:
> 
> I was never happy with GDB's completion: I think it doesn't quite help as
> much as it could.  For example, there are commands which mostly operate
> on files, but insist to complete on symbols instead.
> 
> So I will be submitting a series of patches to make this better.  But
> first, I need to make the file-name completion DTRT; currently, it
> doesn't.  For example, try "dir >foo TAB" or "dir foo:bar TAB" (assuming
> you have a directory or a file which begin with `foo' and `bar').
> 
> (Yes, I know "dir >foo" is nonsense, but GDB shouldn't prevent me from
> saying that; there are GDB commands which can use redirection near file
> names.)
> 
> The following patches correct several minor but annoying problems in
> file-name completion:
> 
>   - completion on a file name in a list of file names didn't work;
>   - GDB would not always append a slash if the completion is a directory;
>   - completion failed when the file name had non-file-name characters,
>     such as redirection, around it;
>   - on DOS/Windows, completion would fail with files with a drive letter.
> 
> Okay to commit?
> 
> 2001-02-12  Eli Zaretskii  <eliz@is.elta.co.il>
> 
>         * completer.c (gdb_completer_file_name_break_characters): Remove
>         slash from file-name break characters.
>         [__MSDOS__]: Special definition for DOS/Windows file names.
>         (line_completion_function): When completing on file names, bump
>         `p' to the first file-name constituent character of `word', before
>         invoking the completer.
> 
> --- gdb/completer.c~0   Fri Dec 15 03:01:46 2000
> +++ gdb/completer.c     Mon Feb 12 00:28:42 2001
> @@ -64,7 +64,13 @@ static char *gdb_completer_command_word_
>     break characters any characters that are commonly used in file
>     names, such as '-', '+', '~', etc.  Otherwise, readline displays
>     incorrect completion candidates.  */
> -static char *gdb_completer_file_name_break_characters = " \t\n*|\"';:?/><";
> +#ifdef __MSDOS__
> +/* MS-DOS and MS-Windows use colon as part of the drive spec, and most
> +   programs support @foo style response files.  */
> +static char *gdb_completer_file_name_break_characters = " \t\n*|\"';?><@";
> +#else
> +static char *gdb_completer_file_name_break_characters = " \t\n*|\"';:?><";
> +#endif
> 
>  /* Characters that can be used to quote completion strings.  Note that we
>     can't include '"' because the gdb C parser treats such quoted sequences
> @@ -348,10 +354,25 @@ line_completion_function (char *text, in
>                     {
>                       /* It is a normal command; what comes after it is
>                          completed by the command's completer function.  */
> -                     list = (*c->completer) (p, word);
>                       if (c->completer == filename_completer)
> -                       rl_completer_word_break_characters =
> -                         gdb_completer_file_name_break_characters;
> +                       {
> +                         char *fbc = gdb_completer_file_name_break_characters;
> +
> +                         /* Many commands which want to complete on
> +                            file names accept several file names, as
> +                            in "run foo bar >>baz".  So we don't want
> +                            to complete the entire text after the
> +                            command, just the last word.  To this
> +                            end, we need to find the beginning of the
> +                            file name starting at word and going
> +                            backwards.  */
> +                         for (p = word;
> +                              p > tmp_command && strchr (fbc, p[-1]) == NULL;
> +                              p--)
> +                           ;
> +                         rl_completer_word_break_characters = fbc;
> +                       }
> +                     list = (*c->completer) (p, word);
>                     }
>                 }
>               else
> @@ -397,10 +418,19 @@ line_completion_function (char *text, in
>               else
>                 {
>                   /* It is a normal command.  */
> -                 list = (*c->completer) (p, word);
>                   if (c->completer == filename_completer)
> -                   rl_completer_word_break_characters =
> -                     gdb_completer_file_name_break_characters;
> +                   {
> +                     char *fbc = gdb_completer_file_name_break_characters;
> +
> +                     /* See the commentary above about the specifics
> +                        of file-name completion.  */
> +                     for (p = word;
> +                          p > tmp_command && strchr (fbc, p[-1]) == NULL;
> +                          p--)
> +                       ;
> +                     rl_completer_word_break_characters = fbc;
> +                   }
> +                 list = (*c->completer) (p, word);
>                 }
>             }
>         }

-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


  reply	other threads:[~2001-02-14 10:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-12  0:18 Eli Zaretskii
2001-02-14 10:35 ` Fernando Nasser [this message]
2001-02-15  3:13   ` Eli Zaretskii
2001-02-17 23:05   ` Eli Zaretskii
2001-02-17 23:34     ` [RFA] More " Eli Zaretskii
2001-02-18  6:58       ` Fernando Nasser
2001-02-18  7:58         ` Eli Zaretskii
2001-02-18  8:40       ` Kevin Buettner
2001-02-18  9:56         ` Fernando Nasser
2001-02-18 10:39           ` Kevin Buettner
2001-02-18 10:49             ` Fernando Nasser
2001-02-18 12:22               ` Eli Zaretskii
2001-02-19  3:48               ` 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=3A8ACFD3.7700B474@cygnus.com \
    --to=fnasser@cygnus.com \
    --cc=eliz@is.elta.co.il \
    --cc=gdb-patches@sources.redhat.com \
    /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