Fix build failure on macOS
[deliverable/binutils-gdb.git] / gdb / maint-test-options.c
index 7e7ef6e799261386af045e13b0ac20f76ba91d50..9bda34a3fd2431665642f0004446d1dd3c6fd909 100644 (file)
    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<test_options_opts> {
+    "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);
 
This page took 0.026931 seconds and 4 git commands to generate.