diff options
author | nicm <nicm> | 2020-04-13 16:19:37 +0000 |
---|---|---|
committer | nicm <nicm> | 2020-04-13 16:19:37 +0000 |
commit | 34804f2709a16dca45dc072fb53d03f79db61e51 (patch) | |
tree | f48af448b3e6ed6b91207a828b7603e0f407ef48 /cmd.c | |
parent | 3f86d6d46014ca55e42cecd570d7f269b1d386b3 (diff) | |
download | rtmux-34804f2709a16dca45dc072fb53d03f79db61e51.tar.gz rtmux-34804f2709a16dca45dc072fb53d03f79db61e51.tar.bz2 rtmux-34804f2709a16dca45dc072fb53d03f79db61e51.zip |
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 'cmd.c')
-rw-r--r-- | cmd.c | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -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); |