diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-06-25 16:04:24 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-06-25 16:04:24 +0000 |
commit | f7a9eb46fc0c0be659912b0cf9c2e7d7ced86bf9 (patch) | |
tree | 045e08db5ffd7da586326ab3f19968a92e2798c4 /grid.c | |
parent | 853ad681620e9a031f41549a39c78d11b2da8990 (diff) | |
download | rtmux-f7a9eb46fc0c0be659912b0cf9c2e7d7ced86bf9.tar.gz rtmux-f7a9eb46fc0c0be659912b0cf9c2e7d7ced86bf9.tar.bz2 rtmux-f7a9eb46fc0c0be659912b0cf9c2e7d7ced86bf9.zip |
Change find-window and monitor-content to use fnmatch(3). For convenience and
compatibility, *s are implicitly added at the start and end of the pattern.
Diffstat (limited to 'grid.c')
-rw-r--r-- | grid.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: grid.c,v 1.3 2009/06/24 22:04:18 nicm Exp $ */ +/* $OpenBSD: grid.c,v 1.4 2009/06/24 22:49:56 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -502,7 +502,7 @@ grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx) const struct grid_utf8 *gu; char *buf; size_t len, off; - u_int xx; + u_int xx, i; GRID_DEBUG(gd, "px=%u, py=%u, nx=%u", px, py, nx); @@ -522,10 +522,11 @@ grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx) } gu = grid_peek_utf8(gd, xx, py); - memcpy(buf + off, gu->data, UTF8_SIZE); - off += UTF8_SIZE; - while (off > 0 && ((u_char) buf[off]) == 0xff) - off--; + for (i = 0; i < UTF8_SIZE; i++) { + if (gu->data[i] == 0xff) + break; + buf[off++] = gu->data[i]; + } } else { while (len < off + 2) { buf = xrealloc(buf, 2, len); @@ -535,7 +536,9 @@ grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx) buf[off++] = gc->data; } } - + + while (off > 0 && buf[off - 1] == ' ') + off--; buf[off] = '\0'; return (buf); } |