]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 7.4.1779 v7.4.1779
authorBram Moolenaar <Bram@vim.org>
Sat, 23 Apr 2016 11:54:48 +0000 (13:54 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 23 Apr 2016 11:54:48 +0000 (13:54 +0200)
Problem:    Using negative index in strcharpart(). (Yegappan Lakshmanan)
Solution:   Assume single byte when using a negative iindex.

src/eval.c
src/version.c

index 146348dd803391c930b5b5e4077fcf3d5511bee5..a3fe2a2775c285d4bf167ef95c24ccf491e6d15b 100644 (file)
@@ -19774,7 +19774,12 @@ f_strcharpart(typval_T *argvars, typval_T *rettv)
            charlen = get_tv_number(&argvars[2]);
            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;
            }
        }
index 9aa400e8ffba0479687850156c8bd4534fd9a55b..adbb46a7550c809381ad5544b170cc9765696a04 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1779,
 /**/
     1778,
 /**/