@@ -3810,7 +3810,7 @@ do_lock_var(lp, name_end, deep, lock)
38103810 /* (un)lock a List item. */
38113811 item_lock(&lp->ll_li->li_tv, deep, lock);
38123812 else
3813- /* un(lock) a Dictionary item. */
3813+ /* (un)lock a Dictionary item. */
38143814 item_lock(&lp->ll_di->di_tv, deep, lock);
38153815
38163816 return ret;
@@ -8310,7 +8310,7 @@ static struct fst
83108310 {"str2float", 1, 1, f_str2float},
83118311#endif
83128312 {"str2nr", 1, 2, f_str2nr},
8313- {"strchars", 1, 1 , f_strchars},
8313+ {"strchars", 1, 2 , f_strchars},
83148314 {"strdisplaywidth", 1, 2, f_strdisplaywidth},
83158315#ifdef HAVE_STRFTIME
83168316 {"strftime", 1, 2, f_strftime},
@@ -18400,18 +18400,30 @@ f_strchars(argvars, rettv)
1840018400 typval_T *rettv;
1840118401{
1840218402 char_u *s = get_tv_string(&argvars[0]);
18403+ int skipcc = 0;
1840318404#ifdef FEAT_MBYTE
1840418405 varnumber_T len = 0;
18406+ int (*func_mb_ptr2char_adv)(char_u **pp);
18407+ #endif
1840518408
18406- while (*s != NUL)
18409+ if (argvars[1].v_type != VAR_UNKNOWN)
18410+ skipcc = get_tv_number_chk(&argvars[1], NULL);
18411+ if (skipcc < 0 || skipcc > 1)
18412+ EMSG(_(e_invarg));
18413+ else
1840718414 {
18408- mb_cptr2char_adv(&s);
18409- ++len;
18410- }
18411- rettv->vval.v_number = len;
18415+ #ifdef FEAT_MBYTE
18416+ func_mb_ptr2char_adv = skipcc ? mb_ptr2char_adv : mb_cptr2char_adv;
18417+ while (*s != NUL)
18418+ {
18419+ func_mb_ptr2char_adv(&s);
18420+ ++len;
18421+ }
18422+ rettv->vval.v_number = len;
1841218423#else
18413- rettv->vval.v_number = (varnumber_T)(STRLEN(s));
18424+ rettv->vval.v_number = (varnumber_T)(STRLEN(s));
1841418425#endif
18426+ }
1841518427}
1841618428
1841718429/*
0 commit comments