OBVIOUS Use report_unrecognized_option_error in 'demangle' and 'info macro' commands.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 27 Oct 2018 19:25:44 +0000 (21:25 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 27 Oct 2018 19:36:53 +0000 (21:36 +0200)
Rather than have some local logic to throw an error for an unrecognized option,
use the new cli-utils.h function throwing an error.

At the same time, fix some wrong indentation in info_macro_command
and fix a small bug in 'demangle' error handling:

Without the patch:
  (gdb) demangle -L c++ abcd
  Unrecognized option 'c++' to demangle command.  Try "help demangle".
  (gdb)

With the patch:
  (gdb) demangle -L c++ abcd
  Unrecognized option '-L' to demangle command.  Try "help demangle".

2018-10-27  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* macrocmd.c (info_macro_command): Use report_unrecognized_option_error
to report a bad option and fix indentation.
* demangle.c (demangle_command): Use report_unrecognized_option_error
to report a bad option and correctly report the bad option.

gdb/ChangeLog
gdb/demangle.c
gdb/macrocmd.c

index 2fb66c6..ff36b9b 100644 (file)
@@ -1,3 +1,10 @@
+2018-10-27  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
+
+       * macrocmd.c (info_macro_command): Use report_unrecognized_option_error
+       to report a bad option and fix indentation.
+       * demangle.c (demangle_command): Use report_unrecognized_option_error
+       to report a bad option and correctly report the bad option.
+
 2018-10-27  Tom Tromey  <tom@tromey.com>
 
        PR cli/23364:
index a37b065..8b341ee 100644 (file)
@@ -180,11 +180,7 @@ demangle_command (const char *args, int from_tty)
       else if (strncmp (arg_start, "--", p - arg_start) == 0)
        processing_args = 0;
       else
-       {
-         std::string option = extract_arg (&p);
-         error (_("Unrecognized option '%s' to demangle command.  "
-                  "Try \"help demangle\"."), option.c_str ());
-       }
+       report_unrecognized_option_error ("demangle", arg_start);
 
       arg_start = skip_spaces (p);
     }
index e6cf921..110423f 100644 (file)
@@ -199,13 +199,9 @@ info_macro_command (const char *args, int from_tty)
             e.g. Scheme's (defmacro ->foo () "bar\n")  */
        processing_args = 0;
       else
-       {
-         error (_("Unrecognized option '%.*s' to info macro command.  "
-                  "Try \"help info macro\"."),
-                int (p - arg_start), arg_start);
-       }
+       report_unrecognized_option_error ("info macro", arg_start);
 
-        arg_start = skip_spaces (p);
+      arg_start = skip_spaces (p);
     }
 
   name = arg_start;