From patchwork Thu Jun 19 20:29:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 1577 Received: (qmail 22687 invoked by alias); 19 Jun 2014 20:29:56 -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 22570 invoked by uid 89); 19 Jun 2014 20:29:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 19 Jun 2014 20:29:54 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5JKTrwM021040 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 19 Jun 2014 16:29:53 -0400 Received: from barimba.redhat.com (ovpn-113-103.phx2.redhat.com [10.3.113.103]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5JKTonY004581; Thu, 19 Jun 2014 16:29:53 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/4] constify do_set_command and do_show_command Date: Thu, 19 Jun 2014 14:29:47 -0600 Message-Id: <1403209788-1015-4-git-send-email-tromey@redhat.com> In-Reply-To: <1403209788-1015-1-git-send-email-tromey@redhat.com> References: <1403209788-1015-1-git-send-email-tromey@redhat.com> This changes do_set_command and do_show_command to take const arguments. 2014-06-19 Tom Tromey * cli/cli-setshow.c (do_set_command): Make "arg" const. (do_show_command): Make "arg" const. * cli/cli-setshow.h (do_set_command, do_show_command): Update. --- gdb/ChangeLog | 6 ++++++ gdb/cli/cli-setshow.c | 12 +++++++----- gdb/cli/cli-setshow.h | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index d14d361..61ff085 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -148,7 +148,7 @@ is_unlimited_literal (const char *arg) other command). C is the command list element for the command. */ void -do_set_command (char *arg, int from_tty, struct cmd_list_element *c) +do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) { /* A flag to indicate the option is changed or not. */ int option_changed = 0; @@ -233,13 +233,15 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c) if (arg != NULL) { /* Clear trailing whitespace of filename. */ - char *ptr = arg + strlen (arg) - 1; + const char *ptr = arg + strlen (arg) - 1; + char *copy; while (ptr >= arg && (*ptr == ' ' || *ptr == '\t')) ptr--; - *(ptr + 1) = '\0'; + copy = xstrndup (arg, ptr + 1 - arg); - val = tilde_expand (arg); + val = tilde_expand (copy); + xfree (copy); } else val = xstrdup (""); @@ -564,7 +566,7 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c) other command). C is the command list element for the command. */ void -do_show_command (char *arg, int from_tty, struct cmd_list_element *c) +do_show_command (const char *arg, int from_tty, struct cmd_list_element *c) { struct ui_out *uiout = current_uiout; struct cleanup *old_chain; diff --git a/gdb/cli/cli-setshow.h b/gdb/cli/cli-setshow.h index a68d610..7619bad 100644 --- a/gdb/cli/cli-setshow.h +++ b/gdb/cli/cli-setshow.h @@ -23,9 +23,9 @@ struct cmd_list_element; Returns 1 for true, 0 for false, and -1 if invalid. */ extern int parse_cli_boolean_value (const char *arg); -extern void do_set_command (char *arg, int from_tty, +extern void do_set_command (const char *arg, int from_tty, struct cmd_list_element *c); -extern void do_show_command (char *arg, int from_tty, +extern void do_show_command (const char *arg, int from_tty, struct cmd_list_element *c); extern void cmd_show_list (struct cmd_list_element *list, int from_tty,