From: Pedro Alves Date: Wed, 12 Jun 2019 23:06:52 +0000 (+0100) Subject: Fix "set enum-command value junk" X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=48c410fb70fe09c036e27092880db687e5c2fb0b;p=deliverable%2Fbinutils-gdb.git Fix "set enum-command value junk" 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 * cli/cli-setshow.c (do_set_command) : Detect junk after item. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 38e34b5dfd..c254e36ec3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-06-13 Pedro Alves + + * cli/cli-setshow.c (do_set_command) : Detect junk + after item. + 2019-06-13 Pedro Alves * cli/cli-setshow.c (is_unlimited_literal): Allow abbreviations. diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index 96d7bf5c3c..86ebed45a4 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -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;