From a8e8a546b607bd4eeaca0696d7adc76c5bd3f849 Mon Sep 17 00:00:00 2001 From: Gregor Schneider Date: Sat, 29 Nov 2008 19:39:53 +0000 Subject: [PATCH] - Updated msvcrt winetests introduced new printf testcases and new failures - fixed: - Special qualifiers with short gG formats may even skip all decimal digits, but the separator is applied nonetheless - Padding spaces on the right caused problems in exponential format, because those are split into two parts, the padding was done in between - Failing fwprintf test was removed from the tests, so the printf test is passed completely now svn path=/trunk/; revision=37740 --- reactos/lib/sdk/crt/stdio/lnx_sprintf.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/reactos/lib/sdk/crt/stdio/lnx_sprintf.c b/reactos/lib/sdk/crt/stdio/lnx_sprintf.c index 57a7b27ae8c..8eb88426261 100644 --- a/reactos/lib/sdk/crt/stdio/lnx_sprintf.c +++ b/reactos/lib/sdk/crt/stdio/lnx_sprintf.c @@ -166,6 +166,7 @@ numberf(char * buf, char * end, double num, char exp_sign, int size, int precisi int i = 0; int j = 0; int ro = 0; + int isize; double frac, intr; double p; @@ -194,6 +195,7 @@ numberf(char * buf, char * end, double num, char exp_sign, int size, int precisi exp_sign -= 2; // g -> e and G -> E else exp_sign = 'f'; + if (type & SPECIAL) precision--; } if ( exp_sign == 'e' || exp_sign == 'E' ) @@ -210,6 +212,13 @@ numberf(char * buf, char * end, double num, char exp_sign, int size, int precisi /* size-5 because "e+abc" is going to follow */ buf = numberf(buf, end, num/pow(10.0L,(long double)e), 'f', size-5, precision, type); + isize = 4; + while(*(buf-1) == ' ') + { + isize++; + --buf; + } + if (buf <= end) *buf = exp_sign; ++buf; @@ -217,7 +226,7 @@ numberf(char * buf, char * end, double num, char exp_sign, int size, int precisi ie = (long)e; type = LEFT | SIGN | PLUS; - buf = number(buf, end, ie, 10, 3, 3, type); + buf = number(buf, end, ie, 10, isize, 3, type); return buf; } @@ -259,16 +268,17 @@ numberf(char * buf, char * end, double num, char exp_sign, int size, int precisi digits[i] = (int)p + '0'; i--; } + i = precision; size -= precision; - - if ( precision >= 1 || type & SPECIAL) - { - digits[i++] = '.'; - size--; - } } + if ( precision >= 1 || type & SPECIAL) + { + digits[i++] = '.'; + size--; + } + ro = 0; if ( frac > 0.5 ) {