diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2016-02-08 13:33:17 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2016-02-08 13:33:17 +0100 |
commit | c4dcfc1bda72883aa20eba627af840d1a4256c7b (patch) | |
tree | deec0a9c189c7d36e4ca8486e1ca7c41fac7c132 /newlib/libc/stdio/vfprintf.c | |
parent | c5fee55606ef77b1ec665e2903848cc9c504297c (diff) | |
download | cygnal-c4dcfc1bda72883aa20eba627af840d1a4256c7b.tar.gz cygnal-c4dcfc1bda72883aa20eba627af840d1a4256c7b.tar.bz2 cygnal-c4dcfc1bda72883aa20eba627af840d1a4256c7b.zip |
printf(3): Handle multibyte decimal point in field size computation
This patch fixes the problem reported in
https://cygwin.com/ml/cygwin/2016-02/msg00014.html
The 2009 changes to handle multibyte decimal point and thousands
separator missed to take the length of a multibyte decimal point into
account when computing the field size.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'newlib/libc/stdio/vfprintf.c')
-rw-r--r-- | newlib/libc/stdio/vfprintf.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 5e6c61ca4..6430edf2c 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -1332,7 +1332,7 @@ reswitch: switch (ch) { expsize = exponent (expstr, expt, ch); size = expsize + ndig; if (ndig > 1 || flags & ALT) - ++size; + size += decp_len; # ifdef _WANT_IO_C99_FORMATS flags &= ~GROUPING; # endif @@ -1341,18 +1341,20 @@ reswitch: switch (ch) { if (expt > 0) { size = expt; if (prec || flags & ALT) - size += prec + 1; + size += prec + decp_len; } else /* "0.X" */ size = (prec || flags & ALT) - ? prec + 2 + ? prec + 1 + decp_len : 1; } else if (expt >= ndig) { /* fixed g fmt */ size = expt; if (flags & ALT) - ++size; - } else - size = ndig + (expt > 0 ? - 1 : 2 - expt); + size += decp_len; + } else { + size = ndig + decp_len; + if (expt <= 0) + size += 1 - expt; + } # ifdef _WANT_IO_C99_FORMATS if ((flags & GROUPING) && expt > 0) { /* space for thousands' grouping */ |