diff options
author | 2015-06-17 17:02:15 +0000 | |
---|---|---|
committer | 2015-06-17 17:02:15 +0000 | |
commit | 76851227ca94e7f71e7a9450a988efa70a3e0d85 (patch) | |
tree | 373264489375d418b31847b0df4c35a3c2f3ff98 /usr.bin/tmux/cmd-queue.c | |
parent | Move the shuffle code from new-window -a into a function and add a -a (diff) | |
download | wireguard-openbsd-76851227ca94e7f71e7a9450a988efa70a3e0d85.tar.xz wireguard-openbsd-76851227ca94e7f71e7a9450a988efa70a3e0d85.zip |
Break cmdq_continue inner loop into a helper function.
Diffstat (limited to 'usr.bin/tmux/cmd-queue.c')
-rw-r--r-- | usr.bin/tmux/cmd-queue.c | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c index 0d26ff2465d..72ed7fbb908 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.23 2015/04/19 21:34:21 nicm Exp $ */ +/* $OpenBSD: cmd-queue.c,v 1.24 2015/06/17 17:02:15 nicm Exp $ */ /* * Copyright (c) 2013 Nicholas Marriott <nicm@users.sourceforge.net> @@ -25,6 +25,8 @@ #include "tmux.h" +enum cmd_retval cmdq_continue_one(struct cmd_q *); + /* Create new command queue. */ struct cmd_q * cmdq_new(struct client *c) @@ -160,14 +162,39 @@ cmdq_append(struct cmd_q *cmdq, struct cmd_list *cmdlist, struct mouse_event *m) item->mouse.valid = 0; } +/* Process one command. */ +enum cmd_retval +cmdq_continue_one(struct cmd_q *cmdq) +{ + struct cmd *cmd = cmdq->cmd; + enum cmd_retval retval; + char tmp[1024]; + int flags = !!(cmd->flags & CMD_CONTROL); + + cmd_print(cmd, tmp, sizeof tmp); + log_debug("cmdq %p: %s", cmdq, tmp); + + cmdq->time = time(NULL); + cmdq->number++; + + cmdq_guard(cmdq, "begin", flags); + + retval = cmd->entry->exec(cmd, cmdq); + + if (retval == CMD_RETURN_ERROR) + cmdq_guard(cmdq, "error", flags); + else + cmdq_guard(cmdq, "end", flags); + return (retval); +} + /* Continue processing command queue. Returns 1 if finishes empty. */ int cmdq_continue(struct cmd_q *cmdq) { struct cmd_q_item *next; enum cmd_retval retval; - int empty, flags; - char s[1024]; + int empty; cmdq->references++; notify_disable(); @@ -184,23 +211,7 @@ cmdq_continue(struct cmd_q *cmdq) do { while (cmdq->cmd != NULL) { - cmd_print(cmdq->cmd, s, sizeof s); - log_debug("cmdq %p: %s (client %d)", cmdq, s, - cmdq->client != NULL ? cmdq->client->ibuf.fd : -1); - - cmdq->time = time(NULL); - cmdq->number++; - - flags = !!(cmdq->cmd->flags & CMD_CONTROL); - cmdq_guard(cmdq, "begin", flags); - - retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq); - - if (retval == CMD_RETURN_ERROR) - cmdq_guard(cmdq, "error", flags); - else - cmdq_guard(cmdq, "end", flags); - + retval = cmdq_continue_one(cmdq); if (retval == CMD_RETURN_ERROR) break; if (retval == CMD_RETURN_WAIT) @@ -209,7 +220,6 @@ cmdq_continue(struct cmd_q *cmdq) cmdq_flush(cmdq); goto empty; } - cmdq->cmd = TAILQ_NEXT(cmdq->cmd, qentry); } next = TAILQ_NEXT(cmdq->item, qentry); |