diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-25 11:41:17 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-25 11:41:17 +0000 |
commit | ad1f17e8ec4b273ef9e3742a2c4f11cf3dd79ba5 (patch) | |
tree | 80d8d44e0480bfb3830cc6e97955e8f2bac0fada /usr.bin | |
parent | 35350ae3fd393214d12b033aef782c6607a8187e (diff) |
Only send end guard if begin was sent, from George Nachman.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cmd-queue.c | 23 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 4 |
2 files changed, 15 insertions, 12 deletions
diff --git a/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c index c80042ce663..31bbc0354b0 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.5 2013/03/25 11:36:08 nicm Exp $ */ +/* $OpenBSD: cmd-queue.c,v 1.6 2013/03/25 11:41:16 nicm Exp $ */ /* * Copyright (c) 2013 Nicholas Marriott <nicm@users.sourceforge.net> @@ -152,19 +152,20 @@ cmdq_error(struct cmd_q *cmdq, const char *fmt, ...) } /* Print a guard line. */ -void +int cmdq_guard(struct cmd_q *cmdq, const char *guard) { struct client *c = cmdq->client; if (c == NULL || c->session == NULL) - return; + return 0; if (!(c->flags & CLIENT_CONTROL)) - return; + return 0; evbuffer_add_printf(c->stdout_data, "%%%s %ld %u\n", guard, (long) cmdq->time, cmdq->number); server_push_stdout(c); + return 1; } /* Add command list to queue and begin processing if needed. */ @@ -197,7 +198,7 @@ cmdq_continue(struct cmd_q *cmdq) { struct cmd_q_item *next; enum cmd_retval retval; - int empty; + int empty, guard; char s[1024]; notify_disable(); @@ -223,12 +224,14 @@ cmdq_continue(struct cmd_q *cmdq) cmdq->time = time(NULL); cmdq->number++; - cmdq_guard(cmdq, "begin"); + guard = cmdq_guard(cmdq, "begin"); retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq); - if (retval == CMD_RETURN_ERROR) - cmdq_guard(cmdq, "error"); - else - cmdq_guard(cmdq, "end"); + if (guard) { + if (retval == CMD_RETURN_ERROR) + cmdq_guard(cmdq, "error"); + else + cmdq_guard(cmdq, "end"); + } if (retval == CMD_RETURN_ERROR) break; diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index b3088f45edd..2fe98ff5a3c 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.403 2013/03/25 11:35:55 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.404 2013/03/25 11:41:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1860,7 +1860,7 @@ int cmdq_free(struct cmd_q *); void printflike2 cmdq_print(struct cmd_q *, const char *, ...); void printflike2 cmdq_info(struct cmd_q *, const char *, ...); void printflike2 cmdq_error(struct cmd_q *, const char *, ...); -void cmdq_guard(struct cmd_q *, const char *); +int cmdq_guard(struct cmd_q *, const char *); void cmdq_run(struct cmd_q *, struct cmd_list *); void cmdq_append(struct cmd_q *, struct cmd_list *); int cmdq_continue(struct cmd_q *); |