summaryrefslogtreecommitdiffstats
path: root/grid.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-11-19 22:23:27 +0000
committerTiago Cunha <tcunha@gmx.com>2009-11-19 22:23:27 +0000
commita0b2b8e875f5118203125e048f1d89029462f98d (patch)
tree9d4e18cf622e6f641443c326725f30ff65617f52 /grid.c
parentacc331c787f4d85c0909563139f7cc81c54edc55 (diff)
Sync OpenBSD patchset 547:
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.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/grid.c b/grid.c
index 3c092534..53b29e39 100644
--- a/grid.c
+++ b/grid.c
@@ -1,4 +1,4 @@
-/* $Id: grid.c,v 1.34 2009-10-15 01:55:12 tcunha Exp $ */
+/* $Id: grid.c,v 1.35 2009-11-19 22:23:27 tcunha 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);