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  <palves@redhat.com>

	* cli/cli-setshow.c (do_set_command) <var_enum>: Detect junk
	after item.
This commit is contained in:
Pedro Alves
2019-06-13 00:06:52 +01:00
parent 93bcb04349
commit 48c410fb70
2 changed files with 9 additions and 0 deletions

View 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;