Mercurial > vim
diff src/message.c @ 3914:f15769bce0b8 v7.3.713
updated for version 7.3.713
Problem: printf() can only align to bytes, not characters.
Solution: Add the "S" item. (Christian Brabandt)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 14 Nov 2012 18:10:56 +0100 |
parents | 19040069b8bf |
children | b31989e2b058 |
line wrap: on
line diff
--- a/src/message.c +++ b/src/message.c @@ -4290,6 +4290,7 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3 case '%': case 'c': case 's': + case 'S': length_modifier = '\0'; str_arg_l = 1; switch (fmt_spec) @@ -4318,6 +4319,7 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3 } case 's': + case 'S': str_arg = #ifndef HAVE_STDARG_H (char *)get_a_arg(arg_idx); @@ -4354,6 +4356,24 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3 str_arg_l = (q == NULL) ? precision : (size_t)(q - str_arg); } +#ifdef FEAT_MBYTE + if (fmt_spec == 'S') + { + if (min_field_width != 0) + min_field_width += STRLEN(str_arg) + - mb_string2cells((char_u *)str_arg, -1); + if (precision) + { + char_u *p1 = (char_u *)str_arg; + size_t i; + + for (i = 0; i < precision && *p1; i++) + p1 += mb_ptr2len(p1); + + str_arg_l = precision = p1 - (char_u *)str_arg; + } + } +#endif break; default: