aboutsummaryrefslogtreecommitdiff
path: root/cmd-set-option.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2012-07-11 19:37:32 +0000
committerTiago Cunha <tcunha@gmx.com>2012-07-11 19:37:32 +0000
commit1f5e6e35d5046693f0ef5ec76535f517757b7122 (patch)
treee53808c90f3a53279554f8580d2b96df606baec3 /cmd-set-option.c
parenta432fcd30617610b46d65f49b7513bf5da5694de (diff)
downloadrtmux-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-set-option.c')
-rw-r--r--cmd-set-option.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c
index 1d37bfeb..ca99a977 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -27,7 +27,7 @@
* Set an option.
*/
-int cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
+enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
int cmd_set_option_unset(struct cmd *, struct cmd_ctx *,
const struct options_table_entry *, struct options *,
@@ -78,7 +78,7 @@ const struct cmd_entry cmd_set_window_option_entry = {
cmd_set_option_exec
};
-int
+enum cmd_retval
cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct args *args = self->args;
@@ -95,7 +95,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
optstr = args->argv[0];
if (*optstr == '\0') {
ctx->error(ctx, "invalid option");
- return (-1);
+ return (CMD_RETURN_ERROR);
}
if (args->argc < 2)
valstr = NULL;
@@ -106,11 +106,11 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
table = oe = NULL;
if (options_table_find(optstr, &table, &oe) != 0) {
ctx->error(ctx, "ambiguous option: %s", optstr);
- return (-1);
+ return (CMD_RETURN_ERROR);
}
if (oe == NULL) {
ctx->error(ctx, "unknown option: %s", optstr);
- return (-1);
+ return (CMD_RETURN_ERROR);
}
/* Work out the tree from the table. */
@@ -122,7 +122,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
else {
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
if (wl == NULL)
- return (-1);
+ return (CMD_RETURN_ERROR);
oo = &wl->window->options;
}
} else if (table == session_options_table) {
@@ -131,21 +131,21 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
else {
s = cmd_find_session(ctx, args_get(args, 't'), 0);
if (s == NULL)
- return (-1);
+ return (CMD_RETURN_ERROR);
oo = &s->options;
}
} else {
ctx->error(ctx, "unknown table");
- return (-1);
+ return (CMD_RETURN_ERROR);
}
/* Unset or set the option. */
if (args_has(args, 'u')) {
if (cmd_set_option_unset(self, ctx, oe, oo, valstr) != 0)
- return (-1);
+ return (CMD_RETURN_ERROR);
} else {
if (cmd_set_option_set(self, ctx, oe, oo, valstr) != 0)
- return (-1);
+ return (CMD_RETURN_ERROR);
}
/* Start or stop timers when automatic-rename changed. */
@@ -168,7 +168,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
server_redraw_client(c);
}
- return (0);
+ return (CMD_RETURN_NORMAL);
}
/* Unset an option. */