diff options
author | nicm <nicm> | 2015-11-27 15:06:43 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-11-27 15:06:43 +0000 |
commit | 6a2ca34216530c687027cf9e767d2b46c85976e6 (patch) | |
tree | 9f0cb8f7f41ea4e93102bc764f7388ae6b5b0d5c /cmd-list.c | |
parent | ac8678aefe157d7e40c5bcedd12333eaedf0df92 (diff) | |
download | rtmux-6a2ca34216530c687027cf9e767d2b46c85976e6.tar.gz rtmux-6a2ca34216530c687027cf9e767d2b46c85976e6.tar.bz2 rtmux-6a2ca34216530c687027cf9e767d2b46c85976e6.zip |
Do not set a limit on the length of commands when printing them.
Diffstat (limited to 'cmd-list.c')
-rw-r--r-- | cmd-list.c | 35 |
1 files changed, 19 insertions, 16 deletions
@@ -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); } |