+
+/* Add an element with a suppress notification to the list of commands. */
+
+struct cmd_list_element *
+add_com_suppress_notification (const char *name, enum command_class theclass,
+ cmd_const_cfunc_ftype *fun, const char *doc,
+ int *suppress_notification)
+{
+ return add_cmd_suppress_notification (name, theclass, fun, doc,
+ &cmdlist, suppress_notification);
+}
+
+/* Print the prefix of C followed by name of C in title style. */
+
+static void
+fput_command_name_styled (struct cmd_list_element *c, struct ui_file *stream)
+{
+ const char *prefixname
+ = c->prefix == nullptr ? "" : c->prefix->prefixname;
+
+ fprintf_styled (stream, title_style.style (), "%s%s", prefixname, c->name);
+}
+
+/* Print the definition of alias C using title style for alias
+ and aliased command. */
+
+static void
+fput_alias_definition_styled (struct cmd_list_element *c,
+ struct ui_file *stream)
+{
+ gdb_assert (c->cmd_pointer != nullptr);
+ fputs_filtered (" alias ", stream);
+ fput_command_name_styled (c, stream);
+ fprintf_filtered (stream, " = ");
+ fput_command_name_styled (c->cmd_pointer, stream);
+ fprintf_filtered (stream, " %s\n", c->default_args.c_str ());
+}
+
+/* Print the definition of the aliases of CMD that have default args. */
+
+static void
+fput_aliases_definition_styled (struct cmd_list_element *cmd,
+ struct ui_file *stream)
+{
+ if (cmd->aliases != nullptr)
+ {
+ for (cmd_list_element *iter = cmd->aliases;
+ iter;
+ iter = iter->alias_chain)
+ {
+ if (!iter->default_args.empty ())
+ fput_alias_definition_styled (iter, stream);
+ }
+ }
+}
+
+
+/* If C has one or more aliases, style print the name of C and
+ the name of its aliases, separated by commas.
+ If ALWAYS_FPUT_C_NAME, print the name of C even if it has no aliases.
+ If one or more names are printed, POSTFIX is printed after the last name.
+*/
+
+static void
+fput_command_names_styled (struct cmd_list_element *c,
+ bool always_fput_c_name, const char *postfix,
+ struct ui_file *stream)
+{
+ if (always_fput_c_name || c->aliases != nullptr)
+ fput_command_name_styled (c, stream);
+ if (c->aliases != nullptr)
+ {
+ for (cmd_list_element *iter = c->aliases; iter; iter = iter->alias_chain)
+ {
+ fputs_filtered (", ", stream);
+ wrap_here (" ");
+ fput_command_name_styled (iter, stream);
+ }
+ }
+ if (always_fput_c_name || c->aliases != nullptr)
+ fputs_filtered (postfix, stream);
+}
+
+/* If VERBOSE, print the full help for command C and highlight the
+ documentation parts matching HIGHLIGHT,
+ otherwise print only one-line help for command C. */
+
+static void
+print_doc_of_command (struct cmd_list_element *c, const char *prefix,
+ bool verbose, compiled_regex &highlight,
+ struct ui_file *stream)
+{
+ /* When printing the full documentation, add a line to separate
+ this documentation from the previous command help, in the likely
+ case that apropos finds several commands. */
+ if (verbose)
+ fputs_filtered ("\n", stream);
+
+ fput_command_names_styled (c, true,
+ verbose ? "" : " -- ", stream);
+ if (verbose)
+ {
+ fputs_filtered ("\n", stream);
+ fput_aliases_definition_styled (c, stream);
+ fputs_highlighted (c->doc, highlight, stream);
+ fputs_filtered ("\n", stream);
+ }
+ else
+ {
+ print_doc_line (stream, c->doc, false);
+ fputs_filtered ("\n", stream);
+ fput_aliases_definition_styled (c, stream);
+ }
+}
+