Fix "set enum-command value junk"
authorPedro Alves <palves@redhat.com>
Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 12 Jun 2019 23:09:37 +0000 (00:09 +0100)
With enum commands, we currently fail to notice junk after the value.

Currently:

  (gdb) set print entry-values compact foo
  (gdb) show print entry-values foo
  Printing of function arguments at function entry is "compact".

After this fix:

 (gdb) set print entry-values compact foo
  Junk after item "compact": foo

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

* cli/cli-setshow.c (do_set_command) <var_enum>: Detect junk
after item.

gdb/ChangeLog
gdb/cli/cli-setshow.c

index 38e34b5dfd0f544d7236f0461999b04e9e3eb7fa..c254e36ec37f6718e72d710304adcfadc3673936 100644 (file)
@@ -1,3 +1,8 @@
+2019-06-13  Pedro Alves  <palves@redhat.com>
+
+       * cli/cli-setshow.c (do_set_command) <var_enum>: Detect junk
+       after item.
+
 2019-06-13  Pedro Alves  <palves@redhat.com>
 
        * cli/cli-setshow.c (is_unlimited_literal): Allow abbreviations.
index 96d7bf5c3c0bb05534c0dcc864745a7c20af1b63..86ebed45a4a14cc4ae1b97272c8854d1d60316cc 100644 (file)
@@ -413,6 +413,10 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c)
        if (nmatches > 1)
          error (_("Ambiguous item \"%s\"."), arg);
 
+       const char *after = skip_spaces (arg + len);
+       if (*after != '\0')
+         error (_("Junk after item \"%.*s\": %s"), len, arg, after);
+
        if (*(const char **) c->var != match)
          {
            *(const char **) c->var = match;
This page took 0.033351 seconds and 4 git commands to generate.