return 0;
}
+/* See command.h. */
+
+struct cmd_list_element *
+lookup_cmd_exact (const char *name,
+ struct cmd_list_element *list,
+ bool ignore_help_classes)
+{
+ const char *tem = name;
+ struct cmd_list_element *cmd = lookup_cmd (&tem, list, "", NULL, -1,
+ ignore_help_classes);
+ if (cmd != nullptr && strcmp (name, cmd->name) != 0)
+ cmd = nullptr;
+ return cmd;
+}
+
/* We are here presumably because an alias or command in TEXT is
deprecated and a warning message should be generated. This
function decodes TEXT and potentially generates a warning message
CMD_POST_HOOK
};
struct cmd_list_element *c, *newc, *hookc = 0, **list;
- const char *tem, *comfull;
+ const char *comfull;
int hook_type = CMD_NO_HOOK;
int hook_name_size = 0;
comfull = comname;
list = validate_comname (&comname);
- /* Look it up, and verify that we got an exact match. */
- tem = comname;
- c = lookup_cmd (&tem, *list, "", NULL, -1, 1);
- if (c && strcmp (comname, c->name) != 0)
- c = 0;
+ c = lookup_cmd_exact (comname, *list);
if (c && commands == nullptr)
{
if (hook_type != CMD_NO_HOOK)
{
- /* Look up cmd it hooks, and verify that we got an exact match. */
- tem = comname + hook_name_size;
- hookc = lookup_cmd (&tem, *list, "", NULL, -1, 0);
- if (hookc && strcmp (comname + hook_name_size, hookc->name) != 0)
- hookc = 0;
+ /* Look up cmd it hooks. */
+ hookc = lookup_cmd_exact (comname + hook_name_size, *list,
+ /* ignore_help_classes = */ false);
if (!hookc && commands == nullptr)
{
warning (_("Your new `%s' command does not "
define_prefix_command (const char *comname, int from_tty)
{
struct cmd_list_element *c, **list;
- const char *tem;
const char *comfull;
comfull = comname;
list = validate_comname (&comname);
- /* Look it up, and verify that we got an exact match. */
- tem = comname;
- c = lookup_cmd (&tem, *list, "", NULL, -1, 1);
- if (c != nullptr && strcmp (comname, c->name) != 0)
- c = nullptr;
+ c = lookup_cmd_exact (comname, *list);
if (c != nullptr && c->theclass != class_user)
error (_("Command \"%s\" is built-in."), comfull);
struct cmd_list_element **result_list, std::string *default_args,
int ignore_help_classes, bool lookup_for_completion_p = false);
+/* Look up the command called NAME in the command list LIST.
+
+ Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
+ on NAME are considered.
+
+ LIST is a chain of struct cmd_list_element's.
+
+ If IGNORE_HELP_CLASSES is true (the default), ignore any command list
+ elements which are actually help classes rather than commands (i.e.
+ the function field of the struct cmd_list_element is null).
+
+ If found, return the struct cmd_list_element for that command,
+ otherwise return NULLPTR. */
+
+extern struct cmd_list_element *lookup_cmd_exact
+ (const char *name,
+ struct cmd_list_element *list,
+ bool ignore_help_classes = true);
+
extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *,
const char * );