diff --git a/cfg.c b/cfg.c index 8e8b7d79d..68d2d406e 100644 --- a/cfg.c +++ b/cfg.c @@ -98,7 +98,6 @@ load_cfg(const char *path, struct cmdq_item *item, { FILE *f; struct cmd_parse_input pi; - struct cmd_invoke_input ci; struct cmd_parse_tree *tree; struct cmdq_item *new_item0; struct cmdq_state *state; @@ -138,10 +137,7 @@ load_cfg(const char *path, struct cmdq_item *item, state = cmdq_new_state(NULL, NULL, 0); cmdq_add_format(state, "current_file", "%s", pi.file); - memset(&ci, 0, sizeof ci); - ci.file = pi.file; - ci.flags = flags; - new_item0 = cmd_invoke_get(tree, state, &ci); + new_item0 = cmd_invoke_get(tree, state, NULL); if (item != NULL) new_item0 = cmdq_insert_after(item, new_item0); else @@ -160,7 +156,6 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path, struct cmdq_item **new_item) { struct cmd_parse_input pi; - struct cmd_invoke_input ci; struct cmd_parse_tree *tree; struct cmdq_item *new_item0; struct cmdq_state *state; @@ -193,10 +188,7 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path, state = cmdq_new_state(NULL, NULL, 0); cmdq_add_format(state, "current_file", "%s", pi.file); - memset(&ci, 0, sizeof ci); - ci.file = pi.file; - ci.flags = flags; - new_item0 = cmd_invoke_get(tree, state, &ci); + new_item0 = cmd_invoke_get(tree, state, NULL); if (item != NULL) new_item0 = cmdq_insert_after(item, new_item0); else diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c index 18030399f..b9f1de90e 100644 --- a/cmd-command-prompt.c +++ b/cmd-command-prompt.c @@ -58,8 +58,6 @@ struct cmd_command_prompt_prompt { struct cmd_command_prompt_cdata { struct cmdq_item *item; struct cmd_parse_tree *tree; - char *file; - int parse_flags; int flags; enum prompt_type prompt_type; @@ -118,10 +116,6 @@ cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item) free(cdata); return (CMD_RETURN_ERROR); } - cmd_get_source(self, &file, NULL); - if (file != NULL) - cdata->file = xstrdup(file); - cdata->parse_flags = cmd_get_parse_flags(self); } if ((s = args_get(args, 'p')) == NULL) { @@ -259,8 +253,6 @@ cmd_command_prompt_callback(struct client *c, void *data, const char *s, /* Explicit body: prompt inputs become the template argv. */ ci.argc = argc; ci.argv = argv; - ci.file = cdata->file; - ci.flags = cdata->parse_flags; new_item = cmd_invoke_get(cdata->tree, cs, &ci); if (item == NULL) cmdq_append(c, new_item); @@ -320,6 +312,5 @@ cmd_command_prompt_free(void *data) free(cdata->prompts); cmd_free_argv(cdata->argc, cdata->argv); cmd_parse_free(cdata->tree); - free(cdata->file); free(cdata); } diff --git a/cmd-confirm-before.c b/cmd-confirm-before.c index df9bf5c8b..8a247c012 100644 --- a/cmd-confirm-before.c +++ b/cmd-confirm-before.c @@ -52,8 +52,6 @@ const struct cmd_entry cmd_confirm_before_entry = { struct cmd_confirm_before_data { struct cmdq_item *item; struct cmd_parse_tree *tree; - char *file; - int parse_flags; u_char confirm_key; int default_yes; }; @@ -73,7 +71,7 @@ cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item) struct client *tc = cmdq_get_target_client(item); struct cmd_find_state *target = cmdq_get_target(item); char *new_prompt, *cause = NULL; - const char *confirm_key, *prompt, *cmd, *file; + const char *confirm_key, *prompt, *cmd; int wait = !args_has(args, 'b'), n; cdata = xcalloc(1, sizeof *cdata); @@ -84,10 +82,6 @@ cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item) free(cdata); return (CMD_RETURN_ERROR); } - cmd_get_source(self, &file, NULL); - if (file != NULL) - cdata->file = xstrdup(file); - cdata->parse_flags = cmd_get_parse_flags(self); if (wait) cdata->item = item; @@ -133,7 +127,6 @@ cmd_confirm_before_callback(struct client *c, void *data, const char *s, struct cmd_confirm_before_data *cdata = data; struct cmdq_item *item = cdata->item, *new_item; struct cmdq_state *cs; - struct cmd_invoke_input ci = { 0 }; int retcode = 1; if (c->flags & CLIENT_DEAD) @@ -145,14 +138,12 @@ cmd_confirm_before_callback(struct client *c, void *data, const char *s, goto out; retcode = 0; - ci.file = cdata->file; - ci.flags = cdata->parse_flags; if (item == NULL) { - new_item = cmd_invoke_get(cdata->tree, NULL, &ci); + new_item = cmd_invoke_get(cdata->tree, NULL, NULL); cmdq_append(c, new_item); } else { cs = cmdq_get_state(item); - new_item = cmd_invoke_get(cdata->tree, cs, &ci); + new_item = cmd_invoke_get(cdata->tree, cs, NULL); cmdq_insert_after(item, new_item); } @@ -172,6 +163,5 @@ cmd_confirm_before_free(void *data) struct cmd_confirm_before_data *cdata = data; cmd_parse_free(cdata->tree); - free(cdata->file); free(cdata); } diff --git a/cmd-display-panes.c b/cmd-display-panes.c index daae09f8d..baa855333 100644 --- a/cmd-display-panes.c +++ b/cmd-display-panes.c @@ -46,8 +46,6 @@ const struct cmd_entry cmd_display_panes_entry = { struct cmd_display_panes_data { struct cmdq_item *item; struct cmd_parse_tree *tree; - char *file; - int parse_flags; }; struct cmd_display_panes_ctx { @@ -300,7 +298,6 @@ cmd_display_panes_free(__unused struct client *c, void *data) if (cdata->item != NULL) cmdq_continue(cdata->item); cmd_parse_free(cdata->tree); - free(cdata->file); free(cdata); } @@ -336,8 +333,6 @@ cmd_display_panes_key(struct client *c, void *data, struct key_event *event) xasprintf(&expanded, "%%%u", wp->id); ci.argc = 1; ci.argv = &expanded; - ci.file = cdata->file; - ci.flags = cdata->parse_flags; if (item != NULL) cs = cmdq_get_state(item); @@ -359,7 +354,6 @@ cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item) struct session *s = tc->session; u_int delay; char *cause; - const char *file; struct cmd_display_panes_data *cdata; int wait = !args_has(args, 'b'); @@ -388,10 +382,6 @@ cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item) free(cdata); return (CMD_RETURN_ERROR); } - cmd_get_source(self, &file, NULL); - if (file != NULL) - cdata->file = xstrdup(file); - cdata->parse_flags = cmd_get_parse_flags(self); if (args_has(args, 'N')) { server_client_set_overlay(tc, delay, NULL, NULL, diff --git a/cmd-if-shell.c b/cmd-if-shell.c index 1a0b85873..9aae9745a 100644 --- a/cmd-if-shell.c +++ b/cmd-if-shell.c @@ -56,8 +56,6 @@ struct cmd_if_shell_data { struct cmd_parse_tree *cmd_if; struct cmd_parse_tree *cmd_else; - char *file; - int parse_flags; struct client *client; struct cmdq_item *item; @@ -80,8 +78,6 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item) struct cmd_if_shell_data *cdata; struct cmdq_item *new_item; struct cmd_parse_tree *tree; - struct cmd_invoke_input input = { 0 }; - const char *file; char *shellcmd, *cause = NULL; struct client *tc = cmdq_get_target_client(item); struct session *s = target->s; @@ -106,10 +102,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item) free(cause); return (CMD_RETURN_ERROR); } - cmd_get_source(self, &file, NULL); - input.file = file; - input.flags = cmd_get_parse_flags(self); - new_item = cmd_invoke_get(tree, cmdq_get_state(item), &input); + new_item = cmd_invoke_get(tree, cmdq_get_state(item), NULL); cmd_parse_free(tree); cmdq_insert_after(item, new_item); return (CMD_RETURN_NORMAL); @@ -129,10 +122,6 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item) goto fail; } } - cmd_get_source(self, &file, NULL); - if (file != NULL) - cdata->file = xstrdup(file); - cdata->parse_flags = cmd_get_parse_flags(self); if (!wait) cdata->client = tc; @@ -170,7 +159,6 @@ cmd_if_shell_callback(struct job *job) struct client *c = cdata->client; struct cmdq_item *item = cdata->item, *new_item; struct cmd_parse_tree *tree; - struct cmd_invoke_input input = { 0 }; int status; status = job_get_status(job); @@ -181,13 +169,11 @@ cmd_if_shell_callback(struct job *job) if (tree == NULL) goto out; - input.file = cdata->file; - input.flags = cdata->parse_flags; if (item == NULL) { - new_item = cmd_invoke_get(tree, NULL, &input); + new_item = cmd_invoke_get(tree, NULL, NULL); cmdq_append(c, new_item); } else { - new_item = cmd_invoke_get(tree, cmdq_get_state(item), &input); + new_item = cmd_invoke_get(tree, cmdq_get_state(item), NULL); cmdq_insert_after(item, new_item); } @@ -208,6 +194,5 @@ cmd_if_shell_free(void *data) cmd_parse_free(cdata->cmd_else); if (cdata->cmd_if != NULL) cmd_parse_free(cdata->cmd_if); - free(cdata->file); free(cdata); } diff --git a/cmd-invoke.c b/cmd-invoke.c index 97ffb7e5f..82368870a 100644 --- a/cmd-invoke.c +++ b/cmd-invoke.c @@ -342,9 +342,9 @@ cmd_invoke_build_command(struct cmdq_item *item, struct cmd_invoke_state *is, struct cmd_parse_node *child; struct args_value *values = NULL; struct cmd *cmd; - const char *file = cmd_parse_file(is->tree); + const char *file = cmd_parse_file(tree); u_int line = cmd_parse_node_line(node); - int flags = cmd_parse_flags(is->tree); + int flags = cmd_parse_flags(tree); char *cause = NULL; u_int count = 0; @@ -497,16 +497,16 @@ cmd_invoke_fire(struct cmdq_item *item, struct cmd_invoke_state *is) break; case CMD_PARSE_ASSIGN: case CMD_PARSE_HIDDEN_ASSIGN: - if (cmd_invoke_assignment(item, is, node) != 0) { - cmdq_error(item, "bad assignment"); - cmd_invoke_skip_sequence(is); - } + if (cmd_invoke_assignment(item, is, node) == 0) + break; + cmd_invoke_error(item, is, node, "bad assignment"); + cmd_invoke_skip_sequence(is); break; case CMD_PARSE_IF: - if (cmd_invoke_if(item, is, node) != 0) { - cmdq_error(item, "bad condition"); - cmd_invoke_skip_sequence(is); - } + if (cmd_invoke_if(item, is, node) == 0) + break; + cmd_invoke_error(item, is, node, "bad condition"); + cmd_invoke_skip_sequence(is); break; case CMD_PARSE_ELIF: case CMD_PARSE_ELSE: diff --git a/cmd-parse.y b/cmd-parse.y index 4da4a7042..c1a5dfd06 100644 --- a/cmd-parse.y +++ b/cmd-parse.y @@ -1285,6 +1285,7 @@ cmd_parse_command_any_have(struct cmd_parse_tree *tree, struct cmd_parse_node *node, int flag) { struct cmd_parse_node *child; + int flags = tree->flags; struct args_value *values = NULL; struct cmd *cmd; char *cause = NULL; @@ -1317,7 +1318,7 @@ cmd_parse_command_any_have(struct cmd_parse_tree *tree, count++; } - cmd = cmd_parse(values, count, NULL, node->line, 0, &cause); + cmd = cmd_parse(values, count, tree->file, node->line, flags, &cause); if (cmd == NULL) { free(cause); found = -1; diff --git a/cmd-run-shell.c b/cmd-run-shell.c index f4ecf9706..16c98ae9a 100644 --- a/cmd-run-shell.c +++ b/cmd-run-shell.c @@ -58,8 +58,6 @@ struct cmd_run_shell_data { struct client *client; char *cmd; struct cmd_parse_tree *tree; - char *file; - int parse_flags; char *cwd; struct cmdq_item *item; struct session *s; @@ -92,7 +90,7 @@ cmd_run_shell_print(struct job *job, const char *msg) cmdq_print(cdata->item, "%s", msg); return; } - if (cdata->item != NULL && cdata->client != NULL) + if (cdata->client != NULL) wp = server_client_get_pane(cdata->client); if (wp == NULL && cmd_find_from_nothing(&fs, 0) == 0) wp = fs.wp; @@ -116,7 +114,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item) struct client *tc = cmdq_get_target_client(item); struct session *s = target->s; struct window_pane *wp = target->wp; - const char *delay, *cmd, *file; + const char *delay, *cmd; struct format_tree *ft; double d; struct timeval tv; @@ -155,10 +153,6 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item) cmd_run_shell_free(cdata); return (CMD_RETURN_ERROR); } - cmd_get_source(self, &file, NULL); - if (file != NULL) - cdata->file = xstrdup(file); - cdata->parse_flags = cmd_get_parse_flags(self); } if (args_has(args, 't') && wp != NULL) @@ -212,7 +206,6 @@ cmd_run_shell_timer(__unused int fd, __unused short events, void* arg) const char *cmd = cdata->cmd; struct cmdq_item *item = cdata->item, *new_item; struct cmdq_state *cs = NULL; - struct cmd_invoke_input input = { 0 }; if (cdata->tree == NULL) { if (cmd == NULL) { @@ -239,9 +232,7 @@ cmd_run_shell_timer(__unused int fd, __unused short events, void* arg) if (item != NULL) cs = cmdq_get_state(item); - input.file = cdata->file; - input.flags = cdata->parse_flags; - new_item = cmd_invoke_get(cdata->tree, cs, &input); + new_item = cmd_invoke_get(cdata->tree, cs, NULL); if (item == NULL) cmdq_append(c, new_item); else @@ -314,7 +305,6 @@ cmd_run_shell_free(void *data) if (cdata->client != NULL) server_client_unref(cdata->client); cmd_parse_free(cdata->tree); - free(cdata->file); free(cdata->cwd); free(cdata->cmd); free(cdata); diff --git a/tmux.h b/tmux.h index ac36c7509..ee157a51f 100644 --- a/tmux.h +++ b/tmux.h @@ -1971,9 +1971,6 @@ struct cmd_entry { /* Command invocation input. */ struct cmd_invoke_input { - const char *file; - int flags; - int argc; char **argv; };