]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: apply escaping to filenames in 'complete' results
authorAndrew Burgess <aburgess@redhat.com>
Fri, 23 Feb 2024 11:05:58 +0000 (11:05 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Sat, 7 Sep 2024 19:28:58 +0000 (20:28 +0100)
commitf2f866c6ca80e3f98deae2f2faabddab70a2163b
tree27a898f9a185be6e8a158084f87b5460e43236af
parent2bebc9ee2708086cec6c8dfd256c91184357ed2f
gdb: apply escaping to filenames in 'complete' results

Building on the mechanism added in the previous commit(s), this commit
applies escaping to filenames in the 'complete' command output.
Consider a file: /tmp/xxx/aa"bb -- that is a filename that contains a
double quote, currently the 'complete' command output looks like this:

  (gdb) complete file /tmp/xxx/a
  file /tmp/xxx/aa"bb

Notice that the double quote in the output is not escaped.  If we
passed this same output back to GDB then the double quote will be
treated as the start of a string.

After this commit then the output looks like this:

  (gdb) complete file /tmp/xxx/a
  file /tmp/xxx/aa\"bb

The double quote is now escaped.  If we feed this output back to GDB
then GDB will treat this as a single filename that contains a double
quote, exactly what we want.

To achieve this I've done a little refactoring, splitting out the core
of gdb_completer_file_name_quote, and then added a new call from the
filename_match_formatter function.

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