1
0
forked from aniani/vim

patch 7.4.1779

Problem:    Using negative index in strcharpart(). (Yegappan Lakshmanan)
Solution:   Assume single byte when using a negative iindex.
This commit is contained in:
Bram Moolenaar
2016-04-23 13:54:48 +02:00
parent b2fa54a840
commit 73dfe917ba
2 changed files with 8 additions and 1 deletions

View File

@@ -19774,7 +19774,12 @@ f_strcharpart(typval_T *argvars, typval_T *rettv)
charlen = get_tv_number(&argvars[2]); charlen = get_tv_number(&argvars[2]);
while (charlen > 0 && nbyte + len < slen) while (charlen > 0 && nbyte + len < slen)
{ {
len += mb_char2len(p[nbyte + len]); int off = nbyte + len;
if (off < 0)
len += 1;
else
len += mb_char2len(p[off]);
--charlen; --charlen;
} }
} }

View File

@@ -753,6 +753,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 */
/**/
1779,
/**/ /**/
1778, 1778,
/**/ /**/