summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/grid.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2009-11-18 17:02:17 +0000
committernicm <nicm@openbsd.org>2009-11-18 17:02:17 +0000
commitcb1fe32b53dde477c7e9087195a8f77403d032d0 (patch)
treece342e4d3548a17182ce517e9fb95f658bfe17e5 /usr.bin/tmux/grid.c
parentAdd a per-client log of status line messages displayed while that client (diff)
downloadwireguard-openbsd-cb1fe32b53dde477c7e9087195a8f77403d032d0.tar.xz
wireguard-openbsd-cb1fe32b53dde477c7e9087195a8f77403d032d0.zip
Cleanup by moving various (mostly horrible) little bits handling UTF-8 grid
data into functions in a new file, grid-utf8.c, and use sizeof intead of UTF8_DATA. Also nuke trailing whitespace from tmux.1, reminded by jmc.
Diffstat (limited to 'usr.bin/tmux/grid.c')
-rw-r--r--usr.bin/tmux/grid.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c
index c021bf364f2..d6082aa3fb7 100644
--- a/usr.bin/tmux/grid.c
+++ b/usr.bin/tmux/grid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grid.c,v 1.15 2009/10/13 15:38:37 nicm Exp $ */
+/* $OpenBSD: grid.c,v 1.16 2009/11/18 17:02:17 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -502,8 +502,8 @@ grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx)
const struct grid_cell *gc;
const struct grid_utf8 *gu;
char *buf;
- size_t len, off;
- u_int xx, i;
+ size_t len, off, size;
+ u_int xx;
GRID_DEBUG(gd, "px=%u, py=%u, nx=%u", px, py, nx);
@@ -517,17 +517,15 @@ grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx)
continue;
if (gc->flags & GRID_FLAG_UTF8) {
- while (len < off + UTF8_SIZE + 1) {
+ gu = grid_peek_utf8(gd, xx, py);
+
+ size = grid_utf8_size(gu);
+ while (len < off + size + 1) {
buf = xrealloc(buf, 2, len);
len *= 2;
}
- gu = grid_peek_utf8(gd, xx, py);
- for (i = 0; i < UTF8_SIZE; i++) {
- if (gu->data[i] == 0xff)
- break;
- buf[off++] = gu->data[i];
- }
+ off += grid_utf8_copy(gu, buf + off, len - off);
} else {
while (len < off + 2) {
buf = xrealloc(buf, 2, len);