From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 06/10] Use std::string in do_set_command
Date: Tue, 29 Aug 2017 19:25:00 -0000 [thread overview]
Message-ID: <20170829192524.29971-7-tom@tromey.com> (raw)
In-Reply-To: <20170829192524.29971-1-tom@tromey.com>
Change do_set_command to use std::string, removing a cleanup and some
manual resizing code.
ChangeLog
2017-08-29 Tom Tromey <tom@tromey.com>
* cli/cli-setshow.c (do_set_command): Use std::string.
---
gdb/ChangeLog | 4 ++++
gdb/cli/cli-setshow.c | 16 ++++------------
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1d9ff74..0cf0fe9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2017-08-29 Tom Tromey <tom@tromey.com>
+ * cli/cli-setshow.c (do_set_command): Use std::string.
+
+2017-08-29 Tom Tromey <tom@tromey.com>
+
* cli/cli-cmds.c (cd_command): Use gdb::unique_xmalloc_ptr.
2017-08-29 Tom Tromey <tom@tromey.com>
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index fb0bd49..c6e5ebc 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -367,24 +367,16 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c)
message. */
if (arg == NULL)
{
- char *msg;
- int msg_len = 0;
-
- for (i = 0; c->enums[i]; i++)
- msg_len += strlen (c->enums[i]) + 2;
-
- msg = (char *) xmalloc (msg_len);
- *msg = '\0';
- make_cleanup (xfree, msg);
+ std::string msg;
for (i = 0; c->enums[i]; i++)
{
if (i != 0)
- strcat (msg, ", ");
- strcat (msg, c->enums[i]);
+ msg += ", ";
+ msg += c->enums[i];
}
error (_("Requires an argument. Valid arguments are %s."),
- msg);
+ msg.c_str ());
}
p = strchr (arg, ' ');
--
2.9.4
next prev parent reply other threads:[~2017-08-29 19:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-29 19:25 [RFA 00/10] some string cleanup removal Tom Tromey
2017-08-29 19:25 ` [RFA 01/10] Return std::string from memory_error_message Tom Tromey
2017-08-29 19:25 ` Tom Tromey [this message]
2017-08-29 19:25 ` [RFA 04/10] Use std::string in mi_cmd_interpreter_exec Tom Tromey
2017-08-29 19:25 ` [RFA 09/10] Use std::string and unique_xmalloc_ptr in compile/ code Tom Tromey
2017-08-30 18:24 ` Keith Seitz
2017-08-29 19:25 ` [RFA 05/10] Use unique_xmalloc_ptr in cd_command Tom Tromey
2017-08-29 19:25 ` [RFA 08/10] Return std::string from perror_string Tom Tromey
2017-08-29 19:25 ` [RFA 07/10] Use std::string and unique_xmalloc_ptr in demangle_command Tom Tromey
2017-08-29 19:36 ` [RFA 02/10] Use std::string thread.c Tom Tromey
2017-08-29 19:37 ` [RFA 03/10] Use unique_xmalloc_ptr in env_execute_cli_command Tom Tromey
2017-08-29 19:37 ` [RFA 10/10] Use std::string in reopen_exec_file Tom Tromey
2017-09-01 8:50 ` [RFA 00/10] some string cleanup removal Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170829192524.29971-7-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).