#include "ui-out.h"
#include "cli/cli-cmds.h"
#include "cli/cli-decode.h"
+#include "common/gdb_optional.h"
/* Prototypes for local functions. */
c->allow_unknown = 0;
c->prefix = NULL;
c->abbrev_flag = 0;
- set_cmd_completer (c, make_symbol_completion_list_fn);
+ set_cmd_completer (c, symbol_completer);
c->completer_handle_brkchars = NULL;
c->destroyer = NULL;
c->type = not_set_cmd;
}
struct cmd_list_element *
-add_alias_cmd (const char *name, const char *oldname, enum command_class theclass,
- int abbrev_flag, struct cmd_list_element **list)
+add_alias_cmd (const char *name, cmd_list_element *old,
+ enum command_class theclass, int abbrev_flag,
+ struct cmd_list_element **list)
{
- const char *tmp;
- struct cmd_list_element *old;
- struct cmd_list_element *c;
-
- tmp = oldname;
- old = lookup_cmd (&tmp, *list, "", 1, 1);
-
if (old == 0)
{
struct cmd_list_element *prehook, *prehookee, *posthook, *posthookee;
return 0;
}
- c = add_cmd (name, theclass, NULL, old->doc, list);
+ struct cmd_list_element *c = add_cmd (name, theclass, NULL, old->doc, list);
/* If OLD->DOC can be freed, we should make another copy. */
if (old->doc_allocated)
return c;
}
+struct cmd_list_element *
+add_alias_cmd (const char *name, const char *oldname,
+ enum command_class theclass, int abbrev_flag,
+ struct cmd_list_element **list)
+{
+ const char *tmp;
+ struct cmd_list_element *old;
+
+ tmp = oldname;
+ old = lookup_cmd (&tmp, *list, "", 1, 1);
+
+ return add_alias_cmd (name, old, theclass, abbrev_flag, list);
+}
+
+
/* 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
void
apropos_cmd (struct ui_file *stream,
struct cmd_list_element *commandlist,
- struct re_pattern_buffer *regex, const char *prefix)
+ compiled_regex ®ex, const char *prefix)
{
struct cmd_list_element *c;
int returnvalue;
returnvalue = -1; /* Needed to avoid double printing. */
if (c->name != NULL)
{
+ size_t name_len = strlen (c->name);
+
/* Try to match against the name. */
- returnvalue = re_search (regex, c->name, strlen(c->name),
- 0, strlen (c->name), NULL);
+ returnvalue = regex.search (c->name, name_len, 0, name_len, NULL);
if (returnvalue >= 0)
{
print_help_for_command (c, prefix,
}
if (c->doc != NULL && returnvalue < 0)
{
+ size_t doc_len = strlen (c->doc);
+
/* Try to match against documentation. */
- if (re_search(regex,c->doc,strlen(c->doc),0,strlen(c->doc),NULL) >=0)
+ if (regex.search (c->doc, doc_len, 0, doc_len, NULL) >= 0)
{
print_help_for_command (c, prefix,
0 /* don't recurse */, stream);
the function field of the struct cmd_list_element is 0). */
struct cmd_list_element *
-lookup_cmd (const char **line, struct cmd_list_element *list, char *cmdtype,
+lookup_cmd (const char **line, struct cmd_list_element *list,
+ const char *cmdtype,
int allow_unknown, int ignore_help_classes)
{
struct cmd_list_element *last_list = 0;
{
if (cmd_func_p (cmd))
{
- struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
+ gdb::optional<scoped_restore_tmpl<int>> restore_suppress;
if (cmd->suppress_notification != NULL)
- {
- make_cleanup_restore_integer (cmd->suppress_notification);
- *cmd->suppress_notification = 1;
- }
+ restore_suppress.emplace (cmd->suppress_notification, 1);
(*cmd->func) (cmd, args, from_tty);
-
- do_cleanups (cleanups);
}
else
error (_("Invalid command"));