text: remove useless arg from mb_string2cells

mb_string2cells was always called like mb_string2cells(..., -1) so that was
the only codepath that was tested. @tarruda was the first to try to input an
actual length, after which valgrind detected that funny business was going
on.

It's not even possible to do the right thing with the current text codec
infrastructure: they all assume to be working with C strings. Meaning that
if there is no NUL-terminator, they will happily keep on reading past the
end of Pascal strings. Ergo, passing the length parameter is moot. The
condition in the for-loop was wrong as well (but that's no longer relevant).

Also change the return value to size_t, by analogy with strlen.

ref:
677d30d796
This commit is contained in:
Nicolas Hillegeer
2014-05-29 10:13:08 +02:00
committed by Justin M. Keyes
parent 63a956112a
commit 46e4bc0481
5 changed files with 16 additions and 16 deletions

View File

@@ -3352,7 +3352,7 @@ int vim_vsnprintf(char *str, size_t str_m, char *fmt, va_list ap, typval_T *tvs)
if (fmt_spec == 'S') {
if (min_field_width != 0)
min_field_width += STRLEN(str_arg)
- mb_string2cells((char_u *)str_arg, -1);
- mb_string2cells((char_u *) str_arg);
if (precision) {
char_u *p1 = (char_u *)str_arg;
size_t i;