The problem was that I was using the same va_list twice, in
window_copy_vadd; the first time uselessly in an xvasprintf whose result
I never used (relic of a an approach I initially started with, but
abandoned for the current use). No idea why it seemed to "work" okay in
32-bit, but anyway, obviously dangerous code.

This new patch fixes the goof.

-mjc

Micah Cowan wrote:
> WARNING WARNING WARNING
> 
> While this patch seems to work fine on two of my laptops running 32-bit
> Ubuntu Karmic Koala (9.04), there seem to be stability issues when
> running from my work desktop running 64-bit Ubuntu Hardy Heron (8.04).
> For me, the symptoms are that the "showb" command produces
> garbledy-gook, and the "info" command causes tmux to dump core (from
> within a strlen() from within a xvasprintf, within window_copy_vadd
> (with innocuous arguments). This smells like memory corruption or
> reading of bad data. I don't experience these problems without my patch.
> Hold off applying it in CVS until I work out what's going wrong.
> 
> Micah Cowan wrote:
>> This is a code-only patch. I'll submit a separate one for the manual.
>>
>> This patch eliminates "output" (or "more") mode, which is used to view
>> command output within an attached tmux client. It's the mode you use
>> when you type <prefix> ? to get a list of bindings.
Index: cmd-copy-mode.c
===================================================================
--- cmd-copy-mode.c.orig	2010-02-16 15:05:09.000000000 -0800
+++ cmd-copy-mode.c	2010-02-16 15:10:16.000000000 -0800
@@ -63,6 +63,7 @@
 		return (-1);
 
 	window_pane_set_mode(wp, &window_copy_mode);
+	window_copy_from_pane(wp);
 	if (wp->mode == &window_copy_mode && cmd_check_flag(data->chflags, 'u'))
 		window_copy_pageup(wp);
 
Index: tmux.h
===================================================================
--- tmux.h.orig	2010-02-16 15:10:16.000000000 -0800
+++ tmux.h	2010-02-16 15:10:16.000000000 -0800
@@ -700,6 +700,8 @@
 
 	int		 mode;
 
+	int		 wrap;		/* whether lines wrap */
+
 	bitstr_t	*tabs;
 
 	struct screen_sel sel;
@@ -1873,13 +1875,12 @@
 
 /* window-copy.c */
 extern const struct window_mode window_copy_mode;
+void		 window_copy_from_pane(struct window_pane *);
+void		 window_copy_backing_init(struct window_pane *);
+void		 window_copy_add(struct window_pane *, const char *, ...);
+void		 window_copy_vadd(struct window_pane *, const char *, va_list);
 void		 window_copy_pageup(struct window_pane *);
 
-/* window-more.c */
-extern const struct window_mode window_more_mode;
-void		 window_more_add(struct window_pane *, const char *, ...);
-void		 window_more_vadd(struct window_pane *, const char *, va_list);
-
 /* window-choose.c */
 extern const struct window_mode window_choose_mode;
 void		 window_choose_vadd(
Index: window-copy.c
===================================================================
--- window-copy.c.orig	2010-02-16 15:10:16.000000000 -0800
+++ window-copy.c	2010-02-16 16:20:11.000000000 -0800
@@ -88,6 +88,7 @@
 
 struct window_copy_mode_data {
 	struct screen	screen;
+	struct screen	*backing;
 
 	struct mode_key_data mdata;
 
@@ -104,6 +105,9 @@
 	u_int		lastcx; /* position in last line with content */
 	u_int		lastsx; /* size of last line with content */
 
+	int		backing_written; /* where to write next line
+					    in backing */
+
 	enum window_copy_input_type inputtype;
 	const char     *inputprompt;
 	char   	       *inputstr;
@@ -117,18 +121,18 @@
 {
 	struct window_copy_mode_data	*data;
 	struct screen			*s;
-	struct screen_write_ctx	 	 ctx;
-	u_int				 i;
 	int				 keys;
 
 	wp->modedata = data = xmalloc(sizeof *data);
 	data->oy = 0;
-	data->cx = wp->base.cx;
-	data->cy = wp->base.cy;
+	data->cx = 0;
+	data->cy = 0;
 
 	data->lastcx = 0;
 	data->lastsx = 0;
 
+	data->backing_written = 0;
+
 	data->rectflag = 0;
 
 	data->inputtype = WINDOW_COPY_OFF;
@@ -149,6 +153,29 @@
 	else
 		mode_key_init(&data->mdata, &mode_key_tree_vi_copy);
 
+	data->backing = NULL;
+
+	return (s);
+}
+
+void
+window_copy_from_pane(struct window_pane *wp)
+{
+	struct window_copy_mode_data	*data;
+	struct screen			*s;
+	struct screen_write_ctx	 	 ctx;
+	u_int				 i;
+
+	if (wp->mode != &window_copy_mode)
+		fatal("not in copy mode");
+
+	data =  wp->modedata;
+	s    = &data->screen;
+
+	data->backing = &wp->base;
+	data->cx = data->backing->cx;
+	data->cy = data->backing->cy;
+
 	s->cx = data->cx;
 	s->cy = data->cy;
 
@@ -157,8 +184,17 @@
 		window_copy_write_line(wp, &ctx, i);
 	screen_write_cursormove(&ctx, data->cx, data->cy);
 	screen_write_stop(&ctx);
+}
 
-	return (s);
+void
+window_copy_backing_init(struct window_pane *wp)
+{
+	struct window_copy_mode_data	*data = wp->modedata;
+
+	data->backing = xmalloc(sizeof *data->backing);
+	screen_init(data->backing, screen_size_x(&wp->base),
+	    screen_size_y(&wp->base), UINT_MAX);
+	data->backing->wrap = 0;
 }
 
 void
@@ -170,12 +206,70 @@
 		xfree(data->searchstr);
 	xfree(data->inputstr);
 
+	if (data->backing != &wp->base) {
+		screen_free(data->backing);
+		xfree(data->backing);
+	}
 	screen_free(&data->screen);
 
 	xfree(data);
 }
 
 void
+window_copy_add(struct window_pane *wp, const char *fmt, ...)
+{
+	va_list	ap;
+
+	va_start(ap, fmt);
+	window_copy_vadd(wp, fmt, ap);
+	va_end(ap);
+}
+
+void
+window_copy_vadd(struct window_pane *wp, const char *fmt, va_list ap)
+{
+	struct window_copy_mode_data	*data = wp->modedata;
+	struct screen			*backing = data->backing;
+	struct screen_write_ctx	 	 back_ctx, ctx;
+	struct grid_cell		 gc;
+	int				 utf8flag;
+	u_int				 old_hsize;
+
+	if (backing == &wp->base)
+		return;
+
+	utf8flag = options_get_number(&wp->window->options, "utf8");
+	memcpy(&gc, &grid_default_cell, sizeof gc);
+
+	old_hsize = screen_hsize(data->backing);
+	screen_write_start(&back_ctx, NULL, backing);
+	if (data->backing_written) {
+		/* On the second or later line, do a CRLF before writing
+		 * (so it's on a new line). */
+		screen_write_carriagereturn(&back_ctx);
+		screen_write_linefeed(&back_ctx, 0);
+	} else
+		data->backing_written++;
+	screen_write_vnputs(&back_ctx, 0, &gc, utf8flag, fmt, ap);
+	screen_write_stop(&back_ctx);
+
+	data->oy += screen_hsize(data->backing) - old_hsize;
+
+	screen_write_start(&ctx, wp, &data->screen);
+
+	/* If the history has changed, draw the top line.
+	 * (If there's any history at all, it has changed.) */
+	if (screen_hsize(data->backing))
+		window_copy_redraw_lines(wp, 0, 1);
+
+	/* Write the line, if it's visible. */
+	if (backing->cy + data->oy < screen_size_y(backing))
+		window_copy_redraw_lines(wp, backing->cy, 1);
+
+	screen_write_stop(&ctx);
+}
+
+void
 window_copy_pageup(struct window_pane *wp)
 {
 	struct window_copy_mode_data	*data = wp->modedata;
@@ -185,8 +279,8 @@
 	n = 1;
 	if (screen_size_y(s) > 2)
 		n = screen_size_y(s) - 2;
-	if (data->oy + n > screen_hsize(&wp->base))
-		data->oy = screen_hsize(&wp->base);
+	if (data->oy + n > screen_hsize(data->backing))
+		data->oy = screen_hsize(data->backing);
 	else
 		data->oy += n;
 	window_copy_update_selection(wp);
@@ -201,6 +295,8 @@
 	struct screen_write_ctx	 	 ctx;
 
 	screen_resize(s, sx, sy);
+	if (data->backing != &wp->base)
+		screen_resize(data->backing, sx, sy);
 
 	if (data->cy > sy - 1)
 		data->cy = sy - 1;
@@ -271,8 +367,8 @@
 		break;
 	case MODEKEYCOPY_HALFPAGEUP:
 		n = screen_size_y(s) / 2;
-		if (data->oy + n > screen_hsize(&wp->base))
-			data->oy = screen_hsize(&wp->base);
+		if (data->oy + n > screen_hsize(data->backing))
+			data->oy = screen_hsize(data->backing);
 		else
 			data->oy += n;
 		window_copy_update_selection(wp);
@@ -308,7 +404,7 @@
 	case MODEKEYCOPY_HISTORYTOP:
 		data->cx = 0;
 		data->cy = 0;
-		data->oy = screen_hsize(&wp->base);
+		data->oy = screen_hsize(data->backing);
 		window_copy_update_selection(wp);
 		window_copy_redraw_screen(wp);
 		break;
@@ -504,8 +600,7 @@
 window_copy_scroll_to(struct window_pane *wp, u_int px, u_int py)
 {
 	struct window_copy_mode_data	*data = wp->modedata;
-	struct screen			*s = &wp->base;
-	struct grid			*gd = s->grid;
+	struct grid			*gd = data->backing->grid;
 	u_int				 offset, gap;
 
 	data->cx = px;
@@ -600,7 +695,7 @@
 window_copy_search_up(struct window_pane *wp, const char *searchstr)
 {
 	struct window_copy_mode_data	*data = wp->modedata;
-	struct screen			*s = &wp->base, ss;
+	struct screen			*s = data->backing, ss;
 	struct screen_write_ctx		 ctx;
 	struct grid			*gd = s->grid, *sgd;
 	struct grid_cell	 	 gc;
@@ -657,7 +752,7 @@
 window_copy_search_down(struct window_pane *wp, const char *searchstr)
 {
 	struct window_copy_mode_data	*data = wp->modedata;
-	struct screen			*s = &wp->base, ss;
+	struct screen			*s = data->backing, ss;
 	struct screen_write_ctx		 ctx;
 	struct grid			*gd = s->grid, *sgd;
 	struct grid_cell	 	 gc;
@@ -717,7 +812,7 @@
 	const char			*errstr;
 	u_int				 lineno;
 
-	lineno = strtonum(linestr, 0, screen_hsize(&wp->base), &errstr);
+	lineno = strtonum(linestr, 0, screen_hsize(data->backing), &errstr);
 	if (errstr != NULL)
 		return;
 
@@ -745,7 +840,7 @@
 	last = screen_size_y(s) - 1;
 	if (py == 0) {
 		size = xsnprintf(hdr, sizeof hdr,
-		    "[%u/%u]", data->oy, screen_hsize(&wp->base));
+		    "[%u/%u]", data->oy, screen_hsize(data->backing));
 		screen_write_cursormove(ctx, screen_size_x(s) - size, 0);
 		screen_write_puts(ctx, &gc, "%s", hdr);
 	} else if (py == last && data->inputtype != WINDOW_COPY_OFF) {
@@ -757,8 +852,9 @@
 		size = 0;
 
 	screen_write_cursormove(ctx, xoff, py);
-	screen_write_copy(ctx, &wp->base, xoff, (screen_hsize(&wp->base) -
-	    data->oy) + py, screen_size_x(s) - size, 1);
+	screen_write_copy(ctx, data->backing, xoff,
+	    (screen_hsize(data->backing) - data->oy) + py,
+	    screen_size_x(s) - size, 1);
 
 	if (py == data->cy && data->cx == screen_size_x(s)) {
 		memcpy(&gc, &grid_default_cell, sizeof gc);
@@ -827,7 +923,7 @@
 	struct screen			*s = &data->screen;
 
 	data->selx = data->cx;
-	data->sely = screen_hsize(&wp->base) + data->cy - data->oy;
+	data->sely = screen_hsize(data->backing) + data->cy - data->oy;
 
 	s->sel.flag = 1;
 	window_copy_update_selection(wp);
@@ -852,7 +948,7 @@
 	gc.attr |= options_get_number(oo, "mode-attr");
 
 	/* Find top of screen. */
-	ty = screen_hsize(&wp->base) - data->oy;
+	ty = screen_hsize(data->backing) - data->oy;
 
 	/* Adjust the selection. */
 	sx = data->selx;
@@ -913,7 +1009,7 @@
 
 	/* Find start and end. */
 	xx = data->cx;
-	yy = screen_hsize(&wp->base) + data->cy - data->oy;
+	yy = screen_hsize(data->backing) + data->cy - data->oy;
 	if (yy < data->sely || (yy == data->sely && xx < data->selx)) {
 		sx = xx; sy = yy;
 		ex = data->selx; ey = data->sely;
@@ -992,12 +1088,13 @@
 window_copy_copy_line(struct window_pane *wp,
     char **buf, size_t *off, u_int sy, u_int sx, u_int ex)
 {
-	struct grid		*gd = wp->base.grid;
-	const struct grid_cell	*gc;
-	const struct grid_utf8	*gu;
-	struct grid_line	*gl;
-	u_int			 i, xx, wrapped = 0;
-	size_t			 size;
+	struct window_copy_mode_data	*data = wp->modedata;
+	struct grid			*gd = data->backing->grid;
+	const struct grid_cell		*gc;
+	const struct grid_utf8		*gu;
+	struct grid_line		*gl;
+	u_int				 i, xx, wrapped = 0;
+	size_t				 size;
 
 	if (sx > ex)
 		return;
@@ -1047,9 +1144,10 @@
 int
 window_copy_in_set(struct window_pane *wp, u_int px, u_int py, const char *set)
 {
-	const struct grid_cell	*gc;
+	struct window_copy_mode_data	*data = wp->modedata;
+	const struct grid_cell		*gc;
 
-	gc = grid_peek_cell(wp->base.grid, px, py);
+	gc = grid_peek_cell(data->backing->grid, px, py);
 	if (gc->flags & (GRID_FLAG_PADDING|GRID_FLAG_UTF8))
 		return (0);
 	if (gc->data == 0x00 || gc->data == 0x7f)
@@ -1060,8 +1158,10 @@
 u_int
 window_copy_find_length(struct window_pane *wp, u_int py)
 {
-	const struct grid_cell	*gc;
-	u_int			 px;
+	struct window_copy_mode_data	*data = wp->modedata;
+	struct screen			*s = data->backing;
+	const struct grid_cell		*gc;
+	u_int				 px;
 
 	/*
 	 * If the pane has been resized, its grid can contain old overlong
@@ -1069,11 +1169,11 @@
 	 * width of the grid, and screen_write_copy treats them as spaces, so
 	 * ignore them here too.
 	 */
-	px = wp->base.grid->linedata[py].cellsize;
-	if (px > screen_size_x(&wp->base))
-		px = screen_size_x(&wp->base);
+	px = s->grid->linedata[py].cellsize;
+	if (px > screen_size_x(s))
+		px = screen_size_x(s);
 	while (px > 0) {
-		gc = grid_peek_cell(wp->base.grid, px - 1, py);
+		gc = grid_peek_cell(s->grid, px - 1, py);
 		if (gc->flags & GRID_FLAG_UTF8)
 			break;
 		if (gc->data != ' ')
@@ -1101,11 +1201,11 @@
 	const struct grid_cell		*gc;
 
 	px = 0;
-	py = screen_hsize(&wp->base) + data->cy - data->oy;
+	py = screen_hsize(data->backing) + data->cy - data->oy;
 	xx = window_copy_find_length(wp, py);
 
 	while (px < xx) {
-		gc = grid_peek_cell(wp->base.grid, px, py);
+		gc = grid_peek_cell(data->backing->grid, px, py);
 		if (gc->flags & GRID_FLAG_UTF8)
 			break;
 		if (gc->data != ' ')
@@ -1124,7 +1224,7 @@
 	struct window_copy_mode_data	*data = wp->modedata;
 	u_int				 px, py;
 
-	py = screen_hsize(&wp->base) + data->cy - data->oy;
+	py = screen_hsize(data->backing) + data->cy - data->oy;
 	px = window_copy_find_length(wp, py);
 
 	window_copy_update_cursor(wp, px, data->cy);
@@ -1153,7 +1253,7 @@
 	struct window_copy_mode_data	*data = wp->modedata;
 	u_int				 px, py;
 
-	py = screen_hsize(&wp->base) + data->cy - data->oy;
+	py = screen_hsize(data->backing) + data->cy - data->oy;
 	px = window_copy_find_length(wp, py);
 
 	if (data->cx >= px) {
@@ -1173,7 +1273,7 @@
 	struct screen			*s = &data->screen;
 	u_int				 ox, oy, px, py;
 
-	oy = screen_hsize(&wp->base) + data->cy - data->oy;
+	oy = screen_hsize(data->backing) + data->cy - data->oy;
 	ox = window_copy_find_length(wp, oy);
 	if (ox != 0) {
 		data->lastcx = data->cx;
@@ -1199,7 +1299,7 @@
 		}
 	}
 
-	py = screen_hsize(&wp->base) + data->cy - data->oy;
+	py = screen_hsize(data->backing) + data->cy - data->oy;
 	px = window_copy_find_length(wp, py);
 	if (data->cx >= data->lastsx || data->cx > px)
 		window_copy_cursor_end_of_line(wp);
@@ -1212,7 +1312,7 @@
 	struct screen			*s = &data->screen;
 	u_int				 ox, oy, px, py;
 
-	oy = screen_hsize(&wp->base) + data->cy - data->oy;
+	oy = screen_hsize(data->backing) + data->cy - data->oy;
 	ox = window_copy_find_length(wp, oy);
 	if (ox != 0) {
 		data->lastcx = data->cx;
@@ -1230,7 +1330,7 @@
 			window_copy_redraw_lines(wp, data->cy - 1, 2);
 	}
 
-	py = screen_hsize(&wp->base) + data->cy - data->oy;
+	py = screen_hsize(data->backing) + data->cy - data->oy;
 	px = window_copy_find_length(wp, py);
 	if (data->cx >= data->lastsx || data->cx > px)
 		window_copy_cursor_end_of_line(wp);
@@ -1240,13 +1340,13 @@
 window_copy_cursor_next_word(struct window_pane *wp, const char *separators)
 {
 	struct window_copy_mode_data	*data = wp->modedata;
-	struct screen			*base_s = &wp->base;
+	struct screen			*back_s = data->backing;
 	u_int				 px, py, xx, yy;
 
 	px = data->cx;
-	py = screen_hsize(base_s) + data->cy - data->oy;
+	py = screen_hsize(back_s) + data->cy - data->oy;
 	xx = window_copy_find_length(wp, py);
-	yy = screen_hsize(base_s) + screen_size_y(base_s) - 1;
+	yy = screen_hsize(back_s) + screen_size_y(back_s) - 1;
 
 	/* Are we in a word? Skip it! */
 	while (!window_copy_in_set(wp, px, py, separators))
@@ -1261,7 +1361,7 @@
 			window_copy_cursor_down(wp, 0);
 			px = 0;
 
-			py = screen_hsize(base_s) + data->cy - data->oy;
+			py = screen_hsize(back_s) + data->cy - data->oy;
 			xx = window_copy_find_length(wp, py);
 		}
 		px++;
@@ -1276,13 +1376,13 @@
 window_copy_cursor_next_word_end(struct window_pane *wp, const char *separators)
 {
 	struct window_copy_mode_data	*data = wp->modedata;
-	struct screen			*base_s = &wp->base;
+	struct screen			*back_s = data->backing;
 	u_int				 px, py, xx, yy;
 
 	px = data->cx;
-	py = screen_hsize(base_s) + data->cy - data->oy;
+	py = screen_hsize(back_s) + data->cy - data->oy;
 	xx = window_copy_find_length(wp, py);
-	yy = screen_hsize(base_s) + screen_size_y(base_s) - 1;
+	yy = screen_hsize(back_s) + screen_size_y(back_s) - 1;
 
 	/* Are we on spaces? Skip 'em! */
 	while (px > xx || window_copy_in_set(wp, px, py, separators)) {
@@ -1293,7 +1393,7 @@
 			window_copy_cursor_down(wp, 0);
 			px = 0;
 
-			py = screen_hsize(base_s) + data->cy - data->oy;
+			py = screen_hsize(back_s) + data->cy - data->oy;
 			xx = window_copy_find_length(wp, py);
 		}
 		px++;
@@ -1316,7 +1416,7 @@
 	u_int				 px, py;
 
 	px = data->cx;
-	py = screen_hsize(&wp->base) + data->cy - data->oy;
+	py = screen_hsize(data->backing) + data->cy - data->oy;
 
 	/* Move back to the previous word character. */
 	for (;;) {
@@ -1326,12 +1426,12 @@
 				break;
 		} else {
 			if (data->cy == 0 &&
-			    (screen_hsize(&wp->base) == 0 ||
-			    data->oy >= screen_hsize(&wp->base) - 1))
+			    (screen_hsize(data->backing) == 0 ||
+			    data->oy >= screen_hsize(data->backing) - 1))
 				goto out;
 			window_copy_cursor_up(wp, 0);
 
-			py = screen_hsize(&wp->base) + data->cy - data->oy;
+			py = screen_hsize(data->backing) + data->cy - data->oy;
 			px = window_copy_find_length(wp, py);
 		}
 	}
@@ -1384,11 +1484,11 @@
 	struct screen			*s = &data->screen;
 	struct screen_write_ctx		 ctx;
 
-	if (ny > screen_hsize(&wp->base))
+	if (ny > screen_hsize(data->backing))
 		return;
 
-	if (data->oy > screen_hsize(&wp->base) - ny)
-		ny = screen_hsize(&wp->base) - data->oy;
+	if (data->oy > screen_hsize(data->backing) - ny)
+		ny = screen_hsize(data->backing) - data->oy;
 	if (ny == 0)
 		return;
 	data->oy += ny;
Index: screen-write.c
===================================================================
--- screen-write.c.orig	2010-02-16 15:05:09.000000000 -0800
+++ screen-write.c	2010-02-16 15:10:16.000000000 -0800
@@ -1009,13 +1009,14 @@
 	}
 
 	/* Check this will fit on the current line and wrap if not. */
-	if (s->cx > screen_size_x(s) - width) {
+	if (s->wrap && s->cx > screen_size_x(s) - width) {
 		screen_write_linefeed(ctx, 1);
 		s->cx = 0;	/* carriage return */
 	}
 
 	/* Sanity checks. */
-	if (s->cx > screen_size_x(s) - 1 || s->cy > screen_size_y(s) - 1)
+	if ((s->wrap && s->cx > screen_size_x(s) - 1)
+	    || s->cy > screen_size_y(s) - 1)
 		return;
 
 	/* Handle overwriting of UTF-8 characters. */
Index: screen.c
===================================================================
--- screen.c.orig	2010-02-16 15:05:09.000000000 -0800
+++ screen.c	2010-02-16 15:10:16.000000000 -0800
@@ -51,6 +51,8 @@
 
 	s->mode = MODE_CURSOR;
 
+	s->wrap = 1;
+
 	screen_reset_tabs(s);
 
 	grid_clear_lines(s->grid, s->grid->hsize, s->grid->sy);
Index: key-bindings.c
===================================================================
--- key-bindings.c.orig	2010-02-16 15:05:09.000000000 -0800
+++ key-bindings.c	2010-02-16 15:10:16.000000000 -0800
@@ -209,12 +209,14 @@
 	struct winlink	*wl = ctx->curclient->session->curw;
 	va_list		 ap;
 
-	if (wl->window->active->mode != &window_more_mode)
+	if (wl->window->active->mode != &window_copy_mode) {
 		window_pane_reset_mode(wl->window->active);
-	window_pane_set_mode(wl->window->active, &window_more_mode);
+		window_pane_set_mode(wl->window->active, &window_copy_mode);
+		window_copy_backing_init(wl->window->active);
+	}
 
 	va_start(ap, fmt);
-	window_more_vadd(wl->window->active, fmt, ap);
+	window_copy_vadd(wl->window->active, fmt, ap);
 	va_end(ap);
 }
 
Index: cmd-new-session.c
===================================================================
--- cmd-new-session.c.orig	2010-02-16 15:05:09.000000000 -0800
+++ cmd-new-session.c	2010-02-16 15:10:16.000000000 -0800
@@ -287,10 +287,11 @@
 	 */
 	if (cfg_finished && !ARRAY_EMPTY(&cfg_causes)) {
 		wp = s->curw->window->active;
-		window_pane_set_mode(wp, &window_more_mode);
+		window_pane_set_mode(wp, &window_copy_mode);
+		window_copy_backing_init(wp);
 		for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
 			cause = ARRAY_ITEM(&cfg_causes, i);
-			window_more_add(wp, "%s", cause);
+			window_copy_add(wp, "%s", cause);
 			xfree(cause);
 		}
 		ARRAY_FREE(&cfg_causes);
Index: server.c
===================================================================
--- server.c.orig	2010-02-16 15:05:09.000000000 -0800
+++ server.c	2010-02-16 15:10:16.000000000 -0800
@@ -201,10 +201,11 @@
 	 */
 	if (!ARRAY_EMPTY(&sessions) && !ARRAY_EMPTY(&cfg_causes)) {
 		wp = ARRAY_FIRST(&sessions)->curw->window->active;
-		window_pane_set_mode(wp, &window_more_mode);
+		window_pane_set_mode(wp, &window_copy_mode);
+		window_copy_backing_init(wp);
 		for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
 			cause = ARRAY_ITEM(&cfg_causes, i);
-			window_more_add(wp, "%s", cause);
+			window_copy_add(wp, "%s", cause);
 			xfree(cause);
 		}
 		ARRAY_FREE(&cfg_causes);
Index: grid.c
===================================================================
--- grid.c.orig	2010-02-16 15:05:09.000000000 -0800
+++ grid.c	2010-02-16 15:10:16.000000000 -0800
@@ -46,19 +46,10 @@
 	    gc, sizeof gd->linedata[py].utf8data[px]);		\
 } while (0)
 
-int	grid_check_x(struct grid *, u_int);
 int	grid_check_y(struct grid *, u_int);
 
 #ifdef DEBUG
 int
-grid_check_x(struct grid *gd, u_int px)
-{
-	if ((px) >= (gd)->sx)
-		log_fatalx("x out of range: %u", px);
-	return (0);
-}
-
-int
 grid_check_y(struct grid *gd, u_int py)
 {
 	if ((py) >= (gd)->hsize + (gd)->sy)
@@ -67,16 +58,6 @@
 }
 #else
 int
-grid_check_x(struct grid *gd, u_int px)
-{
-	if ((px) >= (gd)->sx) {
-		log_debug("x out of range: %u", px);
-		return (-1);
-	}
-	return (0);
-}
-
-int
 grid_check_y(struct grid *gd, u_int py)
 {
 	if ((py) >= (gd)->hsize + (gd)->sy) {
@@ -270,8 +251,6 @@
 const struct grid_cell *
 grid_peek_cell(struct grid *gd, u_int px, u_int py)
 {
-	if (grid_check_x(gd, px) != 0)
-		return (&grid_default_cell);
 	if (grid_check_y(gd, py) != 0)
 		return (&grid_default_cell);
 
@@ -284,8 +263,6 @@
 struct grid_cell *
 grid_get_cell(struct grid *gd, u_int px, u_int py)
 {
-	if (grid_check_x(gd, px) != 0)
-		return (NULL);
 	if (grid_check_y(gd, py) != 0)
 		return (NULL);
 
@@ -298,8 +275,6 @@
 grid_set_cell(
     struct grid *gd, u_int px, u_int py, const struct grid_cell *gc)
 {
-	if (grid_check_x(gd, px) != 0)
-		return;
 	if (grid_check_y(gd, py) != 0)
 		return;
 
@@ -311,8 +286,6 @@
 const struct grid_utf8 *
 grid_peek_utf8(struct grid *gd, u_int px, u_int py)
 {
-	if (grid_check_x(gd, px) != 0)
-		return (NULL);
 	if (grid_check_y(gd, py) != 0)
 		return (NULL);
 
@@ -325,8 +298,6 @@
 struct grid_utf8 *
 grid_get_utf8(struct grid *gd, u_int px, u_int py)
 {
-	if (grid_check_x(gd, px) != 0)
-		return (NULL);
 	if (grid_check_y(gd, py) != 0)
 		return (NULL);
 
@@ -339,8 +310,6 @@
 grid_set_utf8(
     struct grid *gd, u_int px, u_int py, const struct grid_utf8 *gc)
 {
-	if (grid_check_x(gd, px) != 0)
-		return;
 	if (grid_check_y(gd, py) != 0)
 		return;
 
@@ -364,10 +333,6 @@
 		return;
 	}
 
-	if (grid_check_x(gd, px) != 0)
-		return;
-	if (grid_check_x(gd, px + nx - 1) != 0)
-		return;
 	if (grid_check_y(gd, py) != 0)
 		return;
 	if (grid_check_y(gd, py + ny - 1) != 0)
@@ -465,12 +430,6 @@
 	if (nx == 0 || px == dx)
 		return;
 
-	if (grid_check_x(gd, px) != 0)
-		return;
-	if (grid_check_x(gd, px + nx - 1) != 0)
-		return;
-	if (grid_check_x(gd, dx + nx - 1) != 0)
-		return;
 	if (grid_check_y(gd, py) != 0)
 		return;
 	gl = &gd->linedata[py];
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to