summaryrefslogtreecommitdiffstats
path: root/grid.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-11-18 17:02:17 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-11-18 17:02:17 +0000
commita78cc98c8bd79cecbb8574a9dff4c9867a8308d9 (patch)
tree479fa44868219f4e3c39720a6c0068f947ac36d5 /grid.c
parent8db145da1ed40d471e9ecff0e788ced26a43fc92 (diff)
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 'grid.c')
-rw-r--r--grid.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/grid.c b/grid.c
index 1041528d..a49c06bd 100644
--- a/grid.c
+++ b/grid.c
@@ -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);