Patch 7.4.1782
Problem:    strcharpart() does not work properly with some multi-byte
            characters.
Solution:   Use mb_cptr2len() instead of mb_char2len(). (Hirohito Higashi)
Files:      src/eval.c, src/testdir/test_expr_utf8.vim


*** ../vim-7.4.1781/src/eval.c  2016-04-23 15:18:55.069278328 +0200
--- src/eval.c  2016-04-23 15:24:50.197543980 +0200
***************
*** 19764,19770 ****
        if (nchar > 0)
            while (nchar > 0 && nbyte < slen)
            {
!               nbyte += mb_char2len(p[nbyte]);
                --nchar;
            }
        else
--- 19764,19770 ----
        if (nchar > 0)
            while (nchar > 0 && nbyte < slen)
            {
!               nbyte += mb_cptr2len(p + nbyte);
                --nchar;
            }
        else
***************
*** 19779,19785 ****
                if (off < 0)
                    len += 1;
                else
!                   len += mb_char2len(p[off]);
                --charlen;
            }
        }
--- 19779,19785 ----
                if (off < 0)
                    len += 1;
                else
!                   len += mb_cptr2len(p + off);
                --charlen;
            }
        }
*** ../vim-7.4.1781/src/testdir/test_expr_utf8.vim      2016-04-14 
22:54:20.818618214 +0200
--- src/testdir/test_expr_utf8.vim      2016-04-23 15:23:48.038205952 +0200
***************
*** 23,28 ****
--- 23,38 ----
    call assert_equal('á', strcharpart('áxb', 0, 1))
    call assert_equal('x', strcharpart('áxb', 1, 1))
  
+   call assert_equal('いうeお', strcharpart('あいうeお', 1))
+   call assert_equal('い', strcharpart('あいうeお', 1, 1))
+   call assert_equal('いう', strcharpart('あいうeお', 1, 2))
+   call assert_equal('いうe', strcharpart('あいうeお', 1, 3))
+   call assert_equal('いうeお', strcharpart('あいうeお', 1, 4))
+   call assert_equal('eお', strcharpart('あいうeお', 3))
+   call assert_equal('e', strcharpart('あいうeお', 3, 1))
+ 
+   call assert_equal('あ', strcharpart('あいうeお', -3, 4))
+ 
    call assert_equal('a', strcharpart('àxb', 0, 1))
    call assert_equal('̀', strcharpart('àxb', 1, 1))
    call assert_equal('x', strcharpart('àxb', 2, 1))
*** ../vim-7.4.1781/src/version.c       2016-04-23 15:18:55.069278328 +0200
--- src/version.c       2016-04-23 15:27:07.664081041 +0200
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     1782,
  /**/

-- 
Trees moving back and forth is what makes the wind blow.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui