Patch 7.4.1742
Problem:    strgetchar() does not work correctly.
Solution:   use mb_cptr2len().  Add a test. (Naruhiko Nishino)
Files:      src/eval.c, src/testdir/test_expr_utf8.vim


*** ../vim-7.4.1741/src/eval.c  2016-04-14 15:55:58.401348489 +0200
--- src/eval.c  2016-04-14 22:47:10.355148958 +0200
***************
*** 13048,13073 ****
      rettv->vval.v_number = mch_get_pid();
  }
  
- static void getpos_both(typval_T *argvars, typval_T *rettv, int getcurpos);
- 
- /*
-  * "getcurpos()" function
-  */
-     static void
- f_getcurpos(typval_T *argvars, typval_T *rettv)
- {
-     getpos_both(argvars, rettv, TRUE);
- }
- 
- /*
-  * "getpos(string)" function
-  */
-     static void
- f_getpos(typval_T *argvars, typval_T *rettv)
- {
-     getpos_both(argvars, rettv, FALSE);
- }
- 
      static void
  getpos_both(
      typval_T  *argvars,
--- 13048,13053 ----
***************
*** 13110,13115 ****
--- 13090,13114 ----
        rettv->vval.v_number = FALSE;
  }
  
+ 
+ /*
+  * "getcurpos()" function
+  */
+     static void
+ f_getcurpos(typval_T *argvars, typval_T *rettv)
+ {
+     getpos_both(argvars, rettv, TRUE);
+ }
+ 
+ /*
+  * "getpos(string)" function
+  */
+     static void
+ f_getpos(typval_T *argvars, typval_T *rettv)
+ {
+     getpos_both(argvars, rettv, FALSE);
+ }
+ 
  /*
   * "getqflist()" and "getloclist()" functions
   */
***************
*** 19574,19580 ****
        return;
  #ifdef FEAT_MBYTE
      {
!       int             byteidx = 0;
  
        while (charidx >= 0 && byteidx < len)
        {
--- 19573,19579 ----
        return;
  #ifdef FEAT_MBYTE
      {
!       int     byteidx = 0;
  
        while (charidx >= 0 && byteidx < len)
        {
***************
*** 19584,19590 ****
                break;
            }
            --charidx;
!           byteidx += mb_char2len(str[byteidx]);
        }
      }
  #else
--- 19583,19589 ----
                break;
            }
            --charidx;
!           byteidx += mb_cptr2len(str + byteidx);
        }
      }
  #else
*** ../vim-7.4.1741/src/testdir/test_expr_utf8.vim      2016-04-14 
22:52:46.411611239 +0200
--- src/testdir/test_expr_utf8.vim      2016-04-14 22:53:32.751123771 +0200
***************
*** 12,17 ****
--- 12,21 ----
    call assert_equal(char2nr('a'), strgetchar('àxb', 0))
    call assert_equal(char2nr('̀'), strgetchar('àxb', 1))
    call assert_equal(char2nr('x'), strgetchar('àxb', 2))
+ 
+   call assert_equal(char2nr('あ'), strgetchar('あaい', 0))
+   call assert_equal(char2nr('a'), strgetchar('あaい', 1))
+   call assert_equal(char2nr('い'), strgetchar('あaい', 2))
  endfunc
  
  func Test_strcharpart()
*** ../vim-7.4.1741/src/version.c       2016-04-14 22:52:46.411611239 +0200
--- src/version.c       2016-04-14 22:53:41.891027635 +0200
***************
*** 750,751 ****
--- 750,753 ----
  {   /* Add new patch number below this line */
+ /**/
+     1742,
  /**/

-- 
Facepalm statement #4: "3000 year old graves?  That's not possible, it's only
2014!"

 /// 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