From 7839993fe734aec38355401ce5a02d85f9dab5ba Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 10 Oct 2013 11:49:29 +0000 Subject: Only include actual trailing spaces not unused cells with capturep -J, from George Nachman. --- grid.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'grid.c') diff --git a/grid.c b/grid.c index 529ce154..b2ee0c69 100644 --- a/grid.c +++ b/grid.c @@ -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); -- cgit From 1b7c2dd056f4e41f0cec38c1b8ed5531f7281e33 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 10 Oct 2013 12:01:14 +0000 Subject: Trivial style and spacing nits. --- grid.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'grid.c') diff --git a/grid.c b/grid.c index b2ee0c69..d06e7154 100644 --- a/grid.c +++ b/grid.c @@ -268,8 +268,7 @@ grid_get_cell(struct grid *gd, u_int px, u_int py) /* Set cell at relative position. */ void -grid_set_cell( - struct grid *gd, u_int px, u_int py, const struct grid_cell *gc) +grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc) { if (grid_check_y(gd, py) != 0) return; @@ -657,8 +656,8 @@ grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx, * available. */ void -grid_duplicate_lines( - struct grid *dst, u_int dy, struct grid *src, u_int sy, u_int ny) +grid_duplicate_lines(struct grid *dst, u_int dy, struct grid *src, u_int sy, + u_int ny) { struct grid_line *dstl, *srcl; u_int yy; -- cgit