=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-list-buffers.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- src/usr.bin/tmux/cmd-list-buffers.c 2009/12/03 22:50:10 1.8 +++ src/usr.bin/tmux/cmd-list-buffers.c 2010/06/21 21:44:09 1.9 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-buffers.c,v 1.8 2009/12/03 22:50:10 nicm Exp $ */ +/* $OpenBSD: cmd-list-buffers.c,v 1.9 2010/06/21 21:44:09 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -19,7 +19,6 @@ #include #include -#include #include "tmux.h" @@ -47,32 +46,17 @@ struct session *s; struct paste_buffer *pb; u_int idx; - char tmp[51 * 4 + 1]; - size_t size, len; + char *tmp; if ((s = cmd_find_session(ctx, data->target)) == NULL) return (-1); idx = 0; while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) { - size = pb->size; - - /* Translate the first 50 characters. */ - len = size; - if (len > 50) - len = 50; - strvisx(tmp, pb->data, len, VIS_OCTAL|VIS_TAB|VIS_NL); - - /* - * If the first 50 characters were encoded as a longer string, - * or there is definitely more data, add "...". - */ - if (size > 50 || strlen(tmp) > 50) { - tmp[50 - 3] = '\0'; - strlcat(tmp, "...", sizeof tmp); - } - - ctx->print(ctx, "%u: %zu bytes: \"%s\"", idx - 1, size, tmp); + tmp = paste_print(pb, 50); + ctx->print(ctx, + "%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp); + xfree(tmp); } return (0);