diff --git a/reactos/lib/rtl/sprintf.c b/reactos/lib/rtl/sprintf.c index 441bec3ffd2..38673863a0a 100644 --- a/reactos/lib/rtl/sprintf.c +++ b/reactos/lib/rtl/sprintf.c @@ -115,12 +115,12 @@ number(char * buf, char * end, long long num, int base, int size, int precision, size--; } } + if (type & SPECIAL) { if (base == 16) size -= 2; - else if (base == 8) - size--; - } + + } i = 0; if ((num == 0) && (precision !=0)) tmp[i++] = '0'; @@ -141,12 +141,9 @@ number(char * buf, char * end, long long num, int base, int size, int precision, *buf = sign; ++buf; } + if (type & SPECIAL) { - if (base==8) { - if (buf <= end) - *buf = '0'; - ++buf; - } else if (base==16) { + if (base==16) { if (buf <= end) *buf = '0'; ++buf; @@ -155,6 +152,7 @@ number(char * buf, char * end, long long num, int base, int size, int precision, ++buf; } } + if (!(type & LEFT)) { while (size-- > 0) { if (buf <= end) @@ -177,6 +175,7 @@ number(char * buf, char * end, long long num, int base, int size, int precision, *buf = ' '; ++buf; } + return buf; } diff --git a/reactos/lib/rtl/swprintf.c b/reactos/lib/rtl/swprintf.c index 6ba1a925028..47be9107d1b 100644 --- a/reactos/lib/rtl/swprintf.c +++ b/reactos/lib/rtl/swprintf.c @@ -115,12 +115,11 @@ number(wchar_t * buf, wchar_t * end, long long num, int base, int size, int prec size--; } } + if (type & SPECIAL) { if (base == 16) size -= 2; - else if (base == 8) - size--; - } + } i = 0; if ((num == 0) && (precision !=0)) tmp[i++] = L'0'; @@ -141,12 +140,9 @@ number(wchar_t * buf, wchar_t * end, long long num, int base, int size, int prec *buf = sign; ++buf; } + if (type & SPECIAL) { - if (base==8) { - if (buf <= end) - *buf = L'0'; - ++buf; - } else if (base==16) { + if (base==16) { if (buf <= end) *buf = L'0'; ++buf; @@ -177,6 +173,8 @@ number(wchar_t * buf, wchar_t * end, long long num, int base, int size, int prec *buf = L' '; ++buf; } + + return buf; }