mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 13:58:18 +00:00
vim-patch:8.2.3663: using %S in printf() does not work correctly
Problem: Using %S in printf() does not work correctly.
Solution: Fix the problem and add more tests. (closes vim/vim#9208)
1f2453fec6
This commit is contained in:
@@ -1001,25 +1001,20 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap, t
|
||||
- str_arg);
|
||||
}
|
||||
if (fmt_spec == 'S') {
|
||||
size_t base_width = min_field_width;
|
||||
size_t pad_cell = 0;
|
||||
char_u *p1;
|
||||
size_t i;
|
||||
|
||||
if (precision) {
|
||||
char_u *p1;
|
||||
size_t i = 0;
|
||||
|
||||
for (p1 = (char_u *)str_arg; *p1;
|
||||
p1 += utfc_ptr2len(p1)) {
|
||||
i += (size_t)utf_ptr2cells(p1);
|
||||
if (i > precision) {
|
||||
break;
|
||||
}
|
||||
for (i = 0, p1 = (char_u *)str_arg; *p1; p1 += utfc_ptr2len(p1)) {
|
||||
size_t cell = (size_t)utf_ptr2cells(p1);
|
||||
if (precision_specified && i + cell > precision) {
|
||||
break;
|
||||
}
|
||||
pad_cell = min_field_width - precision;
|
||||
base_width = str_arg_l = (size_t)(p1 - (char_u *)str_arg);
|
||||
i += cell;
|
||||
}
|
||||
|
||||
str_arg_l = (size_t)(p1 - (char_u *)str_arg);
|
||||
if (min_field_width != 0) {
|
||||
min_field_width = base_width + pad_cell;
|
||||
min_field_width += str_arg_l - i;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user