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