patch-2.1.42 linux/drivers/char/selection.c

Next file: linux/drivers/char/selection.h
Previous file: linux/drivers/char/riscom8.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.41/linux/drivers/char/selection.c linux/drivers/char/selection.c
@@ -92,10 +92,11 @@
 /* set inwordLut contents. Invoked by ioctl(). */
 int sel_loadlut(const unsigned long arg)
 {
-	int i = verify_area(VERIFY_READ, (char *) arg, 36);
-	if (i)
-		return i;
-	copy_from_user(inwordLut, (u32 *)(arg+4), 32);
+	int err;
+
+	err = copy_from_user(inwordLut, (u32 *)(arg+4), 32);
+	if (err)
+		return -EFAULT;
 	return 0;
 }
 
@@ -120,10 +121,15 @@
 	int sel_mode, new_sel_start, new_sel_end, spc;
 	char *bp, *obp;
 	int i, ps, pe;
+	unsigned long num_lines, num_columns, size_row;
 
 	do_unblank_screen();
 	poke_blanked_console();
 
+	num_lines = get_video_num_lines(fg_console);
+	num_columns = get_video_num_columns(fg_console);
+	size_row = get_video_size_row(fg_console);
+
 	{ unsigned short *args, xs, ys, xe, ye;
 
 	  args = (unsigned short *)(arg + 1);
@@ -145,12 +151,12 @@
 		  sel_mode = *args;
 	  }
 	  xs--; ys--; xe--; ye--;
-	  xs = limit(xs, video_num_columns - 1);
-	  ys = limit(ys, video_num_lines - 1);
-	  xe = limit(xe, video_num_columns - 1);
-	  ye = limit(ye, video_num_lines - 1);
-	  ps = ys * video_size_row + (xs << 1);
-	  pe = ye * video_size_row + (xe << 1);
+	  xs = limit(xs, num_columns - 1);
+	  ys = limit(ys, num_lines - 1);
+	  xe = limit(xe, num_columns - 1);
+	  ye = limit(ye, num_lines - 1);
+	  ps = ys * size_row + (xs << 1);
+	  pe = ye * size_row + (xe << 1);
 
 	  if (sel_mode == 4) {
 	      /* useful for screendump without selection highlights */
@@ -190,7 +196,7 @@
 				    (!spc && !inword(sel_pos(ps))))
 					break;
 				new_sel_start = ps;
-				if (!(ps % video_size_row))
+				if (!(ps % size_row))
 					break;
 			}
 			spc = isspace(sel_pos(pe));
@@ -200,14 +206,14 @@
 				    (!spc && !inword(sel_pos(pe))))
 					break;
 				new_sel_end = pe;
-				if (!((pe + 2) % video_size_row))
+				if (!((pe + 2) % size_row))
 					break;
 			}
 			break;
 		case 2:	/* line-by-line selection */
-			new_sel_start = ps - ps % video_size_row;
-			new_sel_end = pe + video_size_row
-				    - pe % video_size_row - 2;
+			new_sel_start = ps - ps % size_row;
+			new_sel_end = pe + size_row
+				    - pe % size_row - 2;
 			break;
 		case 3:
 			highlight_pointer(pe);
@@ -268,7 +274,7 @@
 		*bp = sel_pos(i);
 		if (!isspace(*bp++))
 			obp = bp;
-		if (! ((i + 2) % video_size_row)) {
+		if (! ((i + 2) % size_row)) {
 			/* strip trailing blanks from line and add newline,
 			   unless non-space at end of line. */
 			if (obp != bp) {

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov