static void undef_cmd_error (char *, char *);
static struct cmd_list_element *delete_cmd (char *name,
- struct cmd_list_element **list);
+ struct cmd_list_element **list,
+ struct cmd_list_element **prehook,
+ struct cmd_list_element **prehookee,
+ struct cmd_list_element **posthook,
+ struct cmd_list_element **posthookee);
static struct cmd_list_element *find_cmd (char *command,
int len,
/* Turn each alias of the old command into an alias of the new
command. */
- c->aliases = delete_cmd (name, list);
+ c->aliases = delete_cmd (name, list, &c->hook_pre, &c->hookee_pre,
+ &c->hook_post, &c->hookee_post);
for (iter = c->aliases; iter; iter = iter->alias_chain)
iter->cmd_pointer = c;
+ if (c->hook_pre)
+ c->hook_pre->hookee_pre = c;
+ if (c->hookee_pre)
+ c->hookee_pre->hook_pre = c;
+ if (c->hook_post)
+ c->hook_post->hookee_post = c;
+ if (c->hookee_post)
+ c->hookee_post->hook_post = c;
if (*list == NULL || strcmp ((*list)->name, name) >= 0)
{
c->flags = 0;
c->replacement = NULL;
c->pre_show_hook = NULL;
- c->hook_pre = NULL;
- c->hook_post = NULL;
c->hook_in = 0;
c->prefixlist = NULL;
c->prefixname = NULL;
c->var_type = var_boolean;
c->enums = NULL;
c->user_commands = NULL;
- c->hookee_pre = NULL;
- c->hookee_post = NULL;
c->cmd_pointer = NULL;
c->alias_chain = NULL;
if (old == 0)
{
- struct cmd_list_element *aliases = delete_cmd (name, list);
+ struct cmd_list_element *prehook, *prehookee, *posthook, *posthookee;
+ struct cmd_list_element *aliases = delete_cmd (name, list,
+ &prehook, &prehookee,
+ &posthook, &posthookee);
/* If this happens, it means a programmer error somewhere. */
- gdb_assert (!aliases);
+ gdb_assert (!aliases && !prehook && prehookee
+ && !posthook && ! posthookee);
return 0;
}
/* Remove the command named NAME from the command list. Return the
list commands which were aliased to the deleted command. If the
- command had no aliases, return NULL. */
+ command had no aliases, return NULL. The various *HOOKs are set to
+ the pre- and post-hook commands for the deleted command. If the
+ command does not have a hook, the corresponding out parameter is
+ set to NULL. */
static struct cmd_list_element *
-delete_cmd (char *name, struct cmd_list_element **list)
+delete_cmd (char *name, struct cmd_list_element **list,
+ struct cmd_list_element **prehook,
+ struct cmd_list_element **prehookee,
+ struct cmd_list_element **posthook,
+ struct cmd_list_element **posthookee)
{
struct cmd_list_element *iter;
struct cmd_list_element **previous_chain_ptr;
struct cmd_list_element *aliases = NULL;
+ *prehook = NULL;
+ *prehookee = NULL;
+ *posthook = NULL;
+ *posthookee = NULL;
previous_chain_ptr = list;
for (iter = *previous_chain_ptr; iter; iter = *previous_chain_ptr)
{
if (iter->hookee_pre)
iter->hookee_pre->hook_pre = 0;
+ *prehook = iter->hook_pre;
+ *prehookee = iter->hookee_pre;
if (iter->hookee_post)
iter->hookee_post->hook_post = 0;
+ *posthook = iter->hook_post;
+ *posthookee = iter->hookee_post;
/* Update the link. */
*previous_chain_ptr = iter->next;