diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-06-20 18:13:05 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-06-20 18:13:05 +0000 |
commit | faa2903ec14f09776a3ed208028ea29e43b9e4b5 (patch) | |
tree | cde5e8e2bb8e43f6e3ec93588d1a977975f450f5 | |
parent | b6f371bfb6e695614406782e09ccdcc7a7f5f458 (diff) |
FIx return of options_scope_from_name on error.
-rw-r--r-- | usr.bin/tmux/options.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/usr.bin/tmux/options.c b/usr.bin/tmux/options.c index a042680c7d7..c13c8901da7 100644 --- a/usr.bin/tmux/options.c +++ b/usr.bin/tmux/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.50 2019/06/20 11:59:59 nicm Exp $ */ +/* $OpenBSD: options.c,v 1.51 2019/06/20 18:13:04 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -741,7 +741,7 @@ options_scope_from_name(struct args *args, int window, struct window_pane *wp = fs->wp; const char *target = args_get(args, 't'); const struct options_table_entry *oe; - int scope; + int scope = OPTIONS_TABLE_NONE; if (*name == '@') return (options_scope_from_flags(args, window, fs, oo, cause)); @@ -754,21 +754,23 @@ options_scope_from_name(struct args *args, int window, xasprintf(cause, "unknown option: %s", name); return (OPTIONS_TABLE_NONE); } - scope = oe->scope; - - switch (scope) { + switch (oe->scope) { case OPTIONS_TABLE_SERVER: *oo = global_options; + scope = OPTIONS_TABLE_SERVER; break; case OPTIONS_TABLE_SESSION: - if (args_has(args, 'g')) + if (args_has(args, 'g')) { *oo = global_s_options; - else if (s == NULL && target != NULL) + scope = OPTIONS_TABLE_SESSION; + } else if (s == NULL && target != NULL) xasprintf(cause, "no such session: %s", target); else if (s == NULL) xasprintf(cause, "no current session"); - else + else { *oo = s->options; + scope = OPTIONS_TABLE_SESSION; + } break; case OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE: if (args_has(args, 'p')) { @@ -776,21 +778,26 @@ options_scope_from_name(struct args *args, int window, xasprintf(cause, "no such pane: %s", target); else if (wp == NULL) xasprintf(cause, "no current pane"); - else + else { *oo = wp->options; + scope = OPTIONS_TABLE_PANE; + } break; } scope = OPTIONS_TABLE_WINDOW; /* FALLTHROUGH */ case OPTIONS_TABLE_WINDOW: - if (args_has(args, 'g')) + if (args_has(args, 'g')) { *oo = global_w_options; - else if (wl == NULL && target != NULL) + scope = OPTIONS_TABLE_WINDOW; + } else if (wl == NULL && target != NULL) xasprintf(cause, "no such window: %s", target); else if (wl == NULL) xasprintf(cause, "no current window"); - else + else { *oo = wl->window->options; + scope = OPTIONS_TABLE_WINDOW; + } break; } return (scope); |