summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-list-buffers.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux/cmd-list-buffers.c')
-rw-r--r--usr.bin/tmux/cmd-list-buffers.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/usr.bin/tmux/cmd-list-buffers.c b/usr.bin/tmux/cmd-list-buffers.c
index 0605724ba08..21c670060e2 100644
--- a/usr.bin/tmux/cmd-list-buffers.c
+++ b/usr.bin/tmux/cmd-list-buffers.c
@@ -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 <nicm@users.sourceforge.net>
@@ -19,7 +19,6 @@
#include <sys/types.h>
#include <string.h>
-#include <vis.h>
#include "tmux.h"
@@ -47,32 +46,17 @@ cmd_list_buffers_exec(struct cmd *self, struct cmd_ctx *ctx)
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);