vim-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)

fca6600305
This commit is contained in:
Michael Ennen 2016-10-23 17:10:14 -07:00
parent 6bc0d9b8c7
commit f6f77272b3
3 changed files with 5 additions and 5 deletions

View File

@ -15762,7 +15762,7 @@ static void f_strcharpart(typval_T *argvars, typval_T *rettv, FunPtr fptr) {
if (!error) {
if (nchar > 0) {
while (nchar > 0 && nbyte < slen) {
nbyte += mb_char2len(p[nbyte]);
nbyte += mb_cptr2len(p + nbyte);
nchar--;
}
} else {
@ -15777,9 +15777,9 @@ static void f_strcharpart(typval_T *argvars, typval_T *rettv, FunPtr fptr) {
if (off < 0) {
len += 1;
} else {
len += mb_char2len(p[off]);
charlen--;
len += mb_cptr2len(p + off);
}
charlen--;
}
} else {
len = slen - nbyte; // default: all bytes that are available.

View File

@ -272,7 +272,7 @@ return {
strchars={args={1,2}},
strdisplaywidth={args={1, 2}},
strftime={args={1, 2}},
strgetchar={args={2,2}},
strgetchar={args={2, 2}},
stridx={args={2, 3}},
string={args=1},
strlen={args=1},

View File

@ -660,7 +660,7 @@ static int included_patches[] = {
// 1785,
// 1784 NA
// 1783,
// 1782,
1782,
// 1781,
// 1780,
1779,