aboutsummaryrefslogtreecommitdiff
path: root/cmd-list.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd-list.c')
-rw-r--r--cmd-list.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/cmd-list.c b/cmd-list.c
index 08e2067c..0c75ed49 100644
--- a/cmd-list.c
+++ b/cmd-list.c
@@ -1,4 +1,4 @@
-/* $Id$ */
+/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -24,7 +24,7 @@
#include "tmux.h"
struct cmd_list *
-cmd_list_parse(int argc, char **argv, const char* file, u_int line,
+cmd_list_parse(int argc, char **argv, const char *file, u_int line,
char **cause)
{
struct cmd_list *cmdlist;
@@ -103,7 +103,7 @@ size_t
cmd_list_print(struct cmd_list *cmdlist, char *buf, size_t len)
{
struct cmd *cmd;
- size_t off;
+ size_t off, used;
off = 0;
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
@@ -112,8 +112,12 @@ cmd_list_print(struct cmd_list *cmdlist, char *buf, size_t len)
off += cmd_print(cmd, buf + off, len - off);
if (off >= len)
break;
- if (TAILQ_NEXT(cmd, qentry) != NULL)
- off += xsnprintf(buf + off, len - off, " ; ");
+ if (TAILQ_NEXT(cmd, qentry) != NULL) {
+ used = xsnprintf(buf + off, len - off, " ; ");
+ if (used > len - off)
+ used = len - off;
+ off += used;
+ }
}
return (off);
}