mirror of
https://github.com/tmux/tmux.git
synced 2024-11-17 18:08:51 +00:00
Stop caring about empty commands, just treat as a null command.
This commit is contained in:
parent
68cacaec68
commit
5241dae87d
4
cfg.c
4
cfg.c
@ -125,8 +125,6 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
|
||||
|
||||
pr = cmd_parse_from_file(f, &pi);
|
||||
fclose(f);
|
||||
if (pr->status == CMD_PARSE_EMPTY)
|
||||
return (0);
|
||||
if (pr->status == CMD_PARSE_ERROR) {
|
||||
cfg_add_cause("%s", pr->error);
|
||||
free(pr->error);
|
||||
@ -179,8 +177,6 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path,
|
||||
pi.c = c;
|
||||
|
||||
pr = cmd_parse_from_buffer(buf, len, &pi);
|
||||
if (pr->status == CMD_PARSE_EMPTY)
|
||||
return (0);
|
||||
if (pr->status == CMD_PARSE_ERROR) {
|
||||
cfg_add_cause("%s", pr->error);
|
||||
free(pr->error);
|
||||
|
@ -75,9 +75,6 @@ cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
|
||||
cmd_free_argv(argc, argv);
|
||||
}
|
||||
switch (pr->status) {
|
||||
case CMD_PARSE_EMPTY:
|
||||
cmdq_error(item, "empty command");
|
||||
return (CMD_RETURN_ERROR);
|
||||
case CMD_PARSE_ERROR:
|
||||
cmdq_error(item, "%s", pr->error);
|
||||
free(pr->error);
|
||||
|
@ -159,8 +159,6 @@ cmd_if_shell_callback(struct job *job)
|
||||
|
||||
pr = cmd_parse_from_string(cmd, &cdata->input);
|
||||
switch (pr->status) {
|
||||
case CMD_PARSE_EMPTY:
|
||||
break;
|
||||
case CMD_PARSE_ERROR:
|
||||
if (cdata->item != NULL)
|
||||
cmdq_error(cdata->item, "%s", pr->error);
|
||||
|
15
cmd-parse.y
15
cmd-parse.y
@ -744,7 +744,8 @@ cmd_parse_expand_alias(struct cmd_parse_command *cmd,
|
||||
|
||||
first = TAILQ_FIRST(&cmd->arguments);
|
||||
if (first == NULL || first->type != CMD_PARSE_STRING) {
|
||||
pr->status = CMD_PARSE_EMPTY;
|
||||
pr->status = CMD_PARSE_SUCCESS;
|
||||
pr->cmdlist = cmd_list_new();
|
||||
return (1);
|
||||
}
|
||||
name = first->string;
|
||||
@ -840,7 +841,8 @@ cmd_parse_build_commands(struct cmd_parse_commands *cmds,
|
||||
|
||||
/* Check for an empty list. */
|
||||
if (TAILQ_EMPTY(cmds)) {
|
||||
pr->status = CMD_PARSE_EMPTY;
|
||||
pr->status = CMD_PARSE_SUCCESS;
|
||||
pr->cmdlist = cmd_list_new();
|
||||
return;
|
||||
}
|
||||
cmd_parse_log_commands(cmds, __func__);
|
||||
@ -942,8 +944,6 @@ cmd_parse_and_insert(const char *s, struct cmd_parse_input *pi,
|
||||
|
||||
pr = cmd_parse_from_string(s, pi);
|
||||
switch (pr->status) {
|
||||
case CMD_PARSE_EMPTY:
|
||||
break;
|
||||
case CMD_PARSE_ERROR:
|
||||
if (error != NULL)
|
||||
*error = pr->error;
|
||||
@ -968,8 +968,6 @@ cmd_parse_and_append(const char *s, struct cmd_parse_input *pi,
|
||||
|
||||
pr = cmd_parse_from_string(s, pi);
|
||||
switch (pr->status) {
|
||||
case CMD_PARSE_EMPTY:
|
||||
break;
|
||||
case CMD_PARSE_ERROR:
|
||||
if (error != NULL)
|
||||
*error = pr->error;
|
||||
@ -1000,9 +998,8 @@ cmd_parse_from_buffer(const void *buf, size_t len, struct cmd_parse_input *pi)
|
||||
memset(&pr, 0, sizeof pr);
|
||||
|
||||
if (len == 0) {
|
||||
pr.status = CMD_PARSE_EMPTY;
|
||||
pr.cmdlist = NULL;
|
||||
pr.error = NULL;
|
||||
pr.status = CMD_PARSE_SUCCESS;
|
||||
pr.cmdlist = cmd_list_new();
|
||||
return (&pr);
|
||||
}
|
||||
|
||||
|
11
cmd-queue.c
11
cmd-queue.c
@ -478,6 +478,13 @@ cmdq_remove_group(struct cmdq_item *item)
|
||||
}
|
||||
}
|
||||
|
||||
/* Empty command callback. */
|
||||
static enum cmd_retval
|
||||
cmdq_empty_command(__unused struct cmdq_item *item, __unused void *data)
|
||||
{
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
/* Get a command for the command queue. */
|
||||
struct cmdq_item *
|
||||
cmdq_get_command(struct cmd_list *cmdlist, struct cmdq_state *state)
|
||||
@ -487,12 +494,14 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmdq_state *state)
|
||||
const struct cmd_entry *entry;
|
||||
int created = 0;
|
||||
|
||||
if ((cmd = cmd_list_first(cmdlist)) == NULL)
|
||||
return (cmdq_get_callback(cmdq_empty_command, NULL));
|
||||
|
||||
if (state == NULL) {
|
||||
state = cmdq_new_state(NULL, NULL, 0);
|
||||
created = 1;
|
||||
}
|
||||
|
||||
cmd = cmd_list_first(cmdlist);
|
||||
while (cmd != NULL) {
|
||||
entry = cmd_get_entry(cmd);
|
||||
|
||||
|
@ -443,10 +443,6 @@ options_array_set(struct options_entry *o, u_int idx, const char *value,
|
||||
if (OPTIONS_IS_COMMAND(o)) {
|
||||
pr = cmd_parse_from_string(value, NULL);
|
||||
switch (pr->status) {
|
||||
case CMD_PARSE_EMPTY:
|
||||
if (cause != NULL)
|
||||
*cause = xstrdup("empty command");
|
||||
return (-1);
|
||||
case CMD_PARSE_ERROR:
|
||||
if (cause != NULL)
|
||||
*cause = pr->error;
|
||||
|
@ -2151,9 +2151,6 @@ server_client_dispatch_command(struct client *c, struct imsg *imsg)
|
||||
|
||||
pr = cmd_parse_from_arguments(argc, argv, NULL);
|
||||
switch (pr->status) {
|
||||
case CMD_PARSE_EMPTY:
|
||||
cause = xstrdup("empty command");
|
||||
goto error;
|
||||
case CMD_PARSE_ERROR:
|
||||
cause = pr->error;
|
||||
goto error;
|
||||
|
1
tmux.h
1
tmux.h
@ -1417,7 +1417,6 @@ enum cmd_retval {
|
||||
|
||||
/* Command parse result. */
|
||||
enum cmd_parse_status {
|
||||
CMD_PARSE_EMPTY,
|
||||
CMD_PARSE_ERROR,
|
||||
CMD_PARSE_SUCCESS
|
||||
};
|
||||
|
@ -1185,9 +1185,6 @@ window_customize_set_command_callback(struct client *c, void *itemdata,
|
||||
|
||||
pr = cmd_parse_from_string(s, NULL);
|
||||
switch (pr->status) {
|
||||
case CMD_PARSE_EMPTY:
|
||||
error = xstrdup("empty command");
|
||||
goto fail;
|
||||
case CMD_PARSE_ERROR:
|
||||
error = pr->error;
|
||||
goto fail;
|
||||
|
Loading…
Reference in New Issue
Block a user