summaryrefslogtreecommitdiffstats
path: root/grid.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-06-24 22:49:56 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-06-24 22:49:56 +0000
commit7e796dea035ed7028fc7188e65979725a24ff03d (patch)
tree2320aac0cebb0b6bf561a7d3a004622669ab174d /grid.c
parent096cbf2ea558c0f66ee7bdaa8316e85c3e55ee69 (diff)
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. Also display the line number and the entire line in the results, and lose the nasty section_string function and the now empty util.c file. Initially from Tiago Cunha.
Diffstat (limited to 'grid.c')
-rw-r--r--grid.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/grid.c b/grid.c
index 01bf7719..071248ee 100644
--- a/grid.c
+++ b/grid.c
@@ -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);
}