From f52b9cd281109616d44e2faad2f7cf5e0472f681 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 21 Aug 2009 07:29:38 +0000 Subject: Fix grid_expand_line so it actually works when the required size is bigger than 2 * the current size. --- usr.bin/tmux/grid.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c index 960b2e6788e..25f6acb0f56 100644 --- a/usr.bin/tmux/grid.c +++ b/usr.bin/tmux/grid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grid.c,v 1.12 2009/08/20 19:14:42 nicm Exp $ */ +/* $OpenBSD: grid.c,v 1.13 2009/08/21 07:29:37 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -189,19 +189,22 @@ grid_scroll_line(struct grid *gd) /* Expand line to fit to cell. */ void -grid_expand_line(struct grid *gd, u_int py, u_int sx) +grid_expand_line(struct grid *gd, u_int py, u_int wantx) { struct grid_line *gl; - u_int xx; + u_int xx, sx; gl = &gd->linedata[py]; - if (sx <= gl->cellsize) + if (wantx <= gl->cellsize) return; if (gl->cellsize > gd->sx / 2) sx = gd->sx; - else - sx = 1 + gl->cellsize * 2; + else { + sx = gl->cellsize + 1; + while (sx < wantx) + sx *= 2; + } gl->celldata = xrealloc(gl->celldata, sx, sizeof *gl->celldata); for (xx = gl->cellsize; xx < sx; xx++) grid_put_cell(gd, xx, py, &grid_default_cell); -- cgit v1.2.3