[vim] 56/139: patch 7.4.1742 Problem: strgetchar() does not work correctly. Solution: use mb_cptr2len(). Add a test. (Naruhiko Nishino)
James McCoy
jamessan at debian.org
Fri May 6 04:00:01 UTC 2016
This is an automated email from the git hooks/post-receive script.
jamessan pushed a commit to branch debian/sid
in repository vim.
commit 5d18e0eca59ffbba22c7f7c91c9f99d672095728
Author: Bram Moolenaar <Bram at vim.org>
Date: Thu Apr 14 22:54:24 2016 +0200
patch 7.4.1742
Problem: strgetchar() does not work correctly.
Solution: use mb_cptr2len(). Add a test. (Naruhiko Nishino)
---
src/eval.c | 43 +++++++++++++++++++++---------------------
src/testdir/test_expr_utf8.vim | 4 ++++
src/version.c | 2 ++
3 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/src/eval.c b/src/eval.c
index 5ced88e..bd4a11a 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -13048,26 +13048,6 @@ f_getpid(typval_T *argvars UNUSED, typval_T *rettv)
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,
@@ -13110,6 +13090,25 @@ getpos_both(
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,7 +19573,7 @@ f_strgetchar(typval_T *argvars, typval_T *rettv)
return;
#ifdef FEAT_MBYTE
{
- int byteidx = 0;
+ int byteidx = 0;
while (charidx >= 0 && byteidx < len)
{
@@ -19584,7 +19583,7 @@ f_strgetchar(typval_T *argvars, typval_T *rettv)
break;
}
--charidx;
- byteidx += mb_char2len(str[byteidx]);
+ byteidx += mb_cptr2len(str + byteidx);
}
}
#else
diff --git a/src/testdir/test_expr_utf8.vim b/src/testdir/test_expr_utf8.vim
index ec36dec..c512ddf 100644
--- a/src/testdir/test_expr_utf8.vim
+++ b/src/testdir/test_expr_utf8.vim
@@ -12,6 +12,10 @@ func Test_strgetchar()
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()
diff --git a/src/version.c b/src/version.c
index 07f1a0d..4c00d31 100644
--- a/src/version.c
+++ b/src/version.c
@@ -749,6 +749,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1742,
+/**/
1741,
/**/
1740,
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-vim/vim.git
More information about the pkg-vim-maintainers
mailing list