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

View File

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