Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2016-02-08 15:33:17 +0300
committerCorinna Vinschen <corinna@vinschen.de>2016-02-08 15:33:17 +0300
commitc4dcfc1bda72883aa20eba627af840d1a4256c7b (patch)
treedeec0a9c189c7d36e4ca8486e1ca7c41fac7c132
parentc5fee55606ef77b1ec665e2903848cc9c504297c (diff)
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>
-rw-r--r--newlib/libc/stdio/vfprintf.c16
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 */