return add_cmd (name, theclass, fun, doc, &cmdlist);
}
-/* Add an alias or abbreviation command to the list of commands. */
+/* Add an alias or abbreviation command to the list of commands.
+ For aliases predefined by GDB (such as bt), THECLASS must be
+ different of class_alias, as class_alias is used to identify
+ user defined aliases. */
struct cmd_list_element *
add_com_alias (const char *name, const char *oldname, enum command_class theclass,
if (verbose)
fputs_filtered ("\n", stream);
- fprintf_styled (stream, title_style.style (),
- "%s%s", prefix, c->name);
- fputs_filtered (" -- ", stream);
+ fput_command_names_styled (c, true, " -- ", stream);
if (verbose)
fputs_highlighted (c->doc, highlight, stream);
else
/* Walk through the commands. */
for (c=commandlist;c;c=c->next)
{
+ if (c->cmd_pointer != nullptr)
+ {
+ /* Command aliases/abbreviations are skipped to ensure we print the
+ doc of a command only once, when encountering the aliased
+ command. */
+ continue;
+ }
+
returnvalue = -1; /* Needed to avoid double printing. */
if (c->name != NULL)
{
returnvalue = regex.search (c->name, name_len, 0, name_len, NULL);
if (returnvalue >= 0)
print_doc_of_command (c, prefix, verbose, regex, stream);
+
+ /* Try to match against the name of the aliases. */
+ for (cmd_list_element *iter = c->aliases;
+ returnvalue < 0 && iter;
+ iter = iter->alias_chain)
+ {
+ name_len = strlen (iter->name);
+ returnvalue = regex.search (iter->name, name_len, 0, name_len, NULL);
+ if (returnvalue >= 0)
+ print_doc_of_command (c, prefix, verbose, regex, stream);
+ }
}
if (c->doc != NULL && returnvalue < 0)
{
if (regex.search (c->doc, doc_len, 0, doc_len, NULL) >= 0)
print_doc_of_command (c, prefix, verbose, regex, stream);
}
- /* Check if this command has subcommands and is not an
- abbreviation. We skip listing subcommands of abbreviations
- in order to avoid duplicates in the output. */
- if (c->prefixlist != NULL && !c->abbrev_flag)
+ /* Check if this command has subcommands. */
+ if (c->prefixlist != NULL)
{
/* Recursively call ourselves on the subcommand list,
passing the right prefix in. */
void
help_cmd (const char *command, struct ui_file *stream)
{
- struct cmd_list_element *c;
+ struct cmd_list_element *c, *alias, *prefix_cmd, *c_cmd;
if (!command)
{
return;
}
+ const char *orig_command = command;
c = lookup_cmd (&command, cmdlist, "", 0, 0);
if (c == 0)
return;
+ 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.
Print its documentation, then list its subcommands.
number of this class so that the commands in the class will be
listed. */
+ /* If the user asked 'help somecommand' and there is no alias,
+ the false indicates to not output the (single) command name. */
+ fput_command_names_styled (c, false, "\n", stream);
fputs_filtered (c->doc, stream);
fputs_filtered ("\n", stream);