aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli/cli-script.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-05-14 15:38:49 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-05-17 14:01:26 -0400
commit3d0b35641081d0f57d32583093f3297ff39b7379 (patch)
treefc6be36e7ce048ed74ce4597e0d365b1be4623d3 /gdb/cli/cli-script.c
parent1be99b11f8d1a8fd4049fee1c0eeaef73b3e6d1d (diff)
downloadbinutils-3d0b35641081d0f57d32583093f3297ff39b7379.zip
binutils-3d0b35641081d0f57d32583093f3297ff39b7379.tar.gz
binutils-3d0b35641081d0f57d32583093f3297ff39b7379.tar.bz2
gdb: add cmd_list_element::is_prefix
Same idea as the previous patch, but for prefix instead of alias. gdb/ChangeLog: * cli/cli-decode.h (cmd_list_element) <is_prefix>: New, use it. Change-Id: I76a9d2e82fc8d7429904424674d99ce6f9880e2b
Diffstat (limited to 'gdb/cli/cli-script.c')
-rw-r--r--gdb/cli/cli-script.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 5ddfab9..ff93523 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -1350,7 +1350,7 @@ validate_comname (const char **comname)
const char *tem = prefix.c_str ();
c = lookup_cmd (&tem, cmdlist, "", NULL, 0, 1);
- if (c->subcommands == NULL)
+ if (!c->is_prefix ())
error (_("\"%s\" is not a prefix command."), prefix.c_str ());
list = c->subcommands;
@@ -1414,7 +1414,7 @@ do_define_command (const char *comname, int from_tty,
/* if C is a prefix command that was previously defined,
tell the user its subcommands will be kept, and ask
if ok to redefine the command. */
- if (c->subcommands != nullptr)
+ if (c->is_prefix ())
q = (c->user_commands.get () == nullptr
|| query (_("Keeping subcommands of prefix command \"%s\".\n"
"Redefine command \"%s\"? "), c->name, c->name));
@@ -1595,7 +1595,7 @@ define_prefix_command (const char *comname, int from_tty)
if (c != nullptr && c->theclass != class_user)
error (_("Command \"%s\" is built-in."), comfull);
- if (c != nullptr && c->subcommands != nullptr)
+ if (c != nullptr && c->is_prefix ())
{
/* c is already a user defined prefix command. */
return;
@@ -1665,7 +1665,7 @@ show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name,
struct command_line *cmdlines = c->user_commands.get ();
fprintf_filtered (stream, "User %scommand \"",
- c->subcommands == NULL ? "" : "prefix ");
+ c->is_prefix () ? "prefix" : "");
fprintf_styled (stream, title_style.style (), "%s%s",
prefix, name);
fprintf_filtered (stream, "\":\n");
@@ -1676,12 +1676,12 @@ show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name,
}
}
- if (c->subcommands != NULL)
+ if (c->is_prefix ())
{
const std::string prefixname = c->prefixname ();
for (c = *c->subcommands; c != NULL; c = c->next)
- if (c->theclass == class_user || c->subcommands != NULL)
+ if (c->theclass == class_user || c->is_prefix ())
show_user_1 (c, prefixname.c_str (), c->name, gdb_stdout);
}