aboutsummaryrefslogtreecommitdiff
path: root/window-copy.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 /window-copy.c
parent8db145da1ed40d471e9ecff0e788ced26a43fc92 (diff)
downloadrtmux-a78cc98c8bd79cecbb8574a9dff4c9867a8308d9.tar.gz
rtmux-a78cc98c8bd79cecbb8574a9dff4c9867a8308d9.tar.bz2
rtmux-a78cc98c8bd79cecbb8574a9dff4c9867a8308d9.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 'window-copy.c')
-rw-r--r--window-copy.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/window-copy.c b/window-copy.c
index 499ead33..25f73634 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -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);
}
}
}