summary refs log tree commit diff
path: root/conf.c
diff options
context:
space:
mode:
authorokan <okan>2014-01-29 18:43:27 +0000
committerokan <okan>2014-01-29 18:43:27 +0000
commit4438970b649d8c6b0d662576bc37fc577b8de1b6 (patch)
tree7a75d963cc55c745b579eb179c4b5663d22b1450 /conf.c
parent1f8f19b4d50f59624e84a3c932b639670e0d8b27 (diff)
downloadcwm-4438970b649d8c6b0d662576bc37fc577b8de1b6.tar.gz
cwm-4438970b649d8c6b0d662576bc37fc577b8de1b6.tar.xz
cwm-4438970b649d8c6b0d662576bc37fc577b8de1b6.zip
Much like we do for keyboard and mouse bindings, remove duplicates for
command name - last match.
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/conf.c b/conf.c
index 8f067d0..9d4c079 100644
--- a/conf.c
+++ b/conf.c
@@ -32,6 +32,7 @@
 #include "calmwm.h"
 
 static const char	*conf_bind_getmask(const char *, unsigned int *);
+static void	 	 conf_cmd_remove(struct conf *, const char *);
 static void	 	 conf_unbind_kbd(struct conf *, struct keybinding *);
 static void	 	 conf_unbind_mouse(struct conf *, struct mousebinding *);
 
@@ -52,6 +53,8 @@ conf_cmd_add(struct conf *c, const char *name, const char *path)
 	} else {
 		cmd = xmalloc(sizeof(*cmd));
 
+		conf_cmd_remove(c, name);
+
 		if (strlcpy(cmd->name, name, sizeof(cmd->name)) >=
 		    sizeof(cmd->name))
 			return (0);
@@ -63,6 +66,18 @@ conf_cmd_add(struct conf *c, const char *name, const char *path)
 	return (1);
 }
 
+static void
+conf_cmd_remove(struct conf *c, const char *name)
+{
+	struct cmd	*cmd = NULL, *cmdnxt;
+
+	TAILQ_FOREACH_SAFE(cmd, &c->cmdq, entry, cmdnxt) {
+		if (strcmp(cmd->name, name) == 0) {
+			TAILQ_REMOVE(&c->cmdq, cmd, entry);
+			free(cmd);
+		}
+	}
+}
 void
 conf_autogroup(struct conf *c, int no, const char *val)
 {