diff options
author | 2015-11-27 15:06:43 +0000 | |
---|---|---|
committer | 2015-11-27 15:06:43 +0000 | |
commit | 8ae71cbb81e6a97f6b0f8f8f0ddba8c9837e743f (patch) | |
tree | facedba4a31a3bcb326d5918ed3f195673c8cbf7 /usr.bin/tmux/cmd-list.c | |
parent | Keep lo(4) definitions inside if_loop.c (diff) | |
download | wireguard-openbsd-8ae71cbb81e6a97f6b0f8f8f0ddba8c9837e743f.tar.xz wireguard-openbsd-8ae71cbb81e6a97f6b0f8f8f0ddba8c9837e743f.zip |
Do not set a limit on the length of commands when printing them.
Diffstat (limited to 'usr.bin/tmux/cmd-list.c')
-rw-r--r-- | usr.bin/tmux/cmd-list.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/usr.bin/tmux/cmd-list.c b/usr.bin/tmux/cmd-list.c index 66eaeef1410..32505c13ed6 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.14 2014/09/01 21:50:18 nicm Exp $ */ +/* $OpenBSD: cmd-list.c,v 1.15 2015/11/27 15:06:43 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -99,25 +99,28 @@ cmd_list_free(struct cmd_list *cmdlist) free(cmdlist); } -size_t -cmd_list_print(struct cmd_list *cmdlist, char *buf, size_t len) +char * +cmd_list_print(struct cmd_list *cmdlist) { struct cmd *cmd; - size_t off, used; + char *buf, *this; + size_t len; + + len = 1; + buf = xcalloc(1, len); - off = 0; TAILQ_FOREACH(cmd, &cmdlist->list, qentry) { - if (off >= len) - break; - off += cmd_print(cmd, buf + off, len - off); - if (off >= len) - break; - if (TAILQ_NEXT(cmd, qentry) != NULL) { - used = xsnprintf(buf + off, len - off, " ; "); - if (used > len - off) - used = len - off; - off += used; - } + this = cmd_print(cmd); + + len += strlen(this) + 3; + buf = xrealloc(buf, len); + + strlcat(buf, this, len); + if (TAILQ_NEXT(cmd, qentry) != NULL) + strlcat(buf, " ; ", len); + + free(this); } - return (off); + + return (buf); } |