struct cmd_list_element **cmd,
struct cmd_list_element *cur_list);
-/* Look up a command whose 'prefixlist' is KEY. Return the command if found,
- otherwise return NULL. */
+/* Look up a command whose 'subcommands' field is SUBCOMMANDS. Return the
+ command if found, otherwise return NULL. */
static struct cmd_list_element *
-lookup_cmd_for_prefixlist (struct cmd_list_element **key,
- struct cmd_list_element *list)
+lookup_cmd_with_subcommands (cmd_list_element **subcommands,
+ cmd_list_element *list)
{
struct cmd_list_element *p = NULL;
{
struct cmd_list_element *q;
- if (p->prefixlist == NULL)
+ if (p->subcommands == NULL)
continue;
- else if (p->prefixlist == key)
+ else if (p->subcommands == subcommands)
{
/* If we found an alias, we must return the aliased
command. */
return p->cmd_pointer ? p->cmd_pointer : p;
}
- q = lookup_cmd_for_prefixlist (key, *(p->prefixlist));
+ q = lookup_cmd_with_subcommands (subcommands, *(p->subcommands));
if (q != NULL)
return q;
}
std::string
cmd_list_element::prefixname () const
{
- if (this->prefixlist == nullptr)
+ if (this->subcommands == nullptr)
/* Not a prefix command. */
return "";
/* Search the prefix cmd of C, and assigns it to C->prefix.
See also add_prefix_cmd and update_prefix_field_of_prefixed_commands. */
- struct cmd_list_element *prefixcmd = lookup_cmd_for_prefixlist (list,
- cmdlist);
+ cmd_list_element *prefixcmd = lookup_cmd_with_subcommands (list, cmdlist);
c->prefix = prefixcmd;
/* NOTE: Both FUNC and all the FUNCTIONs need to be copied. */
c->func = old->func;
c->function = old->function;
- c->prefixlist = old->prefixlist;
+ c->subcommands = old->subcommands;
c->allow_unknown = old->allow_unknown;
c->abbrev_flag = abbrev_flag;
c->cmd_pointer = old;
static void
update_prefix_field_of_prefixed_commands (struct cmd_list_element *c)
{
- for (cmd_list_element *p = *c->prefixlist; p != NULL; p = p->next)
+ for (cmd_list_element *p = *c->subcommands; p != NULL; p = p->next)
{
p->prefix = c;
In such a case, when 'auto-load' was created by do_add_cmd,
the 'libthread-db' prefix field could not be updated, as the
'auto-load' command was not yet reachable by
- lookup_cmd_for_prefixlist (list, cmdlist)
+ lookup_cmd_for_subcommands (list, cmdlist)
that searches from the top level 'cmdlist'. */
- if (p->prefixlist != nullptr)
+ if (p->subcommands != nullptr)
update_prefix_field_of_prefixed_commands (p);
}
}
/* Like add_cmd but adds an element for a command prefix: a name that
should be followed by a subcommand to be looked up in another
- command list. PREFIXLIST should be the address of the variable
+ command list. SUBCOMMANDS should be the address of the variable
containing that list. */
struct cmd_list_element *
add_prefix_cmd (const char *name, enum command_class theclass,
cmd_const_cfunc_ftype *fun,
- const char *doc, struct cmd_list_element **prefixlist,
+ const char *doc, struct cmd_list_element **subcommands,
int allow_unknown, struct cmd_list_element **list)
{
struct cmd_list_element *c = add_cmd (name, theclass, fun, doc, list);
- c->prefixlist = prefixlist;
+ c->subcommands = subcommands;
c->allow_unknown = allow_unknown;
/* Now that prefix command C is defined, we need to set the prefix field
while (c->cmd_pointer != nullptr)
c = c->cmd_pointer;
- help_list (*c->prefixlist, c->prefixname ().c_str (),
+ help_list (*c->subcommands, c->prefixname ().c_str (),
all_commands, gdb_stdout);
}
struct cmd_list_element *
add_basic_prefix_cmd (const char *name, enum command_class theclass,
- const char *doc, struct cmd_list_element **prefixlist,
+ const char *doc, struct cmd_list_element **subcommands,
int allow_unknown, struct cmd_list_element **list)
{
struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr,
- doc, prefixlist,
+ doc, subcommands,
allow_unknown, list);
set_cmd_sfunc (cmd, do_prefix_cmd);
return cmd;
static void
do_show_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c)
{
- cmd_show_list (*c->prefixlist, from_tty);
+ cmd_show_list (*c->subcommands, from_tty);
}
/* See command.h. */
struct cmd_list_element *
add_show_prefix_cmd (const char *name, enum command_class theclass,
- const char *doc, struct cmd_list_element **prefixlist,
+ const char *doc, struct cmd_list_element **subcommands,
int allow_unknown, struct cmd_list_element **list)
{
struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr,
- doc, prefixlist,
+ doc, subcommands,
allow_unknown, list);
set_cmd_sfunc (cmd, do_show_prefix_cmd);
return cmd;
add_prefix_cmd_suppress_notification
(const char *name, enum command_class theclass,
cmd_const_cfunc_ftype *fun,
- const char *doc, struct cmd_list_element **prefixlist,
+ const char *doc, struct cmd_list_element **subcommands,
int allow_unknown, struct cmd_list_element **list,
int *suppress_notification)
{
struct cmd_list_element *element
- = add_prefix_cmd (name, theclass, fun, doc, prefixlist,
+ = add_prefix_cmd (name, theclass, fun, doc, subcommands,
allow_unknown, list);
element->suppress_notification = suppress_notification;
return element;
struct cmd_list_element *
add_abbrev_prefix_cmd (const char *name, enum command_class theclass,
cmd_const_cfunc_ftype *fun, const char *doc,
- struct cmd_list_element **prefixlist,
+ struct cmd_list_element **subcommands,
int allow_unknown, struct cmd_list_element **list)
{
struct cmd_list_element *c = add_cmd (name, theclass, fun, doc, list);
- c->prefixlist = prefixlist;
+ c->subcommands = subcommands;
c->allow_unknown = allow_unknown;
c->abbrev_flag = 1;
return c;
print_doc_of_command (c, prefix, verbose, regex, stream);
}
/* Check if this command has subcommands. */
- if (c->prefixlist != NULL)
+ if (c->subcommands != NULL)
{
/* Recursively call ourselves on the subcommand list,
passing the right prefix in. */
- apropos_cmd (stream, *c->prefixlist, verbose, regex,
+ apropos_cmd (stream, *c->subcommands, verbose, regex,
c->prefixname ().c_str ());
}
}
lookup_cmd_composition (orig_command, &alias, &prefix_cmd, &c_cmd);
/* There are three cases here.
- If c->prefixlist is nonzero, we have a prefix command.
+ If c->subcommands is nonzero, we have a prefix command.
Print its documentation, then list its subcommands.
If c->func is non NULL, we really have a command. Print its
fputs_filtered (c->doc, stream);
fputs_filtered ("\n", stream);
- if (c->prefixlist == 0 && c->func != NULL)
+ if (c->subcommands == 0 && c->func != NULL)
return;
fprintf_filtered (stream, "\n");
/* If this is a prefix command, print it's subcommands. */
- if (c->prefixlist)
- help_list (*c->prefixlist, c->prefixname ().c_str (),
+ if (c->subcommands)
+ help_list (*c->subcommands, c->prefixname ().c_str (),
all_commands, stream);
/* If this is a class name, print all of the commands in the class. */
fput_aliases_definition_styled (c, stream);
if (recurse
- && c->prefixlist != 0
+ && c->subcommands != 0
&& c->abbrev_flag == 0)
/* Subcommands of a prefix command typically have 'all_commands'
as class. If we pass CLASS to recursive invocation,
most often we won't see anything. */
- help_cmd_list (*c->prefixlist, all_commands, true, stream);
+ help_cmd_list (*c->subcommands, all_commands, true, stream);
}
/*
if (recurse
&& (theclass == class_user || theclass == class_alias)
- && c->prefixlist != NULL)
+ && c->subcommands != NULL)
{
/* User-defined commands or aliases may be subcommands. */
- help_cmd_list (*c->prefixlist, theclass, recurse, stream);
+ help_cmd_list (*c->subcommands, theclass, recurse, stream);
continue;
}
}
/* If we found a prefix command, keep looking. */
- if (found->prefixlist)
+ if (found->subcommands)
{
- c = lookup_cmd_1 (text, *found->prefixlist, result_list, default_args,
+ c = lookup_cmd_1 (text, *found->subcommands, result_list, default_args,
ignore_help_classes, lookup_for_completion_p);
if (!c)
{
we've found (if an inferior hasn't already set it). */
if (result_list != nullptr)
if (!*result_list)
- /* This used to say *result_list = *found->prefixlist.
+ /* This used to say *result_list = *found->subcommands.
If that was correct, need to modify the documentation
at the top of this function to clarify what is
supposed to be going on. */
}
else if (c == CMD_LIST_AMBIGUOUS)
{
- /* Ambigous. Local values should be off prefixlist or called
+ /* Ambigous. Local values should be off subcommands or called
values. */
int local_allow_unknown = (last_list ? last_list->allow_unknown :
allow_unknown);
std::string local_cmdtype
= last_list ? last_list->prefixname () : cmdtype;
struct cmd_list_element *local_list =
- (last_list ? *(last_list->prefixlist) : list);
+ (last_list ? *(last_list->subcommands) : list);
if (local_allow_unknown < 0)
{
while (**line == ' ' || **line == '\t')
(*line)++;
- if (c->prefixlist && **line && !c->allow_unknown)
+ if (c->subcommands && **line && !c->allow_unknown)
undef_cmd_error (c->prefixname ().c_str (), *line);
/* Seems to be what he wants. Return it. */
text += len;
text = skip_spaces (text);
- if ((*cmd)->prefixlist != nullptr && *text != '\0')
+ if ((*cmd)->subcommands != nullptr && *text != '\0')
{
- cur_list = *(*cmd)->prefixlist;
+ cur_list = *(*cmd)->subcommands;
*prefix_cmd = *cmd;
}
else
if (!strncmp (ptr->name, text, textlen)
&& !ptr->abbrev_flag
&& (!ignore_help_classes || ptr->func
- || ptr->prefixlist))
+ || ptr->subcommands))
{
if (pass == 0)
{
const char *tem = prefix.c_str ();
c = lookup_cmd (&tem, cmdlist, "", NULL, 0, 1);
- if (c->prefixlist == NULL)
+ if (c->subcommands == NULL)
error (_("\"%s\" is not a prefix command."), prefix.c_str ());
- list = c->prefixlist;
+ list = c->subcommands;
*comname = last_word;
}
/* 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->prefixlist != nullptr)
+ if (c->subcommands != nullptr)
q = (c->user_commands.get () == nullptr
|| query (_("Keeping subcommands of prefix command \"%s\".\n"
"Redefine command \"%s\"? "), c->name, c->name));
cmds = *commands;
{
- struct cmd_list_element **c_prefixlist
- = c == nullptr ? nullptr : c->prefixlist;
+ struct cmd_list_element **c_subcommands
+ = c == nullptr ? nullptr : c->subcommands;
newc = add_cmd (comname, class_user, user_defined_command,
(c != nullptr && c->theclass == class_user)
/* If we define or re-define a command that was previously defined
as a prefix, keep the prefix information. */
- if (c_prefixlist != nullptr)
+ if (c_subcommands != nullptr)
{
- newc->prefixlist = c_prefixlist;
+ newc->subcommands = c_subcommands;
/* allow_unknown: see explanation in equivalent logic in
define_prefix_command (). */
newc->allow_unknown = newc->user_commands.get () != nullptr;
if (c != nullptr && c->theclass != class_user)
error (_("Command \"%s\" is built-in."), comfull);
- if (c != nullptr && c->prefixlist != nullptr)
+ if (c != nullptr && c->subcommands != nullptr)
{
/* c is already a user defined prefix command. */
return;
xstrdup ("User-defined."), list);
}
- /* Allocate the c->prefixlist, which marks the command as a prefix
+ /* Allocate the c->subcommands, which marks the command as a prefix
command. */
- c->prefixlist = new struct cmd_list_element*;
- *(c->prefixlist) = nullptr;
+ c->subcommands = new struct cmd_list_element*;
+ *(c->subcommands) = nullptr;
/* If the prefix command C is not a command, then it must be followed
by known subcommands. Otherwise, if C is also a normal command,
it can be followed by C args that must not cause a 'subcommand'
struct command_line *cmdlines = c->user_commands.get ();
fprintf_filtered (stream, "User %scommand \"",
- c->prefixlist == NULL ? "" : "prefix ");
+ c->subcommands == NULL ? "" : "prefix ");
fprintf_styled (stream, title_style.style (), "%s%s",
prefix, name);
fprintf_filtered (stream, "\":\n");
}
}
- if (c->prefixlist != NULL)
+ if (c->subcommands != NULL)
{
const std::string prefixname = c->prefixname ();
- for (c = *c->prefixlist; c != NULL; c = c->next)
- if (c->theclass == class_user || c->prefixlist != NULL)
+ for (c = *c->subcommands; c != NULL; c = c->next)
+ if (c->theclass == class_user || c->subcommands != NULL)
show_user_1 (c, prefixname.c_str (), c->name, gdb_stdout);
}