diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2015-06-30 18:44:30 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2015-06-30 18:44:30 +0000 |
commit | e69673aeb383cd33b022fe5bc4e880c0d06397c0 (patch) | |
tree | 1eaaa19fee47ed69528d2e392d4d3afee9568d36 /app | |
parent | 8cc5c577746fe453f883c863669dd863c2abb5e1 (diff) |
keep cmdq sorted
Diffstat (limited to 'app')
-rw-r--r-- | app/cwm/conf.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/cwm/conf.c b/app/cwm/conf.c index 54e67912c..6648acd9b 100644 --- a/app/cwm/conf.c +++ b/app/cwm/conf.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: conf.c,v 1.188 2015/06/30 18:42:50 okan Exp $ + * $OpenBSD: conf.c,v 1.189 2015/06/30 18:44:29 okan Exp $ */ #include <sys/types.h> @@ -40,7 +40,7 @@ static void conf_unbind_mouse(struct conf *, struct binding *); int conf_cmd_add(struct conf *c, const char *name, const char *path) { - struct cmd *cmd; + struct cmd *cmd, *prev; cmd = xmalloc(sizeof(*cmd)); @@ -54,6 +54,14 @@ conf_cmd_add(struct conf *c, const char *name, const char *path) conf_cmd_remove(c, name); TAILQ_INSERT_TAIL(&c->cmdq, cmd, entry); + + /* keep queue sorted by name */ + while ((prev = TAILQ_PREV(cmd, cmd_q, entry)) && + (strcmp(prev->name, cmd->name) > 0)) { + TAILQ_REMOVE(&c->cmdq, cmd, entry); + TAILQ_INSERT_BEFORE(prev, cmd, entry); + } + return(1); } |