summaryrefslogtreecommitdiff
path: root/source/ap/vim/patches/7.2.348
blob: 5f4ffbd0320a11ecdef1f35f3b8361c6949a9e13 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
To: vim-dev@vim.org
Subject: Patch 7.2.348 (after 7.2.330)
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.348 (after 7.2.330)
Problem:    Unicode double-width characters are not up-to date.
Solution:   Produce the double-width table like the others.
Files:	    runtime/tools/unicode.vim, src/mbyte.c


*** ../vim-7.2.347/runtime/tools/unicode.vim	2010-01-12 19:48:57.000000000 +0100
--- runtime/tools/unicode.vim	2010-01-27 17:57:17.000000000 +0100
***************
*** 187,202 ****
    wincmd p
  endfunc
  
! " Build the ambiguous table in a new buffer.
  " Uses s:widthprops and s:dataprops.
! func! BuildAmbiguousTable()
    let start = -1
    let end = -1
    let ranges = []
    let dataidx = 0
    for p in s:widthprops
!     if p[1][0] == 'A'
!       let n = ('0x' . p[0]) + 0
        " Find this char in the data table.
        while 1
  	let dn = ('0x' . s:dataprops[dataidx][0]) + 0
--- 187,213 ----
    wincmd p
  endfunc
  
! " Build the double width or ambiguous width table in a new buffer.
  " Uses s:widthprops and s:dataprops.
! func! BuildWidthTable(pattern, tableName)
    let start = -1
    let end = -1
    let ranges = []
    let dataidx = 0
    for p in s:widthprops
!     if p[1][0] =~ a:pattern
!       if p[0] =~ '\.\.'
! 	" It is a range.  we don't check for composing char then.
! 	let rng = split(p[0], '\.\.')
! 	if len(rng) != 2
! 	  echoerr "Cannot parse range: '" . p[0] . "' in width table"
! 	endif
! 	let n = ('0x' . rng[0]) + 0
! 	let n_last =  ('0x' . rng[1]) + 0
!       else
! 	let n = ('0x' . p[0]) + 0
! 	let n_last = n
!       endif
        " Find this char in the data table.
        while 1
  	let dn = ('0x' . s:dataprops[dataidx][0]) + 0
***************
*** 205,231 ****
  	endif
  	let dataidx += 1
        endwhile
!       if dn != n
  	echoerr "Cannot find character " . n . " in data table"
        endif
        " Only use the char when it's not a composing char.
        let dp = s:dataprops[dataidx]
!       if dp[2] != 'Mn' && dp[2] != 'Mc' && dp[2] != 'Me'
  	if start >= 0 && end + 1 == n
  	  " continue with same range.
- 	  let end = n
  	else
  	  if start >= 0
  	    " produce previous range
  	    call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end))
  	  endif
  	  let start = n
- 	  if p[0] =~ '\.\.'
- 	    let end = ('0x' . substitute(p[0], '.*\.\.', '', '')) + 0
- 	  else
- 	    let end = n
- 	  endif
  	endif
        endif
      endif
    endfor
--- 216,238 ----
  	endif
  	let dataidx += 1
        endwhile
!       if dn != n && n_last == n
  	echoerr "Cannot find character " . n . " in data table"
        endif
        " Only use the char when it's not a composing char.
+       " But use all chars from a range.
        let dp = s:dataprops[dataidx]
!       if n_last > n || (dp[2] != 'Mn' && dp[2] != 'Mc' && dp[2] != 'Me')
  	if start >= 0 && end + 1 == n
  	  " continue with same range.
  	else
  	  if start >= 0
  	    " produce previous range
  	    call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end))
  	  endif
  	  let start = n
  	endif
+ 	let end = n_last
        endif
      endif
    endfor
***************
*** 235,242 ****
  
    " New buffer to put the result in.
    new
!   file ambiguous
!   call setline(1, "    static struct interval ambiguous[] =")
    call setline(2, "    {")
    call append('$', ranges)
    call setline('$', getline('$')[:-2])  " remove last comma
--- 242,249 ----
  
    " New buffer to put the result in.
    new
!   exe "file " . a:tableName
!   call setline(1, "    static struct interval " . a:tableName . "[] =")
    call setline(2, "    {")
    call append('$', ranges)
    call setline('$', getline('$')[:-2])  " remove last comma
***************
*** 276,280 ****
  " Parse each line, create a list of lists.
  call ParseWidthProps()
  
! " Build the ambiguous table.
! call BuildAmbiguousTable()
--- 283,290 ----
  " Parse each line, create a list of lists.
  call ParseWidthProps()
  
! " Build the double width table.
! call BuildWidthTable('[WF]', 'doublewidth')
! 
! " Build the ambiguous width table.
! call BuildWidthTable('A', 'ambiguous')
*** ../vim-7.2.347/src/mbyte.c	2010-01-12 19:48:57.000000000 +0100
--- src/mbyte.c	2010-01-27 18:06:35.000000000 +0100
***************
*** 1200,1205 ****
--- 1200,1248 ----
  utf_char2cells(c)
      int		c;
  {
+     /* Sorted list of non-overlapping intervals of East Asian double width
+      * characters, generated with ../runtime/tools/unicode.vim. */
+     static struct interval doublewidth[] =
+     {
+ 	{0x1100, 0x115f},
+ 	{0x11a3, 0x11a7},
+ 	{0x11fa, 0x11ff},
+ 	{0x2329, 0x232a},
+ 	{0x2e80, 0x2e99},
+ 	{0x2e9b, 0x2ef3},
+ 	{0x2f00, 0x2fd5},
+ 	{0x2ff0, 0x2ffb},
+ 	{0x3000, 0x3029},
+ 	{0x3030, 0x303e},
+ 	{0x3041, 0x3096},
+ 	{0x309b, 0x30ff},
+ 	{0x3105, 0x312d},
+ 	{0x3131, 0x318e},
+ 	{0x3190, 0x31b7},
+ 	{0x31c0, 0x31e3},
+ 	{0x31f0, 0x321e},
+ 	{0x3220, 0x3247},
+ 	{0x3250, 0x32fe},
+ 	{0x3300, 0x4dbf},
+ 	{0x4e00, 0xa48c},
+ 	{0xa490, 0xa4c6},
+ 	{0xa960, 0xa97c},
+ 	{0xac00, 0xd7a3},
+ 	{0xd7b0, 0xd7c6},
+ 	{0xd7cb, 0xd7fb},
+ 	{0xf900, 0xfaff},
+ 	{0xfe10, 0xfe19},
+ 	{0xfe30, 0xfe52},
+ 	{0xfe54, 0xfe66},
+ 	{0xfe68, 0xfe6b},
+ 	{0xff01, 0xff60},
+ 	{0xffe0, 0xffe6},
+ 	{0x1f200, 0x1f200},
+ 	{0x1f210, 0x1f231},
+ 	{0x1f240, 0x1f248},
+ 	{0x20000, 0x2fffd},
+ 	{0x30000, 0x3fffd}
+     };
      /* Sorted list of non-overlapping intervals of East Asian Ambiguous
       * characters, generated with ../runtime/tools/unicode.vim. */
      static struct interval ambiguous[] =
***************
*** 1403,1422 ****
  #else
  	if (!utf_printable(c))
  	    return 6;		/* unprintable, displays <xxxx> */
! 	if (c >= 0x1100
! 	    && (c <= 0x115f			/* Hangul Jamo */
! 		|| c == 0x2329
! 		|| c == 0x232a
! 		|| (c >= 0x2e80 && c <= 0xa4cf
! 		    && c != 0x303f)		/* CJK ... Yi */
! 		|| (c >= 0xac00 && c <= 0xd7a3)	/* Hangul Syllables */
! 		|| (c >= 0xf900 && c <= 0xfaff)	/* CJK Compatibility
! 						   Ideographs */
! 		|| (c >= 0xfe30 && c <= 0xfe6f)	/* CJK Compatibility Forms */
! 		|| (c >= 0xff00 && c <= 0xff60)	/* Fullwidth Forms */
! 		|| (c >= 0xffe0 && c <= 0xffe6)
! 		|| (c >= 0x20000 && c <= 0x2fffd)
! 		|| (c >= 0x30000 && c <= 0x3fffd)))
  	    return 2;
  #endif
      }
--- 1446,1452 ----
  #else
  	if (!utf_printable(c))
  	    return 6;		/* unprintable, displays <xxxx> */
! 	if (intable(doublewidth, sizeof(doublewidth), c))
  	    return 2;
  #endif
      }
*** ../vim-7.2.347/src/version.c	2010-01-27 17:31:38.000000000 +0100
--- src/version.c	2010-01-27 18:25:50.000000000 +0100
***************
*** 683,684 ****
--- 683,686 ----
  {   /* Add new patch number below this line */
+ /**/
+     348,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
157. You fum through a magazine, you first check to see if it has a web
     address.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///