[v2,06/24] Fix "set enum-command value garbage"
Commit Message
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 "compact": "foo"
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 | 5 +++++
1 file changed, 5 insertions(+)
Comments
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> (gdb) set print entry-values compact foo
Pedro> Garbage after item "compact": "foo"
In the crucial junk-vs-garbage wording war, junk is winning 9 to 2, so
perhaps its dominance should be continued.
I'm not totally sold on either of these phrasings but at the same time I
don't recall anybody ever complaining about them.
Tom
On 6/3/19 7:51 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>
> Pedro> (gdb) set print entry-values compact foo
> Pedro> Garbage after item "compact": "foo"
>
> In the crucial junk-vs-garbage wording war, junk is winning 9 to 2, so
> perhaps its dominance should be continued.
>
> I'm not totally sold on either of these phrasings but at the same time I
> don't recall anybody ever complaining about them.
Ahaha, yeah.. Just following the trend here. I've changed them to
say "junk", and adjusted the testcase as well.
Thanks,
Pedro Alves
@@ -413,6 +413,11 @@ 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 (_("Garbage after item \"%.*s\": \"%s\""),
+ len, arg, after);
+
if (*(const char **) c->var != match)
{
*(const char **) c->var = match;