~ubuntu-branches/ubuntu/utopic/newt/utopic

« back to all changes in this revision

Viewing changes to debian/patches/720_newt_combiwrap.patch

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-07-01 23:06:29 UTC
  • mfrom: (2.1.23 sid)
  • Revision ID: package-import@ubuntu.com-20130701230629-vn7p5llzt03j09mv
Tags: 0.52.15-2ubuntu1
* Merge with Debian; remaining changes:
  - Fix python-* package descriptions.
  - Install/remove alternatives for the ubuntu palette.
  - Don't install python-newt example files.
  - Install whiptail in /bin instead of /usr/bin.
* Still build with tcl8.5 (8.6 is in universe).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Text incorrectly wrapping at combining characters
 
2
Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=570630
 
3
Author: Theppitak Karoonboonyanan
 
4
Forwarded: no
 
5
Last-Updated: 2010-02-20
 
6
 
 
7
diff -ruN8p newt-0.52.11-old/textbox.c newt-0.52.11/textbox.c
 
8
--- newt-0.52.11-old/textbox.c  2010-02-20 21:22:43.000000000 +0700
 
9
+++ newt-0.52.11/textbox.c      2010-02-20 21:23:04.000000000 +0700
 
10
@@ -205,34 +205,36 @@ static void doReflow(const char * text,
 
11
                fprintf(stderr,"adding %d\n",((width / 2) - (len)) / 2);
 
12
 #endif                                 
 
13
                    howbad += ((width / 2) - (len)) / 2;
 
14
                }
 
15
                text = end;
 
16
                if (*text) text++;
 
17
            } else {
 
18
                const char *spcptr = NULL;
 
19
-               int spc =0,w2, x;
 
20
+               int spc =0,w2, x, w;
 
21
 
 
22
                chptr = text;
 
23
                w2 = 0;
 
24
-               for (i = 0; i < width - 1;) {
 
25
+               for (i = 0; ;) {
 
26
                        if ((x=mbrtowc(&tmp,chptr,end-chptr,&ps))<=0)
 
27
                                break;
 
28
+                       w = wcwidth(tmp);
 
29
+                       if (w>0)
 
30
+                           i+=w;
 
31
+                       if (i >= width)
 
32
+                           break;
 
33
                        if (spc && !iswspace(tmp))
 
34
                                spc = 0;
 
35
                        else if (!spc && iswspace(tmp)) {
 
36
                                spc = 1;
 
37
                                spcptr = chptr;
 
38
                                w2 = i;
 
39
                        }
 
40
                        chptr += x;
 
41
-                       x = wcwidth(tmp);
 
42
-                       if (x>0)
 
43
-                           i+=x;
 
44
                }
 
45
                howbad += width - w2 + 1;
 
46
 #ifdef DEBUG_WRAP                  
 
47
                fprintf(stderr,"adding %d\n",width - w2 + 1, chptr);
 
48
 #endif                                 
 
49
                if (spcptr) chptr = spcptr;
 
50
                if (result) {
 
51
                    strncat(result, text, chptr - text );
 
52