]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: improve escaping when completing filenames
authorAndrew Burgess <aburgess@redhat.com>
Tue, 20 Feb 2024 18:20:19 +0000 (18:20 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Sat, 7 Sep 2024 19:28:58 +0000 (20:28 +0100)
commit3503687591356ace0dcae967104952db467936ee
treec48242d53a0e361e910829e88a0e4f5745457372
parentdc22ab49e9b9a5d55d6608f662f808c6427600c4
gdb: improve escaping when completing filenames

This improves quoting and escaping when completing filenames for
commands that allow filenames to be quoted and escaped.

I've struggled a bit trying to split this series into chunks.  There's
a lot of dependencies between different parts of the completion
system, and trying to get this working correctly is pretty messy.

This first step is really about implementing 3 readline hooks:

  rl_char_is_quoted_p
    - Is a particular character quoted within readline's input buffer?
  rl_filename_dequoting_function
    - Remove quoting characters from a filename.
  rl_filename_quoting_function
    - Add quoting characters to a filename.

See 'info readline' for full details, but with these hooks connected
up, readline (on behalf of GDB) should do a better job inserting
backslash escapes when completing filenames.

There's still a bunch of stuff that doesn't work after this commit,
mostly around the 'complete' command which of course doesn't go
through readline, so doesn't benefit from all of these new functions
yet, I'll add some of this in a later commit.

Tab completion is now slightly improved though, it is possible to
tab-complete a filename that includes a double or single quote, either
in an unquoted string or within a string surrounded by single or
double quotes, backslash escaping is used when necessary.

There are some additional tests to cover the new functionality.
gdb/completer.c
gdb/testsuite/gdb.base/filename-completion.exp