From patchwork Thu Sep 21 05:10:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 23045 Received: (qmail 67698 invoked by alias); 21 Sep 2017 05:41:33 -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 67522 invoked by uid 89); 21 Sep 2017 05:41:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Setting, 31897, 21487 X-HELO: gproxy10-pub.mail.unifiedlayer.com Received: from gproxy10-pub.mail.unifiedlayer.com (HELO gproxy10-pub.mail.unifiedlayer.com) (69.89.20.226) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Sep 2017 05:41:29 +0000 Received: from cmgw2 (unknown [10.0.90.83]) by gproxy10.mail.unifiedlayer.com (Postfix) with ESMTP id 49393140644 for ; Wed, 20 Sep 2017 23:41:28 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id C5hR1w01A2f2jeq015hULM; Wed, 20 Sep 2017 23:41:28 -0600 X-Authority-Analysis: v=2.2 cv=dZfw5Tfe c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=2JCJgTwv5E4A:10 a=zstS-IiYAAAA:8 a=sAa6H2vGdjgkRdXDfzgA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-76-94.hlrn.qwest.net ([75.166.76.94]:36574 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dutl1-00118R-IB; Wed, 20 Sep 2017 23:10:39 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 59/67] Constify some commands in infcmd.c Date: Wed, 20 Sep 2017 23:10:15 -0600 Message-Id: <20170921051023.19023-60-tom@tromey.com> In-Reply-To: <20170921051023.19023-1-tom@tromey.com> References: <20170921051023.19023-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dutl1-00118R-IB X-Source-Sender: 75-166-76-94.hlrn.qwest.net (bapiya.Home) [75.166.76.94]:36574 X-Source-Auth: tom+tromey.com X-Email-Count: 68 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes ChangeLog 2017-09-20 Tom Tromey * infcmd.c (environment_info, set_environment_command) (unset_environment_command, path_info, info_proc_cmd_1) (info_proc_cmd_mappings, info_proc_cmd_stat) (info_proc_cmd_status, info_proc_cmd_cwd, info_proc_cmd_cmdline) (info_proc_cmd_exe, info_proc_cmd_all): Constify. --- gdb/ChangeLog | 8 ++++++++ gdb/infcmd.c | 43 +++++++++++++++++-------------------------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 9c0cead..da16f5e 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -68,8 +68,6 @@ static void until_next_command (int); static void until_command (char *, int); -static void path_info (char *, int); - static void path_command (char *, int); static void unset_command (char *, int); @@ -78,12 +76,6 @@ static void info_float_command (char *, int); static void disconnect_command (char *, int); -static void unset_environment_command (char *, int); - -static void set_environment_command (char *, int); - -static void environment_info (char *, int); - static void info_program_command (char *, int); static void finish_command (char *, int); @@ -2148,7 +2140,7 @@ info_program_command (char *args, int from_tty) } static void -environment_info (char *var, int from_tty) +environment_info (const char *var, int from_tty) { if (var) { @@ -2181,9 +2173,9 @@ environment_info (char *var, int from_tty) } static void -set_environment_command (char *arg, int from_tty) +set_environment_command (const char *arg, int from_tty) { - char *p, *val, *var; + const char *p, *val; int nullset = 0; if (arg == 0) @@ -2230,21 +2222,20 @@ set_environment_command (char *arg, int from_tty) while (p != arg && (p[-1] == ' ' || p[-1] == '\t')) p--; - var = savestring (arg, p - arg); + std::string var (arg, p - arg); if (nullset) { printf_filtered (_("Setting environment variable " "\"%s\" to null value.\n"), - var); - current_inferior ()->environment.set (var, ""); + var.c_str ()); + current_inferior ()->environment.set (var.c_str (), ""); } else - current_inferior ()->environment.set (var, val); - xfree (var); + current_inferior ()->environment.set (var.c_str (), val); } static void -unset_environment_command (char *var, int from_tty) +unset_environment_command (const char *var, int from_tty) { if (var == 0) { @@ -2262,7 +2253,7 @@ unset_environment_command (char *var, int from_tty) static const char path_var_name[] = "PATH"; static void -path_info (char *args, int from_tty) +path_info (const char *args, int from_tty) { puts_filtered ("Executable and object file path: "); puts_filtered (current_inferior ()->environment.get (path_var_name)); @@ -3133,7 +3124,7 @@ unset_command (char *args, int from_tty) /* Implement `info proc' family of commands. */ static void -info_proc_cmd_1 (char *args, enum info_proc_what what, int from_tty) +info_proc_cmd_1 (const char *args, enum info_proc_what what, int from_tty) { struct gdbarch *gdbarch = get_current_arch (); @@ -3157,7 +3148,7 @@ info_proc_cmd (char *args, int from_tty) /* Implement `info proc mappings'. */ static void -info_proc_cmd_mappings (char *args, int from_tty) +info_proc_cmd_mappings (const char *args, int from_tty) { info_proc_cmd_1 (args, IP_MAPPINGS, from_tty); } @@ -3165,7 +3156,7 @@ info_proc_cmd_mappings (char *args, int from_tty) /* Implement `info proc stat'. */ static void -info_proc_cmd_stat (char *args, int from_tty) +info_proc_cmd_stat (const char *args, int from_tty) { info_proc_cmd_1 (args, IP_STAT, from_tty); } @@ -3173,7 +3164,7 @@ info_proc_cmd_stat (char *args, int from_tty) /* Implement `info proc status'. */ static void -info_proc_cmd_status (char *args, int from_tty) +info_proc_cmd_status (const char *args, int from_tty) { info_proc_cmd_1 (args, IP_STATUS, from_tty); } @@ -3181,7 +3172,7 @@ info_proc_cmd_status (char *args, int from_tty) /* Implement `info proc cwd'. */ static void -info_proc_cmd_cwd (char *args, int from_tty) +info_proc_cmd_cwd (const char *args, int from_tty) { info_proc_cmd_1 (args, IP_CWD, from_tty); } @@ -3189,7 +3180,7 @@ info_proc_cmd_cwd (char *args, int from_tty) /* Implement `info proc cmdline'. */ static void -info_proc_cmd_cmdline (char *args, int from_tty) +info_proc_cmd_cmdline (const char *args, int from_tty) { info_proc_cmd_1 (args, IP_CMDLINE, from_tty); } @@ -3197,7 +3188,7 @@ info_proc_cmd_cmdline (char *args, int from_tty) /* Implement `info proc exe'. */ static void -info_proc_cmd_exe (char *args, int from_tty) +info_proc_cmd_exe (const char *args, int from_tty) { info_proc_cmd_1 (args, IP_EXE, from_tty); } @@ -3205,7 +3196,7 @@ info_proc_cmd_exe (char *args, int from_tty) /* Implement `info proc all'. */ static void -info_proc_cmd_all (char *args, int from_tty) +info_proc_cmd_all (const char *args, int from_tty) { info_proc_cmd_1 (args, IP_ALL, from_tty); }