aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicm <nicm>2021-08-21 17:25:32 +0000
committernicm <nicm>2021-08-21 17:25:32 +0000
commit5241dae87de88906dc5c1dc271a4f25522a22d4c (patch)
tree17be354eb3556ed62cfdc74f2a8e4ecfe6599a22
parent68cacaec68ca8300e0ea439abdf9db16e74241bb (diff)
downloadrtmux-5241dae87de88906dc5c1dc271a4f25522a22d4c.tar.gz
rtmux-5241dae87de88906dc5c1dc271a4f25522a22d4c.tar.bz2
rtmux-5241dae87de88906dc5c1dc271a4f25522a22d4c.zip
Stop caring about empty commands, just treat as a null command.
-rw-r--r--cfg.c4
-rw-r--r--cmd-bind-key.c3
-rw-r--r--cmd-if-shell.c2
-rw-r--r--cmd-parse.y15
-rw-r--r--cmd-queue.c11
-rw-r--r--options.c4
-rw-r--r--server-client.c3
-rw-r--r--tmux.h1
-rw-r--r--window-customize.c3
9 files changed, 16 insertions, 30 deletions
diff --git a/cfg.c b/cfg.c
index cf6117f4..3130e323 100644
--- a/cfg.c
+++ b/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);
diff --git a/cmd-bind-key.c b/cmd-bind-key.c
index a16d054e..97057b3a 100644
--- a/cmd-bind-key.c
+++ b/cmd-bind-key.c
@@ -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);
diff --git a/cmd-if-shell.c b/cmd-if-shell.c
index 28e9b5d1..a04bdddd 100644
--- a/cmd-if-shell.c
+++ b/cmd-if-shell.c
@@ -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);
diff --git a/cmd-parse.y b/cmd-parse.y
index 458092b4..6be5d8a0 100644
--- a/cmd-parse.y
+++ b/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);
}
diff --git a/cmd-queue.c b/cmd-queue.c
index 806f1cbb..4fbdc4e7 100644
--- a/cmd-queue.c
+++ b/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);
diff --git a/options.c b/options.c
index 23c83c07..e32db774 100644
--- a/options.c
+++ b/options.c
@@ -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;
diff --git a/server-client.c b/server-client.c
index 87c0f554..8821ba57 100644
--- a/server-client.c
+++ b/server-client.c
@@ -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;
diff --git a/tmux.h b/tmux.h
index 3a825526..f8dcac49 100644
--- a/tmux.h
+++ b/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
};
diff --git a/window-customize.c b/window-customize.c
index 782542f7..0f09eba8 100644
--- a/window-customize.c
+++ b/window-customize.c
@@ -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;