Hide struct args behind a couple of accessor functions.

This commit is contained in:
nicm
2021-08-20 19:50:16 +00:00
parent de94a344f6
commit 5f32b7d961
41 changed files with 355 additions and 306 deletions

View File

@ -59,22 +59,22 @@ cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
struct cmd_confirm_before_data *cdata;
struct client *tc = cmdq_get_target_client(item);
struct cmd_find_state *target = cmdq_get_target(item);
char *cmd, *copy, *new_prompt, *ptr;
char *cmd, *copy, *new_prompt, *tmp;
const char *prompt;
int wait = !args_has(args, 'b');
cdata = xcalloc(1, sizeof *cdata);
cdata->cmd = xstrdup(args_string(args, 0));
if ((prompt = args_get(args, 'p')) != NULL)
xasprintf(&new_prompt, "%s ", prompt);
else {
ptr = copy = xstrdup(args->argv[0]);
cmd = strsep(&ptr, " \t");
tmp = copy = xstrdup(cdata->cmd);
cmd = strsep(&tmp, " \t");
xasprintf(&new_prompt, "Confirm '%s'? (y/n) ", cmd);
free(copy);
}
cdata = xcalloc(1, sizeof *cdata);
cdata->cmd = xstrdup(args->argv[0]);
cmd_get_source(self, &cdata->pi.file, &cdata->pi.line);
if (wait)
cdata->pi.item = item;