=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/paste.c,v retrieving revision 1.16 retrieving revision 1.17 diff -c -r1.16 -r1.17 *** src/usr.bin/tmux/paste.c 2014/03/31 21:39:31 1.16 --- src/usr.bin/tmux/paste.c 2014/04/02 18:12:18 1.17 *************** *** 1,4 **** ! /* $OpenBSD: paste.c,v 1.16 2014/03/31 21:39:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: paste.c,v 1.17 2014/04/02 18:12:18 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 148,172 **** return (0); } ! /* Convert a buffer into a visible string. */ char * ! paste_print(struct paste_buffer *pb, size_t width) { ! char *buf; ! size_t len, used; - if (width < 3) - width = 3; - buf = xmalloc(width * 4 + 1); - len = pb->size; if (len > width) len = width; ! used = strvisx(buf, pb->data, len, VIS_OCTAL|VIS_TAB|VIS_NL); if (pb->size > width || used > width) ! strlcpy(buf + width - 3, "...", 4); ! return (buf); } --- 148,173 ---- return (0); } ! /* Convert start of buffer into a nice string. */ char * ! paste_make_sample(struct paste_buffer *pb, int utf8flag) { ! char *buf; ! size_t len, used; ! const int flags = VIS_OCTAL|VIS_TAB|VIS_NL; ! const size_t width = 200; len = pb->size; if (len > width) len = width; + buf = xmalloc(len * 4 + 4); ! if (utf8flag) ! used = utf8_strvis(buf, pb->data, len, flags); ! else ! used = strvisx(buf, pb->data, len, flags); if (pb->size > width || used > width) ! strlcpy(buf + width, "...", 4); return (buf); }