From 26cd0154216b957d0f41d4720955bfcfefc3d2f2 Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Tue, 6 Jun 2006 22:43:41 +0000 Subject: [PATCH] fixing two more bugs in *printf strings version. this make we pass one more of wine test svn path=/trunk/; revision=22255 --- reactos/lib/rtl/sprintf.c | 12 ++++++++++-- reactos/lib/rtl/swprintf.c | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/reactos/lib/rtl/sprintf.c b/reactos/lib/rtl/sprintf.c index e020319603a..c258476e7d8 100644 --- a/reactos/lib/rtl/sprintf.c +++ b/reactos/lib/rtl/sprintf.c @@ -286,6 +286,10 @@ static char* string(char* buf, char* end, const char* s, int len, int field_width, int precision, int flags) { int i; + char c; + + c = (flags & ZEROPAD) ? '0' : ' '; + if (s == NULL) { s = ""; @@ -309,7 +313,7 @@ string(char* buf, char* end, const char* s, int len, int field_width, int precis while (len < field_width--) { if (buf <= end) - *buf = ' '; + *buf = c; ++buf; } for (i = 0; i < len; ++i) @@ -331,6 +335,10 @@ static char* stringw(char* buf, char* end, const wchar_t* sw, int len, int field_width, int precision, int flags) { int i; + char c; + + c = (flags & ZEROPAD) ? '0' : ' '; + if (sw == NULL) { sw = L""; @@ -354,7 +362,7 @@ stringw(char* buf, char* end, const wchar_t* sw, int len, int field_width, int p while (len < field_width--) { if (buf <= end) - *buf = ' '; + *buf = c; buf++; } for (i = 0; i < len; ++i) diff --git a/reactos/lib/rtl/swprintf.c b/reactos/lib/rtl/swprintf.c index 4a71ffda121..33f5ac4e371 100644 --- a/reactos/lib/rtl/swprintf.c +++ b/reactos/lib/rtl/swprintf.c @@ -286,6 +286,10 @@ static wchar_t* string(wchar_t* buf, wchar_t* end, const char* s, int len, int field_width, int precision, int flags) { int i; + wchar_t c; + + c = (flags & ZEROPAD) ? L'0' : L' '; + if (s == NULL) { s = ""; @@ -309,7 +313,7 @@ string(wchar_t* buf, wchar_t* end, const char* s, int len, int field_width, int while (len < field_width--) { if (buf <= end) - *buf = L' '; + *buf = c; ++buf; } for (i = 0; i < len; ++i) @@ -331,6 +335,10 @@ static wchar_t* stringw(wchar_t* buf, wchar_t* end, const wchar_t* sw, int len, int field_width, int precision, int flags) { int i; + wchar_t c; + + c = (flags & ZEROPAD) ? L'0' : L' '; + if (sw == NULL) { sw = L""; @@ -354,7 +362,7 @@ stringw(wchar_t* buf, wchar_t* end, const wchar_t* sw, int len, int field_width, while (len < field_width--) { if (buf <= end) - *buf = L' '; + *buf = c; buf++; } for (i = 0; i < len; ++i)