diff options
author | nicm <nicm> | 2021-08-20 19:50:16 +0000 |
---|---|---|
committer | nicm <nicm> | 2021-08-20 19:50:16 +0000 |
commit | 5f32b7d9613e9ef3f8198302379a42630323da6a (patch) | |
tree | 0a0b488496625e9da5cbc02c5a1271634568ecc3 /cmd-set-option.c | |
parent | de94a344f61b0e4ef6459c11621be3c3d1683c9e (diff) | |
download | rtmux-5f32b7d9613e9ef3f8198302379a42630323da6a.tar.gz rtmux-5f32b7d9613e9ef3f8198302379a42630323da6a.tar.bz2 rtmux-5f32b7d9613e9ef3f8198302379a42630323da6a.zip |
Hide struct args behind a couple of accessor functions.
Diffstat (limited to 'cmd-set-option.c')
-rw-r--r-- | cmd-set-option.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c index 70e3c54d..48e04eed 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -77,14 +77,16 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item) struct window_pane *loop; struct options *oo; struct options_entry *parent, *o, *po; - char *name, *argument, *value = NULL, *cause; + char *name, *argument, *expanded = NULL; + char *cause; + const char *value; int window, idx, already, error, ambiguous; int scope; window = (cmd_get_entry(self) == &cmd_set_window_option_entry); /* Expand argument. */ - argument = format_single_from_target(item, args->argv[0]); + argument = format_single_from_target(item, args_string(args, 0)); /* If set-hook -R, fire the hook straight away. */ if (cmd_get_entry(self) == &cmd_set_hook_entry && args_has(args, 'R')) { @@ -104,12 +106,14 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item) cmdq_error(item, "invalid option: %s", argument); goto fail; } - if (args->argc < 2) + if (args_count(args) < 2) value = NULL; - else if (args_has(args, 'F')) - value = format_single_from_target(item, args->argv[1]); else - value = xstrdup(args->argv[1]); + value = args_string(args, 1); + if (value != NULL && args_has(args, 'F')) { + expanded = format_single_from_target(item, value); + value = expanded; + } /* Get the scope and table for the option .*/ scope = options_scope_from_name(args, window, name, target, &oo, @@ -211,13 +215,13 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item) out: free(argument); - free(value); + free(expanded); free(name); return (CMD_RETURN_NORMAL); fail: free(argument); - free(value); + free(expanded); free(name); return (CMD_RETURN_ERROR); } |