summaryrefslogtreecommitdiff
blob: 509d1afbfa7d89d6b128d264df98d3851959a1ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
diff -ur nano-1.3.11/src/text.c nano-1.3.11-fixed/src/text.c
--- nano-1.3.11/src/text.c	2006-02-18 16:32:29.000000000 -0500
+++ nano-1.3.11-fixed/src/text.c	2006-05-18 13:51:50.000000000 -0400
@@ -607,14 +607,14 @@
 	 * found with short enough display width.  */
     ssize_t cur_loc = 0;
 	/* Current index in line. */
+    size_t cur_pos = 0;
+	/* Current column position in line. */
     int line_len;
 
     assert(line != NULL);
 
-    while (*line != '\0' && goal >= 0) {
-	size_t pos = 0;
-
-	line_len = parse_mbchar(line, NULL, &pos);
+    while (*line != '\0' && goal >= cur_pos) {
+	line_len = parse_mbchar(line, NULL, &cur_pos);
 
 	if (is_blank_mbchar(line)
 #ifndef DISABLE_HELP
@@ -629,12 +629,11 @@
 #endif
 	}
 
-	goal -= pos;
 	line += line_len;
 	cur_loc += line_len;
     }
 
-    if (goal >= 0)
+    if (goal >= cur_pos)
 	/* In fact, the whole line displays shorter than goal. */
 	return cur_loc;