comparison src/message.c @ 18176:dfe9db84e326 v8.1.2083

patch 8.1.2083: multi-byte chars do not work properly with "%.*S" in printf() Commit: https://github.com/vim/vim/commit/ce0fac28977af31f1dec411d3535b4de2c3169b3 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 27 13:32:06 2019 +0200 patch 8.1.2083: multi-byte chars do not work properly with "%.*S" in printf() Problem: Multi-byte chars do not work properly with "%.*S" in printf(). Solution: Use mb_ptr2cells(). Daniel Hahler, closes https://github.com/vim/vim/issues/4989)
author Bram Moolenaar <Bram@vim.org>
date Fri, 27 Sep 2019 13:45:04 +0200
parents 1868ec23360e
children 1c5974759bcd
comparison
equal deleted inserted replaced
18175:0f3b1cafbf8c 18176:dfe9db84e326
4403 if (min_field_width != 0) 4403 if (min_field_width != 0)
4404 min_field_width += STRLEN(str_arg) 4404 min_field_width += STRLEN(str_arg)
4405 - mb_string2cells((char_u *)str_arg, -1); 4405 - mb_string2cells((char_u *)str_arg, -1);
4406 if (precision) 4406 if (precision)
4407 { 4407 {
4408 char_u *p1 = (char_u *)str_arg; 4408 char_u *p1;
4409 size_t i; 4409 size_t i = 0;
4410 4410
4411 for (i = 0; i < precision && *p1; i++) 4411 for (p1 = (char_u *)str_arg; *p1;
4412 p1 += mb_ptr2len(p1); 4412 p1 += mb_ptr2len(p1))
4413 4413 {
4414 i += (size_t)mb_ptr2cells(p1);
4415 if (i > precision)
4416 break;
4417 }
4414 str_arg_l = precision = p1 - (char_u *)str_arg; 4418 str_arg_l = precision = p1 - (char_u *)str_arg;
4415 } 4419 }
4416 } 4420 }
4417 break; 4421 break;
4418 4422