summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-list.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2019-05-23 14:03:44 +0000
committernicm <nicm@openbsd.org>2019-05-23 14:03:44 +0000
commit5c131106bbf08e3f46edb3c5f7e7e6cdd6dad225 (patch)
treeca7f1b87659fbd485832a2b60a10fb5ada4e9d9b /usr.bin/tmux/cmd-list.c
parentDon't print "not conigured" messages for nodes that are disabled. (diff)
downloadwireguard-openbsd-5c131106bbf08e3f46edb3c5f7e7e6cdd6dad225.tar.xz
wireguard-openbsd-5c131106bbf08e3f46edb3c5f7e7e6cdd6dad225.zip
Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.
Diffstat (limited to 'usr.bin/tmux/cmd-list.c')
-rw-r--r--usr.bin/tmux/cmd-list.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/tmux/cmd-list.c b/usr.bin/tmux/cmd-list.c
index 6beaacbfcdf..f98c1b2c31d 100644
--- a/usr.bin/tmux/cmd-list.c
+++ b/usr.bin/tmux/cmd-list.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-list.c,v 1.18 2019/05/23 11:13:30 nicm Exp $ */
+/* $OpenBSD: cmd-list.c,v 1.19 2019/05/23 14:03:44 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -129,7 +129,7 @@ cmd_list_free(struct cmd_list *cmdlist)
}
char *
-cmd_list_print(struct cmd_list *cmdlist)
+cmd_list_print(struct cmd_list *cmdlist, int escaped)
{
struct cmd *cmd;
char *buf, *this;
@@ -141,12 +141,16 @@ cmd_list_print(struct cmd_list *cmdlist)
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
this = cmd_print(cmd);
- len += strlen(this) + 3;
+ len += strlen(this) + 4;
buf = xrealloc(buf, len);
strlcat(buf, this, len);
- if (TAILQ_NEXT(cmd, qentry) != NULL)
- strlcat(buf, " ; ", len);
+ if (TAILQ_NEXT(cmd, qentry) != NULL) {
+ if (escaped)
+ strlcat(buf, " \\; ", len);
+ else
+ strlcat(buf, " ; ", len);
+ }
free(this);
}