Re: [PATCH 06/24] Fix "set enum-command value garbage"

Sergio Durigan Junior
2019-05-23T19:13:16Z

On Wednesday, May 22 2019, Pedro Alves wrote:

> With enum commands, we currently fail to notice garbage 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
> Garbage after item: "foo"

I think it would be clearer to specify which item here, otherwise the
user might think that the item is "foo". Maybe:

Invalid data after item "compact": "foo"

What do you think? Otherwise, LGTM. Thanks.

> gdb/ChangeLog:
> yyyy-mm-dd Pedro Alves <palves@redhat.com>
>
> * cli/cli-setshow.c (do_set_command) <var_enum>: Detect garbage
> after item.
> ---
> gdb/cli/cli-setshow.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
> index 96d7bf5c3c0..9d6479ffca2 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);
>
> + arg = skip_spaces (arg + len);
> + if (*arg != '\0')
> + error (_("Garbage after item: \"%s\""), arg);
> +
> if (*(const char **) c->var != match)
> {
> *(const char **) c->var = match;
> --
> 2.14.5

--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible