diff options
author | Tiago Cunha <tcunha@gmx.com> | 2012-07-11 19:37:32 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2012-07-11 19:37:32 +0000 |
commit | 1f5e6e35d5046693f0ef5ec76535f517757b7122 (patch) | |
tree | e53808c90f3a53279554f8580d2b96df606baec3 /cmd-list.c | |
parent | a432fcd30617610b46d65f49b7513bf5da5694de (diff) | |
download | rtmux-1f5e6e35d5046693f0ef5ec76535f517757b7122.tar.gz rtmux-1f5e6e35d5046693f0ef5ec76535f517757b7122.tar.bz2 rtmux-1f5e6e35d5046693f0ef5ec76535f517757b7122.zip |
Sync OpenBSD patchset 1151:
Make command exec functions return an enum rather than -1/0/1 values and
add a new value to mean "leave client running but don't attach" to fix
problems with using some commands in a command sequence. Most of the
work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531.
Diffstat (limited to 'cmd-list.c')
-rw-r--r-- | cmd-list.c | 34 |
1 files changed, 19 insertions, 15 deletions
@@ -79,12 +79,13 @@ bad: return (NULL); } -int +enum cmd_retval cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx) { struct client *c = ctx->curclient; struct cmd *cmd; - int n, retval, guards; + enum cmd_retval retval; + int guards, n; guards = 0; if (c != NULL && c->session != NULL) @@ -98,21 +99,17 @@ cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx) if (guards) ctx->print(ctx, "%%end"); - /* Return of -1 is an error. */ - if (n == -1) - return (-1); - - /* - * A 1 return value means the command client is being attached - * (sent MSG_READY). - */ - if (n == 1) { - retval = 1; + switch (n) + { + case CMD_RETURN_ERROR: + return (CMD_RETURN_ERROR); + case CMD_RETURN_ATTACH: + /* Client is being attached (send MSG_READY). */ + retval = CMD_RETURN_ATTACH; /* - * The command client has been attached, so mangle the - * context to treat any following commands as if they - * were called from inside. + * Mangle the context to treat any following commands + * as if they were called from inside. */ if (ctx->curclient == NULL) { ctx->curclient = ctx->cmdclient; @@ -122,6 +119,13 @@ cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx) ctx->print = key_bindings_print; ctx->info = key_bindings_info; } + break; + case CMD_RETURN_YIELD: + if (retval == CMD_RETURN_NORMAL) + retval = CMD_RETURN_YIELD; + break; + case CMD_RETURN_NORMAL: + break; } } return (retval); |