mirror of
https://github.com/tmate-io/tmate.git
synced 2025-08-17 17:11:38 +02:00
Do not set a limit on the length of commands when printing them.
This commit is contained in:
35
cmd-list.c
35
cmd-list.c
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user