[patch] fix another End keypress lockup in the viewer



Hello,

the new viewer has a problem with viewing files with DOS line
separators, which manifests again in a lockup after pressing the End
key. Then, it is impossible to move the view further, except by pressing
the Home key.

It is caused by the code of view_move_up, which moves by one line using
view_coord_to_offset() and then view_offset_to_coord() with offset
decremented by one. In the case of 0d/0a separator, the decremented
offset points to 0d, and view_offset_to_coord() returns the same coords.

The attached patch fixes the issue by decrementing the offset until
something else than 0d appears.

Regards,
-- 
Jindrich Makovicka
Index: view.c
===================================================================
RCS file: /cvsroot/mc/mc/src/view.c,v
retrieving revision 1.314
diff -u -r1.314 view.c
--- view.c	6 Aug 2005 18:19:14 -0000	1.314
+++ view.c	14 Aug 2005 15:33:11 -0000
@@ -1161,7 +1161,8 @@
 		col -= width;
 	    } else if (line >= 1) {
 		view_coord_to_offset (view, &linestart, line, 0);
-		view_offset_to_coord (view, &line, &col, linestart - 1);
+		do { linestart--; } while (get_byte(view, linestart) == '\r');
+		view_offset_to_coord (view, &line, &col, linestart);
 
 		/* if the only thing that would be displayed were a
 		 * single newline character, advance to the previous


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]