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.
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, _("\
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/"
} "" "${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"