From patchwork Tue Jun 4 22:34:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 32991 Received: (qmail 45751 invoked by alias); 4 Jun 2019 22:35:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 45697 invoked by uid 89); 4 Jun 2019 22:35:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=Printing X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Jun 2019 22:35:09 +0000 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 47CB9316290C for ; Tue, 4 Jun 2019 22:35:08 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF14E19C69 for ; Tue, 4 Jun 2019 22:35:07 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v3 06/24] Fix "set enum-command value junk" Date: Tue, 4 Jun 2019 23:34:26 +0100 Message-Id: <20190604223444.26472-7-palves@redhat.com> In-Reply-To: <20190604223444.26472-1-palves@redhat.com> References: <20190604223444.26472-1-palves@redhat.com> 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: yyyy-mm-dd Pedro Alves * cli/cli-setshow.c (do_set_command) : Detect junk 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..86ebed45a4a 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;