aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2024-02-21 11:28:31 +0000
committerAndrew Burgess <aburgess@redhat.com>2024-09-07 20:28:58 +0100
commit1d1df7539771d00721abe5dd8da4645e233ed3f5 (patch)
treeb18d09377f42fd0b6d6316e087c70ed13369d6c4 /gdb/cli
parent3503687591356ace0dcae967104952db467936ee (diff)
downloadbinutils-1d1df7539771d00721abe5dd8da4645e233ed3f5.zip
binutils-1d1df7539771d00721abe5dd8da4645e233ed3f5.tar.gz
binutils-1d1df7539771d00721abe5dd8da4645e233ed3f5.tar.bz2
gdb: move display of completion results into completion_result class
This commit moves the printing of the 'complete' command results out of the 'complete_command' function. The printing is now done in a new member function 'completion_result::print_matches'. At this point, this is entirely a refactor. The motivation for this refactor is how 'complete' should print the completion of filename arguments. In some cases the filename results need to have escaping added to the output. This escaping needs to be done immediately prior to printing the result as adding too early will result in multiple 'complete' results potentially being sorted incorrectly. See the subsequent commits for more details. There should be no user visible changes after this commit. Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-cmds.c26
1 files changed, 1 insertions, 25 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 58bb62e..fd8e277 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -423,31 +423,7 @@ complete_command (const char *arg, int from_tty)
{
std::string arg_prefix (arg, word - arg);
- if (result.number_matches == 1)
- printf_unfiltered ("%s%s\n", arg_prefix.c_str (), result.match_list[0]);
- else
- {
- result.sort_match_list ();
-
- for (size_t i = 0; i < result.number_matches; i++)
- {
- printf_unfiltered ("%s%s",
- arg_prefix.c_str (),
- result.match_list[i + 1]);
- if (quote_char)
- printf_unfiltered ("%c", quote_char);
- printf_unfiltered ("\n");
- }
- }
-
- if (result.number_matches == max_completions)
- {
- /* ARG_PREFIX and WORD are included in the output so that emacs
- will include the message in the output. */
- printf_unfiltered (_("%s%s %s\n"),
- arg_prefix.c_str (), word,
- get_max_completions_reached_message ());
- }
+ result.print_matches (arg_prefix, word, quote_char);
}
}