mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 01:34:18 +00:00 
			
		
		
		
	Rm some redundant checks, prevent issues when data->size == 0.
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: window-copy.c,v 1.4 2007-11-22 19:40:17 nicm Exp $ */
 | 
					/* $Id: window-copy.c,v 1.5 2007-11-23 16:43:04 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -232,9 +232,6 @@ window_copy_cursor_left(struct window *w)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	struct window_copy_mode_data	*data = w->modedata;
 | 
						struct window_copy_mode_data	*data = w->modedata;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (data->ox + data->cx == 0)
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (data->cx == 0)
 | 
						if (data->cx == 0)
 | 
				
			||||||
		window_copy_scroll_right(w, 1); 
 | 
							window_copy_scroll_right(w, 1); 
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
@@ -251,9 +248,6 @@ window_copy_cursor_right(struct window *w)
 | 
				
			|||||||
	struct window_copy_mode_data	*data = w->modedata;
 | 
						struct window_copy_mode_data	*data = w->modedata;
 | 
				
			||||||
	struct screen			*s = &w->screen;
 | 
						struct screen			*s = &w->screen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (data->ox + data->cx == SHRT_MAX)
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (data->cx == screen_last_x(s))
 | 
						if (data->cx == screen_last_x(s))
 | 
				
			||||||
		window_copy_scroll_left(w, 1);
 | 
							window_copy_scroll_left(w, 1);
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
@@ -269,9 +263,6 @@ window_copy_cursor_up(struct window *w)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	struct window_copy_mode_data	*data = w->modedata;
 | 
						struct window_copy_mode_data	*data = w->modedata;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (data->cy == 0 && data->oy == data->size)
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (data->cy == 0)
 | 
						if (data->cy == 0)
 | 
				
			||||||
		window_copy_scroll_down(w, 1);
 | 
							window_copy_scroll_down(w, 1);
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
@@ -288,9 +279,6 @@ window_copy_cursor_down(struct window *w)
 | 
				
			|||||||
	struct window_copy_mode_data	*data = w->modedata;
 | 
						struct window_copy_mode_data	*data = w->modedata;
 | 
				
			||||||
	struct screen			*s = &w->screen;
 | 
						struct screen			*s = &w->screen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (data->cy == screen_last_y(s) && data->oy == 0)
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (data->cy == screen_last_y(s))
 | 
						if (data->cy == screen_last_y(s))
 | 
				
			||||||
		window_copy_scroll_up(w, 1);
 | 
							window_copy_scroll_up(w, 1);
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
@@ -343,7 +331,7 @@ window_copy_scroll_left(struct window *w, u_int nx)
 | 
				
			|||||||
	struct hdr			 hdr;
 | 
						struct hdr			 hdr;
 | 
				
			||||||
	size_t				 size;
 | 
						size_t				 size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (data->ox >= SHRT_MAX - nx)
 | 
						if (data->ox > SHRT_MAX - nx)
 | 
				
			||||||
		nx = SHRT_MAX - data->ox;
 | 
							nx = SHRT_MAX - data->ox;
 | 
				
			||||||
	if (nx == 0)
 | 
						if (nx == 0)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
@@ -490,7 +478,10 @@ window_copy_scroll_down(struct window *w, u_int ny)
 | 
				
			|||||||
	struct hdr			 hdr;
 | 
						struct hdr			 hdr;
 | 
				
			||||||
	size_t				 size;
 | 
						size_t				 size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (data->oy >= data->size - ny)
 | 
						if (ny > data->size)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (data->oy > data->size - ny)
 | 
				
			||||||
		ny = data->size - data->oy;
 | 
							ny = data->size - data->oy;
 | 
				
			||||||
	if (ny == 0)
 | 
						if (ny == 0)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user