X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fmaint-test-options.c;h=9bda34a3fd2431665642f0004446d1dd3c6fd909;hb=708e4b9f189a86d542519b35e36e3f087b36b524;hp=7e7ef6e799261386af045e13b0ac20f76ba91d50;hpb=41fc454c915057d9c5536617370c5eb2a5f71323;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/maint-test-options.c b/gdb/maint-test-options.c index 7e7ef6e799..9bda34a3fd 100644 --- a/gdb/maint-test-options.c +++ b/gdb/maint-test-options.c @@ -58,10 +58,10 @@ readline, for proper testing of TAB completion. These maintenance commands support options of all the different - available kinds of commands (boolean, enum, flag, uinteger): + available kinds of commands (boolean, enum, flag, string, uinteger): (gdb) maint test-options require-delimiter -[TAB] - -bool -enum -flag -uinteger -xx1 -xx2 + -bool -enum -flag -string -uinteger -xx1 -xx2 (gdb) maint test-options require-delimiter -bool o[TAB] off on @@ -126,13 +126,23 @@ static const char *const test_options_enum_values_choices[] = struct test_options_opts { - int flag_opt = 0; - int xx1_opt = 0; - int xx2_opt = 0; - int boolean_opt = 0; + bool flag_opt = false; + bool xx1_opt = false; + bool xx2_opt = false; + bool boolean_opt = false; const char *enum_opt = test_options_enum_values_xxx; unsigned int uint_opt = 0; int zuint_unl_opt = 0; + char *string_opt = nullptr; + + test_options_opts () = default; + + DISABLE_COPY_AND_ASSIGN (test_options_opts); + + ~test_options_opts () + { + xfree (string_opt); + } /* Dump the options to FILE. ARGS is the remainder unprocessed arguments. */ @@ -140,7 +150,7 @@ struct test_options_opts { fprintf_unfiltered (file, _("-flag %d -xx1 %d -xx2 %d -bool %d " - "-enum %s -uint %s -zuint-unl %s -- %s\n"), + "-enum %s -uint %s -zuint-unl %s -string '%s' -- %s\n"), flag_opt, xx1_opt, xx2_opt, @@ -152,6 +162,9 @@ struct test_options_opts (zuint_unl_opt == -1 ? "unlimited" : plongest (zuint_unl_opt)), + (string_opt != nullptr + ? string_opt + : ""), args); } }; @@ -216,6 +229,14 @@ static const gdb::option::option_def test_options_option_defs[] = { nullptr, /* show_doc */ nullptr, /* help_doc */ }, + + /* A string option. */ + gdb::option::string_option_def { + "string", + [] (test_options_opts *opts) { return &opts->string_opt; }, + nullptr, /* show_cmd_cb */ + N_("A string option."), + }, }; /* Create an option_def_group for the test_options_opts options, with @@ -423,8 +444,8 @@ Command used for testing options processing.\n\ Usage: maint test-options require-delimiter [[OPTION]... --] [OPERAND]...\n\ \n\ Options:\n\ -\n\ %OPTIONS%\n\ +\n\ If you specify any command option, you must use a double dash (\"--\")\n\ to mark the end of option processing."), def_group); @@ -435,7 +456,6 @@ Command used for testing options processing.\n\ Usage: maint test-options unknown-is-error [OPTION]... [OPERAND]...\n\ \n\ Options:\n\ -\n\ %OPTIONS%"), def_group); @@ -445,7 +465,6 @@ Command used for testing options processing.\n\ Usage: maint test-options unknown-is-operand [OPTION]... [OPERAND]...\n\ \n\ Options:\n\ -\n\ %OPTIONS%"), def_group);