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