Problem: printf() can only align to bytes, not characters.
Solution: Add the "S" item. (Christian Brabandt)
Often used items are:
%s string
+ %6S string right-aligned in 6 display cells
%6s string right-aligned in 6 bytes
%.9s string truncated to 9 bytes
%c single byte
s The text of the String argument is used. If a
precision is specified, no more bytes than the number
specified are used.
+ S The text of the String argument is used. If a
+ precision is specified, no more display cells than the
+ number specified are used. Without the |+multi_byte|
+ feature works just like 's'.
*printf-f* *E807*
f The Float argument is converted into a string of the
case '%':
case 'c':
case 's':
+ case 'S':
length_modifier = '\0';
str_arg_l = 1;
switch (fmt_spec)
}
case 's':
+ case 'S':
str_arg =
#ifndef HAVE_STDARG_H
(char *)get_a_arg(arg_idx);
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:
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 713,
/**/
712,
/**/