From e6ed716cd5514c08b9d7c469d185b1aa177dbc22 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 13 Jun 2019 00:06:53 +0100 Subject: Migrate rest of compile commands to new options framework As I was in the neighbourhood, I converted the other "compile" subcommands to the new options framework too. Specifically, "compile code" and "compile file". The user-visible changes are: - All abbreviations of "-raw" are accepted now, instead of just -r. Obviously that means "-ra" is now accepted. - Option completion now works. - "compile file" did not have a completer yet, and now it knows to complete on filenames. - You couldn't use "compile file" with a file named "-something". You can now, with "compile file -- -something". gdb/ChangeLog: 2019-06-13 Pedro Alves * compile/compile.c (struct compile_options): New. (compile_flag_option_def, compile_command_option_defs) (make_compile_options_def_group): New. (compile_file_command): Handle options with gdb::option::process_options. (compile_file_command_completer): New function. (compile_code_command): Handle options with gdb::option::process_options. (compile_code_command_completer): New function. (_initialize_compiler): Install completers for "compile code" and "compile file". Mention available options in "compile code" and "compile code"'s help. * completer.c (advance_to_completion_word): New, factored out from ... (advance_to_expression_complete_word_point): ... this. (advance_to_filename_complete_word_point): New. * completer.h (advance_to_filename_complete_word_point): New declaration. gdb/testsuite/ChangeLog: 2019-06-13 Pedro Alves * gdb.compile/compile.exp: Adjust expected output to option processing changes. --- gdb/completer.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'gdb/completer.c') diff --git a/gdb/completer.c b/gdb/completer.c index 5dd9a99..0f4e7f9 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -352,16 +352,18 @@ gdb_rl_find_completion_word (struct gdb_rl_completion_word_info *info, return line_buffer + point; } -/* See completer.h. */ +/* Find the completion word point for TEXT, emulating the algorithm + readline uses to find the word point, using WORD_BREAK_CHARACTERS + as word break characters. */ -const char * -advance_to_expression_complete_word_point (completion_tracker &tracker, - const char *text) +static const char * +advance_to_completion_word (completion_tracker &tracker, + const char *word_break_characters, + const char *text) { gdb_rl_completion_word_info info; - info.word_break_characters - = current_language->la_word_break_characters (); + info.word_break_characters = word_break_characters; info.quote_characters = gdb_completer_quote_characters; info.basic_quote_characters = rl_basic_quote_characters; @@ -382,6 +384,26 @@ advance_to_expression_complete_word_point (completion_tracker &tracker, /* See completer.h. */ +const char * +advance_to_expression_complete_word_point (completion_tracker &tracker, + const char *text) +{ + const char *brk_chars = current_language->la_word_break_characters (); + return advance_to_completion_word (tracker, brk_chars, text); +} + +/* See completer.h. */ + +const char * +advance_to_filename_complete_word_point (completion_tracker &tracker, + const char *text) +{ + const char *brk_chars = gdb_completer_file_name_break_characters; + return advance_to_completion_word (tracker, brk_chars, text); +} + +/* See completer.h. */ + bool completion_tracker::completes_to_completion_word (const char *word) { -- cgit v1.1