From cb02a04e74094b5ab59e438145f33b0a61fd5fa4 Mon Sep 17 00:00:00 2001 From: sabetts Date: Thu, 24 Jan 2002 10:58:20 +0000 Subject: * src/actions.c (find_alias_index): new function (cmd_alias): When an alias is already in the alias list, replace it with the new alias. * src/events.c (configure_request): do not send a synthetic configure notify event. --- src/actions.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) (limited to 'src/actions.c') diff --git a/src/actions.c b/src/actions.c index 17fe2b1..2aadf38 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2324,10 +2324,25 @@ cmd_defbarpadding (int interactive, void *data) return NULL; } +/* Search the alias table for a match. If a match is found, return its + index into the table. Otherwise return -1. */ +static int +find_alias_index (char *name) +{ + int i; + + for (i=0; i= alias_list_size) - { - alias_list_size *= 2; - alias_list = xrealloc (alias_list, sizeof (cmd_alias) * alias_list_size); - } - + /* Parse out the arguments. */ name = strtok (data, " "); alias = strtok (NULL, "\0"); @@ -2349,10 +2359,26 @@ cmd_alias (int interactive, void *data) message (" alias: Two arguments required "); return NULL; } - - alias_list[alias_list_last].name = xstrdup (name); - alias_list[alias_list_last].alias = xstrdup (alias); - alias_list_last++; + + /* Are we updating an existing alias, or creating a new one? */ + index = find_alias_index (name); + if (index >= 0) + { + free (alias_list[index].alias); + alias_list[index].alias = xstrdup (alias); + } + else + { + if (alias_list_last >= alias_list_size) + { + alias_list_size *= 2; + alias_list = xrealloc (alias_list, sizeof (cmd_alias) * alias_list_size); + } + + alias_list[alias_list_last].name = xstrdup (name); + alias_list[alias_list_last].alias = xstrdup (alias); + alias_list_last++; + } return NULL; } -- cgit v1.2.3