diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-18 17:02:18 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-18 17:02:18 +0000 |
commit | 52a1bf0505be729040b1a19208229c945a958caf (patch) | |
tree | 0107f42937859e68d192adee15adbd13b755de28 /usr.bin/tmux/window-copy.c | |
parent | e33df98b55285d194871e65c988fd48970c8c06c (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 'usr.bin/tmux/window-copy.c')
-rw-r--r-- | usr.bin/tmux/window-copy.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 73c107b7e5e..ab62d32eb77 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.31 2009/10/20 21:35:25 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.32 2009/11/18 17:02:17 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -486,6 +486,7 @@ window_copy_search_compare( { const struct grid_cell *gc, *sgc; const struct grid_utf8 *gu, *sgu; + size_t size; gc = grid_peek_cell(gd, px, py); sgc = grid_peek_cell(sgd, spx, 0); @@ -496,7 +497,7 @@ window_copy_search_compare( if (gc->flags & GRID_FLAG_UTF8) { gu = grid_peek_utf8(gd, px, py); sgu = grid_peek_utf8(sgd, spx, 0); - if (memcmp(gu->data, sgu->data, UTF8_SIZE) == 0) + if (grid_utf8_compare(gu, sgu)) return (1); } else { if (gc->data == sgc->data) @@ -895,7 +896,8 @@ window_copy_copy_line(struct window_pane *wp, const struct grid_cell *gc; const struct grid_utf8 *gu; struct grid_line *gl; - u_int i, j, xx, wrapped = 0; + u_int i, xx, wrapped = 0; + size_t size; if (sx > ex) return; @@ -928,12 +930,9 @@ window_copy_copy_line(struct window_pane *wp, (*buf)[(*off)++] = gc->data; } else { gu = grid_peek_utf8(gd, i, sy); - *buf = xrealloc(*buf, 1, (*off) + UTF8_SIZE); - for (j = 0; j < UTF8_SIZE; j++) { - if (gu->data[j] == 0xff) - break; - (*buf)[(*off)++] = gu->data[j]; - } + size = grid_utf8_size(gu); + *buf = xrealloc(*buf, 1, (*off) + size); + *off += grid_utf8_copy(gu, *buf + *off, size); } } } |