summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-04-13 16:19:38 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-04-13 16:19:38 +0000
commit6af0448783bd9a0505e6c6248be39e08292148cd (patch)
tree087db4ecb5e92230f244a6205c1f3c18598981b3 /usr.bin/tmux/cmd.c
parentbbcd02d308c01313ff44ba41376758f81178d8ab (diff)
When parsing strings, put all commands in one group even if there are
newlines. This means that for example bind q { a \n b } and bind q "a ; b" are the same. Also log commands in different groups separated by ;; rather than ; (a command list like this should never be user visible).
Diffstat (limited to 'usr.bin/tmux/cmd.c')
-rw-r--r--usr.bin/tmux/cmd.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c
index 8756c4f24f5..b4f0d863398 100644
--- a/usr.bin/tmux/cmd.c
+++ b/usr.bin/tmux/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.159 2020/04/13 15:55:51 nicm Exp $ */
+/* $OpenBSD: cmd.c,v 1.160 2020/04/13 16:19:37 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -624,7 +624,7 @@ cmd_list_free(struct cmd_list *cmdlist)
char *
cmd_list_print(struct cmd_list *cmdlist, int escaped)
{
- struct cmd *cmd;
+ struct cmd *cmd, *next;
char *buf, *this;
size_t len;
@@ -634,15 +634,24 @@ cmd_list_print(struct cmd_list *cmdlist, int escaped)
TAILQ_FOREACH(cmd, cmdlist->list, qentry) {
this = cmd_print(cmd);
- len += strlen(this) + 4;
+ len += strlen(this) + 6;
buf = xrealloc(buf, len);
strlcat(buf, this, len);
- if (TAILQ_NEXT(cmd, qentry) != NULL) {
- if (escaped)
- strlcat(buf, " \\; ", len);
- else
- strlcat(buf, " ; ", len);
+
+ next = TAILQ_NEXT(cmd, qentry);
+ if (next != NULL) {
+ if (cmd->group != next->group) {
+ if (escaped)
+ strlcat(buf, " \\;\\; ", len);
+ else
+ strlcat(buf, " ;; ", len);
+ } else {
+ if (escaped)
+ strlcat(buf, " \\; ", len);
+ else
+ strlcat(buf, " ; ", len);
+ }
}
free(this);