From d62e9d48be1fa4bae9a29423c07f443ba713756c Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Sun, 28 May 2006 04:58:27 +0000 Subject: [PATCH] starteted implement float into sprintf, snprintf and alot other printf api. this is more like a start how to implement it. This commit is more market for me. so I do not forget where string functions of *printf api (the main api functions) are. One more thing if u change on sprintf.c same change must be done in swprintf.c or changes into swprintf.c same changes must be done in swprintf.c, other wise the efect of bugfix or change will not be excutected in reactos, for u do not know if program pic the ansi or unicode version. svn path=/trunk/; revision=22083 --- reactos/lib/rtl/sprintf.c | 15 ++++++++++++++- reactos/lib/rtl/swprintf.c | 13 ++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/reactos/lib/rtl/sprintf.c b/reactos/lib/rtl/sprintf.c index 6f1e4411fcb..01740a8a368 100644 --- a/reactos/lib/rtl/sprintf.c +++ b/reactos/lib/rtl/sprintf.c @@ -241,6 +241,8 @@ int _vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args) { int len; unsigned long long num; + double _double; + int base; char *str, *end; const char *s; @@ -258,7 +260,7 @@ int _vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args) str = buf; end = buf + cnt - 1; if (end < buf - 1) { - end = ((void *) -1); + end = ((char *) -1); cnt = end - buf + 1; } @@ -441,6 +443,17 @@ int _vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args) *ip = (str - buf); } continue; + + /* float number formats - set up the flags and "break" */ + case 'e': + case 'E': + case 'f': + case 'g': + case 'G': + _double = (double)va_arg(args, double); + str = number(str, end, (int)_double, base, field_width, precision, flags); + continue; + /* integer number formats - set up the flags and "break" */ case 'o': diff --git a/reactos/lib/rtl/swprintf.c b/reactos/lib/rtl/swprintf.c index 8134d920d48..717ed5a122c 100644 --- a/reactos/lib/rtl/swprintf.c +++ b/reactos/lib/rtl/swprintf.c @@ -245,6 +245,7 @@ int _vsnwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, va_list args) wchar_t * str, * end; const char *s; const wchar_t *sw; + double _double; int flags; /* flags to number() */ @@ -256,7 +257,7 @@ int _vsnwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, va_list args) str = buf; end = buf + cnt - 1; if (end < buf - 1) { - end = ((void *) -1); + end = ((wchar_t *) -1); cnt = end - buf + 1; } @@ -439,6 +440,16 @@ int _vsnwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, va_list args) *ip = (str - buf); } continue; + /* float number formats - set up the flags and "break" */ + case 'e': + case 'E': + case 'f': + case 'g': + case 'G': + _double = (double)va_arg(args, double); + str = number(str, end, (int)_double, base, field_width, precision, flags); + continue; + /* integer number formats - set up the flags and "break" */ case L'o':