summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2021-08-21 17:25:33 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2021-08-21 17:25:33 +0000
commit875c2b0b8f7f7acb0557452e782e2da8db5adab7 (patch)
tree1f40398f1fc71878d6173c4b12e273eb99f0e8bb
parentcfe83787625d008d51ad0a0b535fed82147c5ac7 (diff)
Stop caring about empty commands, just treat as a null command.
-rw-r--r--usr.bin/tmux/cfg.c6
-rw-r--r--usr.bin/tmux/cmd-bind-key.c5
-rw-r--r--usr.bin/tmux/cmd-if-shell.c4
-rw-r--r--usr.bin/tmux/cmd-parse.y17
-rw-r--r--usr.bin/tmux/cmd-queue.c13
-rw-r--r--usr.bin/tmux/options.c6
-rw-r--r--usr.bin/tmux/server-client.c5
-rw-r--r--usr.bin/tmux/tmux.h3
-rw-r--r--usr.bin/tmux/window-customize.c5
9 files changed, 25 insertions, 39 deletions
diff --git a/usr.bin/tmux/cfg.c b/usr.bin/tmux/cfg.c
index fe053e87ca7..b0dd37013ee 100644
--- a/usr.bin/tmux/cfg.c
+++ b/usr.bin/tmux/cfg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cfg.c,v 1.83 2021/04/07 12:50:12 nicm Exp $ */
+/* $OpenBSD: cfg.c,v 1.84 2021/08/21 17:25:32 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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/usr.bin/tmux/cmd-bind-key.c b/usr.bin/tmux/cmd-bind-key.c
index 6508bf8b39e..1ad89b805e0 100644
--- a/usr.bin/tmux/cmd-bind-key.c
+++ b/usr.bin/tmux/cmd-bind-key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-bind-key.c,v 1.40 2021/08/21 10:22:38 nicm Exp $ */
+/* $OpenBSD: cmd-bind-key.c,v 1.41 2021/08/21 17:25:32 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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/usr.bin/tmux/cmd-if-shell.c b/usr.bin/tmux/cmd-if-shell.c
index ec0394bada9..60832901cb4 100644
--- a/usr.bin/tmux/cmd-if-shell.c
+++ b/usr.bin/tmux/cmd-if-shell.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-if-shell.c,v 1.78 2021/08/21 10:22:39 nicm Exp $ */
+/* $OpenBSD: cmd-if-shell.c,v 1.79 2021/08/21 17:25:32 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -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/usr.bin/tmux/cmd-parse.y b/usr.bin/tmux/cmd-parse.y
index 14e39e80ae6..895f43e9214 100644
--- a/usr.bin/tmux/cmd-parse.y
+++ b/usr.bin/tmux/cmd-parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-parse.y,v 1.38 2021/08/21 14:06:17 nicm Exp $ */
+/* $OpenBSD: cmd-parse.y,v 1.39 2021/08/21 17:25:32 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c
index 5ec234b42bb..7d36f3cb8be 100644
--- a/usr.bin/tmux/cmd-queue.c
+++ b/usr.bin/tmux/cmd-queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-queue.c,v 1.106 2021/08/21 10:28:05 nicm Exp $ */
+/* $OpenBSD: cmd-queue.c,v 1.107 2021/08/21 17:25:32 nicm Exp $ */
/*
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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/usr.bin/tmux/options.c b/usr.bin/tmux/options.c
index c07d69198ed..c429f319eea 100644
--- a/usr.bin/tmux/options.c
+++ b/usr.bin/tmux/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.63 2021/08/11 20:49:55 nicm Exp $ */
+/* $OpenBSD: options.c,v 1.64 2021/08/21 17:25:32 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 3a489378b10..3bcc496547b 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.382 2021/08/20 19:08:36 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.383 2021/08/21 17:25:32 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index e4dabcb92e2..01c574fade7 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.1131 2021/08/21 14:06:17 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1132 2021/08/21 17:25:32 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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/usr.bin/tmux/window-customize.c b/usr.bin/tmux/window-customize.c
index efbb4a48a08..ea9dae79894 100644
--- a/usr.bin/tmux/window-customize.c
+++ b/usr.bin/tmux/window-customize.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-customize.c,v 1.11 2021/06/10 07:50:04 nicm Exp $ */
+/* $OpenBSD: window-customize.c,v 1.12 2021/08/21 17:25:32 nicm Exp $ */
/*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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;