mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-27 09:38:57 +00:00
Make extract_arg return a std::string
Change extract_arg to return a std::string and fix up all the users. I think string is mildly better than unique_xmalloc_ptr<char>, when possible, because it provides a more robust API. I changed the error messages emitted from find_location_by_number to avoid either writing to a string or an extra allocation; this can be changed but I thought that the new message was not any less clear. You can see an example in the testsuite patch. ChangeLog 2017-09-11 Tom Tromey <tom@tromey.com> * demangle.c (demangle_command): Update. * breakpoint.c (disable_command): Update. (enable_command): Update. (find_location_by_number): Make "number" const. Use get_number_trailer. * cli/cli-utils.c (extract_arg): Return std::string. * probe.c (parse_probe_linespec): Update. Change types. (collect_probes): Take string arguments. (parse_probe_linespec): Likewise. (info_probes_for_ops): Update. (enable_probes_command): Update. (disable_probes_command): Update. * break-catch-sig.c (catch_signal_split_args): Update. * mi/mi-parse.c (mi_parse): Update. testsuite/ChangeLog 2017-09-11 Tom Tromey <tom@tromey.com> * gdb.base/ena-dis-br.exp (test_ena_dis_br): Update test.
This commit is contained in:
@@ -170,21 +170,21 @@ demangle_command (char *args, int from_tty)
|
||||
std::string arg_buf = args != NULL ? args : "";
|
||||
arg_start = arg_buf.c_str ();
|
||||
|
||||
gdb::unique_xmalloc_ptr<char> lang_name;
|
||||
std::string lang_name;
|
||||
while (processing_args
|
||||
&& *arg_start == '-')
|
||||
{
|
||||
const char *p = skip_to_space (arg_start);
|
||||
|
||||
if (strncmp (arg_start, "-l", p - arg_start) == 0)
|
||||
lang_name.reset (extract_arg (&p));
|
||||
lang_name = extract_arg (&p);
|
||||
else if (strncmp (arg_start, "--", p - arg_start) == 0)
|
||||
processing_args = 0;
|
||||
else
|
||||
{
|
||||
gdb::unique_xmalloc_ptr<char> option (extract_arg (&p));
|
||||
std::string option = extract_arg (&p);
|
||||
error (_("Unrecognized option '%s' to demangle command. "
|
||||
"Try \"help demangle\"."), option.get ());
|
||||
"Try \"help demangle\"."), option.c_str ());
|
||||
}
|
||||
|
||||
arg_start = skip_spaces (p);
|
||||
@@ -195,13 +195,13 @@ demangle_command (char *args, int from_tty)
|
||||
if (*name == '\0')
|
||||
error (_("Usage: demangle [-l language] [--] name"));
|
||||
|
||||
if (lang_name != NULL)
|
||||
if (!lang_name.empty ())
|
||||
{
|
||||
enum language lang_enum;
|
||||
|
||||
lang_enum = language_enum (lang_name.get ());
|
||||
lang_enum = language_enum (lang_name.c_str ());
|
||||
if (lang_enum == language_unknown)
|
||||
error (_("Unknown language \"%s\""), lang_name.get ());
|
||||
error (_("Unknown language \"%s\""), lang_name.c_str ());
|
||||
lang = language_def (lang_enum);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user