summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/grid.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2013-10-10 11:49:29 +0000
committernicm <nicm@openbsd.org>2013-10-10 11:49:29 +0000
commit24e5de378cc6fbfecba0d40437c4ebb73cc8811c (patch)
tree4f9ac959ca4018879312838e3de2bd901548a5d5 /usr.bin/tmux/grid.c
parentAllow the file descriptor received from the client to be -1. (diff)
downloadwireguard-openbsd-24e5de378cc6fbfecba0d40437c4ebb73cc8811c.tar.xz
wireguard-openbsd-24e5de378cc6fbfecba0d40437c4ebb73cc8811c.zip
Only include actual trailing spaces not unused cells with capturep -J,
from George Nachman.
Diffstat (limited to 'usr.bin/tmux/grid.c')
-rw-r--r--usr.bin/tmux/grid.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c
index 70ff4b005b3..9ff18cd1fa6 100644
--- a/usr.bin/tmux/grid.c
+++ b/usr.bin/tmux/grid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grid.c,v 1.29 2013/03/25 10:07:40 nicm Exp $ */
+/* $OpenBSD: grid.c,v 1.30 2013/10/10 11:49:29 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -592,6 +592,7 @@ grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx,
char *buf, code[128];
size_t len, off, size, codelen;
u_int xx;
+ const struct grid_line *gl;
GRID_DEBUG(gd, "px=%u, py=%u, nx=%u", px, py, nx);
@@ -604,8 +605,11 @@ grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx,
buf = xmalloc(len);
off = 0;
+ gl = grid_peek_line(gd, py);
for (xx = px; xx < px + nx; xx++) {
- gc = grid_peek_cell(gd, xx, py);
+ if (gl == NULL || xx >= gl->cellsize)
+ break;
+ gc = &gl->celldata[xx];
if (gc->flags & GRID_FLAG_PADDING)
continue;
grid_cell_get(gc, &ud);