From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 02/12] Remove cleanup from display_gdb_prompt
Date: Thu, 28 Sep 2017 19:50:00 -0000 [thread overview]
Message-ID: <20170928195011.27382-3-tom@tromey.com> (raw)
In-Reply-To: <20170928195011.27382-1-tom@tromey.com>
This removes a cleanup from display_gdb_prompt by using std::string.
gdb/ChangeLog
2017-09-28 Tom Tromey <tom@tromey.com>
* event-top.c (top_level_prompt): Return std::string.
(display_gdb_prompt): Update.
---
gdb/ChangeLog | 5 +++++
gdb/event-top.c | 22 ++++++++--------------
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/gdb/event-top.c b/gdb/event-top.c
index b1cc8b9..17367ea 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -48,7 +48,7 @@
/* readline defines this. */
#undef savestring
-static char *top_level_prompt (void);
+static std::string top_level_prompt ();
/* Signal handlers. */
#ifdef SIGQUIT
@@ -352,16 +352,13 @@ gdb_rl_callback_handler_reinstall (void)
void
display_gdb_prompt (const char *new_prompt)
{
- char *actual_gdb_prompt = NULL;
- struct cleanup *old_chain;
+ std::string actual_gdb_prompt;
annotate_display_prompt ();
/* Reset the nesting depth used when trace-commands is set. */
reset_command_nest_depth ();
- old_chain = make_cleanup (free_current_contents, &actual_gdb_prompt);
-
/* Do not call the python hook on an explicit prompt change as
passed to this function, as this forms a secondary/local prompt,
IE, displayed but not set. */
@@ -391,7 +388,6 @@ display_gdb_prompt (const char *new_prompt)
if (current_ui->command_editing)
gdb_rl_callback_handler_remove ();
- do_cleanups (old_chain);
return;
}
else if (ui->prompt_state == PROMPT_NEEDED)
@@ -402,12 +398,12 @@ display_gdb_prompt (const char *new_prompt)
}
}
else
- actual_gdb_prompt = xstrdup (new_prompt);
+ actual_gdb_prompt = new_prompt;
if (current_ui->command_editing)
{
gdb_rl_callback_handler_remove ();
- gdb_rl_callback_handler_install (actual_gdb_prompt);
+ gdb_rl_callback_handler_install (actual_gdb_prompt.c_str ());
}
/* new_prompt at this point can be the top of the stack or the one
passed in. It can't be NULL. */
@@ -416,11 +412,9 @@ display_gdb_prompt (const char *new_prompt)
/* Don't use a _filtered function here. It causes the assumed
character position to be off, since the newline we read from
the user is not accounted for. */
- fputs_unfiltered (actual_gdb_prompt, gdb_stdout);
+ fputs_unfiltered (actual_gdb_prompt.c_str (), gdb_stdout);
gdb_flush (gdb_stdout);
}
-
- do_cleanups (old_chain);
}
/* Return the top level prompt, as specified by "set prompt", possibly
@@ -428,7 +422,7 @@ display_gdb_prompt (const char *new_prompt)
with the prompt prefix and suffix (annotations). The caller is
responsible for freeing the returned string. */
-static char *
+static std::string
top_level_prompt (void)
{
char *prompt;
@@ -448,10 +442,10 @@ top_level_prompt (void)
beginning. */
const char suffix[] = "\n\032\032prompt\n";
- return concat (prefix, prompt, suffix, (char *) NULL);
+ return std::string (prefix) + prompt + suffix;
}
- return xstrdup (prompt);
+ return prompt;
}
/* See top.h. */
--
2.9.5
next prev parent reply other threads:[~2017-09-28 19:50 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-28 19:50 [RFA 00/12] some minor cleanup removals Tom Tromey
2017-09-28 19:50 ` [RFA 06/12] Remove cleanups from cp-support.c Tom Tromey
2017-09-28 19:50 ` [RFA 05/12] Remove some cleanups from stack.c Tom Tromey
2017-09-28 22:06 ` Pedro Alves
2017-09-28 19:50 ` Tom Tromey [this message]
2017-09-28 21:56 ` [RFA 02/12] Remove cleanup from display_gdb_prompt Pedro Alves
2017-09-28 19:50 ` [RFA 11/12] Remove a cleanup from symtab.c Tom Tromey
2017-09-28 19:50 ` [RFA 09/12] Remove cleanup from xstormy16-tdep.c Tom Tromey
2017-09-28 19:50 ` [RFA 04/12] Remove cleanup from tilegx-tdep.c Tom Tromey
2017-09-28 22:00 ` Pedro Alves
2017-09-28 19:50 ` [RFA 01/12] Introduce string_vprintf Tom Tromey
2017-09-28 21:53 ` Pedro Alves
2017-09-29 2:38 ` Tom Tromey
2017-09-29 3:00 ` Tom Tromey
2017-09-29 10:25 ` Pedro Alves
2017-09-28 19:50 ` [RFA 08/12] Remove cleanup from complaints.c Tom Tromey
2017-09-28 22:09 ` Pedro Alves
2017-09-28 19:50 ` [RFA 12/12] Remove some unused declarations Tom Tromey
2017-09-28 19:50 ` [RFA 03/12] Remove cleanups from utils.c Tom Tromey
2017-09-28 22:00 ` Pedro Alves
2017-09-28 19:50 ` [RFA 10/12] Remove cleanup from mt-tdep.c Tom Tromey
2017-09-28 20:11 ` [RFA 07/12] Remove some cleanups from tracepoint.c Tom Tromey
2017-09-28 21:04 ` [RFA 00/12] some minor cleanup removals Sergio Durigan Junior
2017-09-28 22:11 ` Pedro Alves
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=20170928195011.27382-3-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