aboutsummaryrefslogtreecommitdiff
path: root/cmd.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2015-11-27 15:41:28 +0000
committerThomas Adam <thomas@xteddy.org>2015-11-27 15:41:28 +0000
commit9fe8b28746faa5d38c25853449127d526beac8f9 (patch)
treea7d9f07efdbce0d4be8f8920efb7ccde1c5b308d /cmd.c
parent3b83bda29c51c7b2c3aeef01dde1d3ba6a441e89 (diff)
parent6a2ca34216530c687027cf9e767d2b46c85976e6 (diff)
downloadrtmux-9fe8b28746faa5d38c25853449127d526beac8f9.tar.gz
rtmux-9fe8b28746faa5d38c25853449127d526beac8f9.tar.bz2
rtmux-9fe8b28746faa5d38c25853449127d526beac8f9.zip
Merge branch 'obsd-master'
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 badfcb4a..21e0f0c3 100644
--- a/cmd.c
+++ b/cmd.c
@@ -383,21 +383,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. */