mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 7.4.1742
Problem: strgetchar() does not work correctly. Solution: use mb_cptr2len(). Add a test. (Naruhiko Nishino)
This commit is contained in:
41
src/eval.c
41
src/eval.c
@@ -13048,26 +13048,6 @@ f_getpid(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
rettv->vval.v_number = mch_get_pid();
|
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
|
static void
|
||||||
getpos_both(
|
getpos_both(
|
||||||
typval_T *argvars,
|
typval_T *argvars,
|
||||||
@@ -13110,6 +13090,25 @@ getpos_both(
|
|||||||
rettv->vval.v_number = FALSE;
|
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
|
* "getqflist()" and "getloclist()" functions
|
||||||
*/
|
*/
|
||||||
@@ -19584,7 +19583,7 @@ f_strgetchar(typval_T *argvars, typval_T *rettv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
--charidx;
|
--charidx;
|
||||||
byteidx += mb_char2len(str[byteidx]);
|
byteidx += mb_cptr2len(str + byteidx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@@ -12,6 +12,10 @@ func Test_strgetchar()
|
|||||||
call assert_equal(char2nr('a'), strgetchar('àxb', 0))
|
call assert_equal(char2nr('a'), strgetchar('àxb', 0))
|
||||||
call assert_equal(char2nr('̀'), strgetchar('àxb', 1))
|
call assert_equal(char2nr('̀'), strgetchar('àxb', 1))
|
||||||
call assert_equal(char2nr('x'), strgetchar('àxb', 2))
|
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
|
endfunc
|
||||||
|
|
||||||
func Test_strcharpart()
|
func Test_strcharpart()
|
||||||
|
@@ -748,6 +748,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1742,
|
||||||
/**/
|
/**/
|
||||||
1741,
|
1741,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user