patch 7.4.1742
Problem: strgetchar() does not work correctly.
Solution: use mb_cptr2len(). Add a test. (Naruhiko Nishino)
diff --git a/src/eval.c b/src/eval.c
index 5ced88e..bd4a11a 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -13048,26 +13048,6 @@
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
getpos_both(
typval_T *argvars,
@@ -13110,6 +13090,25 @@
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
*/
@@ -19574,7 +19573,7 @@
return;
#ifdef FEAT_MBYTE
{
- int byteidx = 0;
+ int byteidx = 0;
while (charidx >= 0 && byteidx < len)
{
@@ -19584,7 +19583,7 @@
break;
}
--charidx;
- byteidx += mb_char2len(str[byteidx]);
+ byteidx += mb_cptr2len(str + byteidx);
}
}
#else