aboutsummaryrefslogtreecommitdiff
path: root/cmd.c
diff options
context:
space:
mode:
authornicm <nicm>2015-11-27 15:06:43 +0000
committernicm <nicm>2015-11-27 15:06:43 +0000
commit6a2ca34216530c687027cf9e767d2b46c85976e6 (patch)
tree9f0cb8f7f41ea4e93102bc764f7388ae6b5b0d5c /cmd.c
parentac8678aefe157d7e40c5bcedd12333eaedf0df92 (diff)
downloadrtmux-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.c')
-rw-r--r--cmd.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/cmd.c b/cmd.c
index 0c20d656..824d9caf 100644
--- a/cmd.c
+++ b/cmd.c
@@ -384,21 +384,19 @@ usage:
return (NULL);
}
-size_t
-cmd_print(struct cmd *cmd, char *buf, size_t len)
+char *
+cmd_print(struct cmd *cmd)
{
- size_t off, used;
+ char *out, *s;
- off = xsnprintf(buf, len, "%s ", cmd->entry->name);
- if (off + 1 < len) {
- used = args_print(cmd->args, buf + off, len - off - 1);
- if (used == 0)
- off--;
- else
- off += used;
- buf[off] = '\0';
- }
- return (off);
+ s = args_print(cmd->args);
+ if (*s != '\0')
+ xasprintf(&out, "%s %s", cmd->entry->name, s);
+ else
+ out = xstrdup(cmd->entry->name);
+ free(s);
+
+ return (out);
}
/* Adjust current mouse position for a pane. */