From patchwork Thu May 30 19:53:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 32948 Received: (qmail 17084 invoked by alias); 30 May 2019 20:03:12 -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 17072 invoked by uid 89); 30 May 2019 20:03:12 -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= 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; Thu, 30 May 2019 20:03:11 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 556823082E20 for ; Thu, 30 May 2019 19:53:38 +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 E319D5D9E1 for ; Thu, 30 May 2019 19:53:37 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 04/24] Make check_for_argument skip whitespace after arg itself Date: Thu, 30 May 2019 20:53:13 +0100 Message-Id: <20190530195333.20448-5-palves@redhat.com> In-Reply-To: <20190530195333.20448-1-palves@redhat.com> References: <20190530195333.20448-1-palves@redhat.com> Basically every caller of check_for_argument needs to skip space after the argument. This patch makes check_for_argument do it itself. Suggested by Philippe Waroquiers gdb/ChangeLog: yyyy-mm-dd Pedro Alves * ax-gdb.c (agent_command_1): Remove skip_spaces call. * breakpoint.c (watch_maybe_just_location): Remove skip_spaces call. * cli/cli-utils.c (extract_info_print_args): Remove skip_spaces calls. (check_for_argument): Skip spaces after argument. --- gdb/ax-gdb.c | 2 -- gdb/breakpoint.c | 5 +---- gdb/cli/cli-utils.c | 3 +-- gdb/cli/cli-utils.h | 4 +++- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 778e89515b6..5872bec4777 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -2634,8 +2634,6 @@ agent_command_1 (const char *exp, int eval) { struct linespec_result canonical; - exp = skip_spaces (exp); - event_location_up location = new_linespec_location (&exp, symbol_name_match_type::WILD); decode_line_full (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL, diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 054bb1b13da..b85f7eedac8 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -10899,10 +10899,7 @@ watch_maybe_just_location (const char *arg, int accessflag, int from_tty) if (arg && (check_for_argument (&arg, "-location", sizeof ("-location") - 1) || check_for_argument (&arg, "-l", sizeof ("-l") - 1))) - { - arg = skip_spaces (arg); - just_location = 1; - } + just_location = 1; watch_command_1 (arg, accessflag, from_tty, just_location, 0); } diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c index c8b07f0b6bc..a24fe9278c7 100644 --- a/gdb/cli/cli-utils.c +++ b/gdb/cli/cli-utils.c @@ -139,7 +139,6 @@ extract_info_print_args (const char **args, /* Check for NAMEREGEXP or -- NAMEREGEXP. */ if (**args != '-' || check_for_argument (args, "--", 2)) { - *args = skip_spaces (*args); *regexp = *args; *args = NULL; return true; @@ -155,7 +154,6 @@ extract_info_print_args (const char **args, if (check_for_argument (args, "-q", 2)) { *quiet = true; - *args = skip_spaces (*args); return true; } @@ -459,6 +457,7 @@ check_for_argument (const char **str, const char *arg, int arg_len) && ((*str)[arg_len] == '\0' || isspace ((*str)[arg_len]))) { *str += arg_len; + *str = skip_spaces (*str); return 1; } return 0; diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h index d0161db0916..9425fb4c09d 100644 --- a/gdb/cli/cli-utils.h +++ b/gdb/cli/cli-utils.h @@ -188,7 +188,9 @@ extern std::string extract_arg (const char **arg); /* A helper function that looks for an argument at the start of a string. The argument must also either be at the end of the string, or be followed by whitespace. Returns 1 if it finds the argument, - 0 otherwise. If the argument is found, it updates *STR. */ + 0 otherwise. If the argument is found, it updates *STR to point + past the argument and past any whitespace following the + argument. */ extern int check_for_argument (const char **str, const char *arg, int arg_len); /* Same, for non-const STR. */