diff options
-rw-r--r-- | gdb/completer.c | 21 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/filename-completion.exp | 12 |
2 files changed, 33 insertions, 0 deletions
diff --git a/gdb/completer.c b/gdb/completer.c index b0e999e..b80649c 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -321,6 +321,26 @@ gdb_completer_file_name_dequote (char *filename, int quote_char) return strdup (tmp.c_str ()); } +/* Implement readline's rl_directory_rewrite_hook. Remove any quoting from + the string *DIRNAME,update *DIRNAME, and return non-zero. If *DIRNAME + doesn't need updating then return zero. See readline docs for more + information. */ + +static int +gdb_completer_directory_rewrite (char **dirname) +{ + if (!rl_completion_found_quote) + return 0; + + int quote_char = rl_completion_quote_character; + char *new_dirname + = gdb_completer_file_name_dequote (*dirname, quote_char); + free (*dirname); + *dirname = new_dirname; + + return 1; +} + /* Apply character escaping to the filename in TEXT and return a newly allocated buffer containing the possibly updated filename. @@ -3416,6 +3436,7 @@ _initialize_completer () rl_filename_quote_characters = " \t\n\\\"'"; rl_filename_dequoting_function = gdb_completer_file_name_dequote; rl_filename_quoting_function = gdb_completer_file_name_quote; + rl_directory_rewrite_hook = gdb_completer_directory_rewrite; add_setshow_zuinteger_unlimited_cmd ("max-completions", no_class, &max_completions, _("\ diff --git a/gdb/testsuite/gdb.base/filename-completion.exp b/gdb/testsuite/gdb.base/filename-completion.exp index a4b411c..cf00d00 100644 --- a/gdb/testsuite/gdb.base/filename-completion.exp +++ b/gdb/testsuite/gdb.base/filename-completion.exp @@ -170,6 +170,11 @@ proc run_quoting_and_escaping_tests { root } { set dq "\\\"" } + test_gdb_complete_unique "${cmd} ${qc}${root}/bb2/dir${sp}1/" \ + "${cmd} ${qc}${root}/bb2/dir${sp}1/unique${sp}file${qc}" " " \ + false \ + "expand a unique file name in a directory containing a space" + test_gdb_complete_filename_multiple "$cmd ${qc}${root}/bb2/" \ "d" "ir${sp}" { "dir 1/" @@ -177,6 +182,13 @@ proc run_quoting_and_escaping_tests { root } { } "" "${qc}" false \ "expand multiple directory names containing spaces" + test_gdb_complete_filename_multiple "${cmd} ${qc}${root}/bb2/dir${sp}2/" \ + "f" "ile${sp}" { + "file 1" + "file 2" + } "" "${qc}" false \ + "expand contents of a directory containing a space" + test_gdb_complete_filename_multiple "$cmd ${qc}${root}/aaa/" \ "a" "a${sp}" { "aa bb" |