summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-05-03 15:43:02 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-05-03 15:43:02 +0000
commitd8032392ffccc29b0dd06f73623de47b321b28a8 (patch)
tree0b3c9efa34b6842497e73463a904a29822c5d71f
parente7fc3e82b30f6b084d933337504a0e35279420b1 (diff)
Correct ordering when adding after an existing item.
-rw-r--r--usr.bin/tmux/cmd-queue.c26
-rw-r--r--usr.bin/tmux/tmux.h4
2 files changed, 12 insertions, 18 deletions
diff --git a/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c
index 3109cdb8cf8..3290e4c6292 100644
--- a/usr.bin/tmux/cmd-queue.c
+++ b/usr.bin/tmux/cmd-queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-queue.c,v 1.63 2019/04/26 11:38:51 nicm Exp $ */
+/* $OpenBSD: cmd-queue.c,v 1.64 2019/05/03 15:43:01 nicm Exp $ */
/*
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -66,6 +66,7 @@ cmdq_append(struct client *c, struct cmdq_item *item)
item->queue = queue;
TAILQ_INSERT_TAIL(queue, item, entry);
+ log_debug("%s %s: %s", __func__, cmdq_name(c), item->name);
item = next;
} while (item != NULL);
@@ -81,18 +82,17 @@ cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item)
do {
next = item->next;
- item->next = NULL;
+ item->next = after->next;
+ after->next = item;
if (c != NULL)
c->references++;
item->client = c;
item->queue = queue;
- if (after->next != NULL)
- TAILQ_INSERT_AFTER(queue, after->next, item, entry);
- else
- TAILQ_INSERT_AFTER(queue, after, item, entry);
- after->next = item;
+ TAILQ_INSERT_AFTER(queue, after, item, entry);
+ log_debug("%s %s: %s after %s", __func__, cmdq_name(c),
+ item->name, after->name);
item = next;
} while (item != NULL);
@@ -170,7 +170,7 @@ cmdq_remove(struct cmdq_item *item)
TAILQ_REMOVE(item->queue, item, entry);
- free((void *)item->name);
+ free(item->name);
free(item);
}
@@ -206,7 +206,6 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current,
struct cmdq_item *item, *first = NULL, *last = NULL;
struct cmd *cmd;
u_int group = cmdq_next_group();
- char *tmp;
struct cmdq_shared *shared;
shared = xcalloc(1, sizeof *shared);
@@ -218,10 +217,8 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current,
memcpy(&shared->mouse, m, sizeof shared->mouse);
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
- xasprintf(&tmp, "command[%s]", cmd->entry->name);
-
item = xcalloc(1, sizeof *item);
- item->name = tmp;
+ xasprintf(&item->name, "[%s/%p]", cmd->entry->name, item);
item->type = CMDQ_COMMAND;
item->group = group;
@@ -316,12 +313,9 @@ struct cmdq_item *
cmdq_get_callback1(const char *name, cmdq_cb cb, void *data)
{
struct cmdq_item *item;
- char *tmp;
-
- xasprintf(&tmp, "callback[%s]", name);
item = xcalloc(1, sizeof *item);
- item->name = tmp;
+ xasprintf(&item->name, "[%s/%p]", name, item);
item->type = CMDQ_CALLBACK;
item->group = 0;
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 38fa024f8f6..f02d444b9a9 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.885 2019/05/03 14:51:31 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.886 2019/05/03 15:43:01 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1291,7 +1291,7 @@ struct cmdq_shared {
/* Command queue item. */
typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *);
struct cmdq_item {
- const char *name;
+ char *name;
struct cmdq_list *queue;
struct cmdq_item *next;