From c17edd594e8088d2355102a8ca58f4b256c59397 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 29 May 2019 19:34:42 +0000 Subject: The line number needs to be updated only after the \n is processed by the parser, so store a flag and update it next time around. Also each new line needs its own shared data. --- cmd-queue.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'cmd-queue.c') diff --git a/cmd-queue.c b/cmd-queue.c index f08d7c02..93dcaa53 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -203,16 +203,20 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current, struct cmdq_item *item, *first = NULL, *last = NULL; struct cmd *cmd; struct cmdq_shared *shared; - - shared = xcalloc(1, sizeof *shared); - if (current != NULL) - cmd_find_copy_state(&shared->current, current); - else - cmd_find_clear_state(&shared->current, 0); - if (m != NULL) - memcpy(&shared->mouse, m, sizeof shared->mouse); + u_int group = 0; TAILQ_FOREACH(cmd, &cmdlist->list, qentry) { + if (cmd->group != group) { + shared = xcalloc(1, sizeof *shared); + if (current != NULL) + cmd_find_copy_state(&shared->current, current); + else + cmd_find_clear_state(&shared->current, 0); + if (m != NULL) + memcpy(&shared->mouse, m, sizeof shared->mouse); + group = cmd->group; + } + item = xcalloc(1, sizeof *item); xasprintf(&item->name, "[%s/%p]", cmd->entry->name, item); item->type = CMDQ_COMMAND; @@ -263,12 +267,20 @@ static enum cmd_retval cmdq_fire_command(struct cmdq_item *item) { struct client *c = item->client; + const char *name = cmdq_name(c); struct cmdq_shared *shared = item->shared; struct cmd *cmd = item->cmd; const struct cmd_entry *entry = cmd->entry; enum cmd_retval retval; struct cmd_find_state *fsp, fs; int flags; + char *tmp; + + if (log_get_level() > 1) { + tmp = cmd_print(cmd); + log_debug("%s %s: (%u) %s", __func__, name, item->group, tmp); + free(tmp); + } flags = !!(shared->flags & CMDQ_SHARED_CONTROL); cmdq_guard(item, "begin", flags); -- cgit From 2c5f3074bcd3c4d1399a5cf3691430027452266f Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 31 May 2019 21:41:17 +0000 Subject: Fix warnings, from Ben Boeckel. --- cmd-queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd-queue.c') diff --git a/cmd-queue.c b/cmd-queue.c index 93dcaa53..1ee43508 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -202,7 +202,7 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current, { struct cmdq_item *item, *first = NULL, *last = NULL; struct cmd *cmd; - struct cmdq_shared *shared; + struct cmdq_shared *shared = NULL; u_int group = 0; TAILQ_FOREACH(cmd, &cmdlist->list, qentry) { -- cgit From 9272fe36e2e36789342337d81914008826499941 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 18 Jun 2019 11:08:42 +0000 Subject: Add a cmdq_continue function rather than twiddling the flag directly. --- cmd-queue.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cmd-queue.c') diff --git a/cmd-queue.c b/cmd-queue.c index 1ee43508..ef68d5d5 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -156,6 +156,13 @@ cmdq_insert_hook(struct session *s, struct cmdq_item *item, free(name); } +/* Continue processing command queue. */ +void +cmdq_continue(struct cmdq_item *item) +{ + item->flags &= ~CMDQ_WAITING; +} + /* Remove an item. */ static void cmdq_remove(struct cmdq_item *item) -- cgit