From 78adf1b7db1c12652cbf2c23ec00b879043608c7 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Fri, 29 Aug 2008 18:57:31 +0000 Subject: [PATCH] Gregor Schneider - Only pad with zeroes if padding requested. - Show signs for floating point numbers without checking for SIGN type (since there is no unsigned float/double). See issue #3587 for more details. svn path=/trunk/; revision=35764 --- reactos/lib/sdk/crt/stdio/lnx_sprintf.c | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/reactos/lib/sdk/crt/stdio/lnx_sprintf.c b/reactos/lib/sdk/crt/stdio/lnx_sprintf.c index 3b48479e7c7..c8508a577ea 100644 --- a/reactos/lib/sdk/crt/stdio/lnx_sprintf.c +++ b/reactos/lib/sdk/crt/stdio/lnx_sprintf.c @@ -167,18 +167,16 @@ numberf(char * buf, char * end, double num, int base, int size, int precision, i return 0; c = (type & ZEROPAD) ? '0' : ' '; sign = 0; - if (type & SIGN) { - if (num < 0) { - sign = '-'; - num = -num; - size--; - } else if (type & PLUS) { - sign = '+'; - size--; - } else if (type & SPACE) { - sign = ' '; - size--; - } + if (num < 0) { + sign = '-'; + num = -num; + size--; + } else if (type & PLUS) { + sign = '+'; + size--; + } else if (type & SPACE) { + sign = ' '; + size--; } if (type & SPECIAL) { if (base == 16) @@ -231,10 +229,12 @@ numberf(char * buf, char * end, double num, int base, int size, int precision, i ++buf; } } - while (i < precision--) { - if (buf <= end) - *buf = '0'; - ++buf; + if (type & ZEROPAD) { + while (i < precision--) { + if (buf <= end) + *buf = '0'; + ++buf; + } } while (i-- > 0) { if (buf <= end)