summaryrefslogtreecommitdiff
path: root/src/message.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2012-11-14 18:10:56 +0100
committerBram Moolenaar <Bram@vim.org>2012-11-14 18:10:56 +0100
commit3ab72c5c72fb824da0e9c850479052d6f8c78e52 (patch)
tree44c3211ba24e2d7a8fb57290bd1ff6896ec50aa1 /src/message.c
parente3a2246227cfc1c9a4415d2c3f8a71622a67eac3 (diff)
downloadvim-git-3ab72c5c72fb824da0e9c850479052d6f8c78e52.tar.gz
updated for version 7.3.713v7.3.713
Problem: printf() can only align to bytes, not characters. Solution: Add the "S" item. (Christian Brabandt)
Diffstat (limited to 'src/message.c')
-rw-r--r--src/message.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/message.c b/src/message.c
index b9cc93fa1..f5d17146a 100644
--- a/src/message.c
+++ b/src/message.c
@@ -4290,6 +4290,7 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
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, a4, a5, a6, a7, a8, a9, a10)
}
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, a4, a5, a6, a7, a8, a9, a10)
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: