File: 720_newt_combiwrap.patch

package info (click to toggle)
newt 0.52.14-11.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,548 kB
  • sloc: ansic: 9,098; python: 708; makefile: 235; sh: 14
file content (52 lines) | stat: -rw-r--r-- 1,382 bytes parent folder | download | duplicates (3)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Description: Text incorrectly wrapping at combining characters
Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=570630
Author: Theppitak Karoonboonyanan
Forwarded: no
Last-Updated: 2010-02-20

diff -ruN8p newt-0.52.11-old/textbox.c newt-0.52.11/textbox.c
--- newt-0.52.11-old/textbox.c	2010-02-20 21:22:43.000000000 +0700
+++ newt-0.52.11/textbox.c	2010-02-20 21:23:04.000000000 +0700
@@ -205,34 +205,36 @@ static void doReflow(const char * text,
 		fprintf(stderr,"adding %d\n",((width / 2) - (len)) / 2);
 #endif					
 		    howbad += ((width / 2) - (len)) / 2;
 		}
 		text = end;
 		if (*text) text++;
 	    } else {
 		const char *spcptr = NULL;
-	        int spc =0,w2, x;
+	        int spc =0,w2, x, w;
 
 	        chptr = text;
 		w2 = 0;
-		for (i = 0; i < width - 1;) {
+		for (i = 0; ;) {
 			if ((x=mbrtowc(&tmp,chptr,end-chptr,&ps))<=0)
 				break;
+			w = wcwidth(tmp);
+			if (w>0)
+			    i+=w;
+			if (i >= width)
+			    break;
 		        if (spc && !iswspace(tmp))
 				spc = 0;
 			else if (!spc && iswspace(tmp)) {
 				spc = 1;
 				spcptr = chptr;
 				w2 = i;
 			}
 			chptr += x;
-			x = wcwidth(tmp);
-			if (x>0)
-			    i+=x;
 		}
 		howbad += width - w2 + 1;
 #ifdef DEBUG_WRAP		    
 		fprintf(stderr,"adding %d\n",width - w2 + 1, chptr);
 #endif					
 		if (spcptr) chptr = spcptr;
 		if (result) {
 		    strncat(result, text, chptr - text );