[CRT]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Tue, 11 Jan 2011 19:09:48 +0000 (19:09 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Tue, 11 Jan 2011 19:09:48 +0000 (19:09 +0000)
- Add user32_wsprintf library, with all the wsprintf functions, generated from the same codebase
- simplify handling of ll modifier in streamout

svn path=/trunk/; revision=50360

reactos/lib/sdk/crt/crt.rbuild
reactos/lib/sdk/crt/printf/_sxprintf.c
reactos/lib/sdk/crt/printf/streamout.c
reactos/lib/sdk/crt/printf/wsprintfA.c [new file with mode: 0644]
reactos/lib/sdk/crt/printf/wsprintfW.c [new file with mode: 0644]
reactos/lib/sdk/crt/printf/wvsnprintfA.c [new file with mode: 0644]
reactos/lib/sdk/crt/printf/wvsnprintfW.c [new file with mode: 0644]
reactos/lib/sdk/crt/printf/wvsprintfA.c [new file with mode: 0644]
reactos/lib/sdk/crt/printf/wvsprintfW.c [new file with mode: 0644]

index 14e8743..dfa2df6 100644 (file)
                <file>undname.c</file>
        </directory>
 </module>
+
+<module name="user32_wsprintf" type="staticlibrary">
+       <library>chkstk</library>
+       <include base="crt">.</include>
+       <include base="crt">include</include>
+       <define name="_USER32_WSPRINTF" />
+
+       <directory name="printf">
+               <file>streamout.c</file>
+               <file>wstreamout.c</file>
+               <file>wsprintfA.c</file>
+               <file>wsprintfW.c</file>
+               <file>wvsprintfA.c</file>
+               <file>wvsprintfW.c</file>
+               <file>wvsnprintfA.c</file>
+               <file>wvsnprintfW.c</file>
+       </directory>
+       <directory name="string">
+               <file>mbstowcs_nt.c</file>
+               <file>wcstombs_nt.c</file>
+       </directory>
+</module>
+
 </group>
index c212232..0b6c196 100644 (file)
 int _cdecl _tstreamout(FILE *stream, const TCHAR *format, va_list argptr);
 
 int
+#if defined(USER32_WSPRINTF) && defined(_M_IX86)
+_stdcall
+#else
 _cdecl
+#endif
 _sxprintf(
     TCHAR *buffer,
 #if USE_COUNT
index c771443..c300f32 100644 (file)
@@ -77,6 +77,8 @@ enum
 #define get_exp(f) floor(f == 0 ? 0 : (f >= 0 ? log10(f) : log10(-f)))
 #define round(x) floor((x) + 0.5)
 
+#ifndef _USER32_WSPRINTF
+
 void
 #ifdef _LIBCNT
 /* Due to restrictions in kernel mode regarding the use of floating point,
@@ -218,6 +220,7 @@ format_float(
     while ((unsigned __int64)fpval2);
 
 }
+#endif
 
 static
 int
@@ -226,11 +229,15 @@ streamout_char(FILE *stream, int chr)
     /* Check if the buffer is full */
     if (stream->_cnt < sizeof(TCHAR))
     {
+#ifdef _USER32_WSPRINTF
+        return _TEOF;
+#else
         /* Strings are done now */
         if (stream->_flag & _IOSTRG) return _TEOF;
 
         /* Flush buffer for files */
         return _flsbuf(chr, stream) != _TEOF;
+#endif
     }
 
     *(TCHAR*)stream->_ptr = chr;
@@ -298,6 +305,11 @@ streamout_wstring(FILE *stream, const wchar_t *string, int count)
 #define streamout_string streamout_astring
 #endif
 
+#ifdef _USER32_WSPRINTF
+# define USE_MULTISIZE 0
+#else
+# define USE_MULTISIZE 1
+#endif
 
 int
 _cdecl
@@ -391,7 +403,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
         else precision = -1;
 
         /* Handle argument size prefix */
-        while (1)
+        do
         {
                  if (chr == _T('h')) flags |= FLAG_SHORT;
             else if (chr == _T('w')) flags |= FLAG_WIDECHAR;
@@ -399,14 +411,9 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
             else if (chr == _T('F')) flags |= 0; // FIXME: what is that?
             else if (chr == _T('l'))
             {
-                flags |= FLAG_LONG;
-#if SUPPORT_LL
-                if (format[0] == _T('l'))
-                {
-                    format++;
-                    flags |= FLAG_INT64;
-                }
-#endif
+                /* Check if this is the 2nd 'l' in a row */
+                if (format[-2] == 'l') flags |= FLAG_INT64;
+                else flags |= FLAG_LONG;
             }
             else if (chr == _T('I'))
             {
@@ -430,6 +437,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
             else break;
             chr = *format++;
         }
+        while (USE_MULTISIZE);
 
         /* Handle the format specifier */
         digits = digits_l;
@@ -511,6 +519,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
                 precision = 0;
                 break;
 
+#ifndef _USER32_WSPRINTF
             case _T('G'):
             case _T('E'):
             case _T('A'):
@@ -528,6 +537,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
                 len = _tcslen(string);
                 precision = 0;
                 break;
+#endif
 
             case _T('d'):
             case _T('i'):
diff --git a/reactos/lib/sdk/crt/printf/wsprintfA.c b/reactos/lib/sdk/crt/printf/wsprintfA.c
new file mode 100644 (file)
index 0000000..28379ab
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * COPYRIGHT:       GNU GPL, see COPYING in the top level directory
+ * PROJECT:         ReactOS crt library
+ * FILE:            lib/sdk/crt/printf/wsprintfA.c
+ * PURPOSE:         Implementation of wsprintfA
+ * PROGRAMMER:      Timo Kreuzer
+ */
+
+#define _sxprintf wsprintfA
+#define USE_COUNT 0
+#define USER32_WSPRINTF
+
+#include "_sxprintf.c"
diff --git a/reactos/lib/sdk/crt/printf/wsprintfW.c b/reactos/lib/sdk/crt/printf/wsprintfW.c
new file mode 100644 (file)
index 0000000..0c5076c
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * COPYRIGHT:       GNU GPL, see COPYING in the top level directory
+ * PROJECT:         ReactOS crt library
+ * FILE:            lib/sdk/crt/printf/wsprintfW.c
+ * PURPOSE:         Implementation of wsprintfW
+ * PROGRAMMER:      Timo Kreuzer
+ */
+
+#define _sxprintf wsprintfW
+#define USE_COUNT 0
+#define _UNICODE
+#define USER32_WSPRINTF
+
+#include "_sxprintf.c"
diff --git a/reactos/lib/sdk/crt/printf/wvsnprintfA.c b/reactos/lib/sdk/crt/printf/wvsnprintfA.c
new file mode 100644 (file)
index 0000000..b81d19c
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * COPYRIGHT:       GNU GPL, see COPYING in the top level directory
+ * PROJECT:         ReactOS crt library
+ * FILE:            lib/sdk/crt/printf/wvsnprintfA.c
+ * PURPOSE:         Implementation of wvsnprintfA
+ * PROGRAMMER:      Timo Kreuzer
+ */
+
+#define _sxprintf wvsnprintfA
+#define USE_COUNT 1
+#define USE_VARARGS 1
+#define USER32_WSPRINTF
+
+#include "_sxprintf.c"
diff --git a/reactos/lib/sdk/crt/printf/wvsnprintfW.c b/reactos/lib/sdk/crt/printf/wvsnprintfW.c
new file mode 100644 (file)
index 0000000..cd042b1
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * COPYRIGHT:       GNU GPL, see COPYING in the top level directory
+ * PROJECT:         ReactOS crt library
+ * FILE:            lib/sdk/crt/printf/wvsnprintfW.c
+ * PURPOSE:         Implementation of wvsnprintfW
+ * PROGRAMMER:      Timo Kreuzer
+ */
+
+#define _sxprintf wvsnprintfW
+#define USE_COUNT 1
+#define USE_VARARGS 1
+#define USER32_WSPRINTF
+
+#include "_sxprintf.c"
diff --git a/reactos/lib/sdk/crt/printf/wvsprintfA.c b/reactos/lib/sdk/crt/printf/wvsprintfA.c
new file mode 100644 (file)
index 0000000..7be026b
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * COPYRIGHT:       GNU GPL, see COPYING in the top level directory
+ * PROJECT:         ReactOS crt library
+ * FILE:            lib/sdk/crt/printf/wvsprintfA.c
+ * PURPOSE:         Implementation of wvsprintfA
+ * PROGRAMMER:      Timo Kreuzer
+ */
+
+#define _sxprintf wvsprintfA
+#define USE_COUNT 0
+#define USE_VARARGS 1
+#define USER32_WSPRINTF
+
+#include "_sxprintf.c"
diff --git a/reactos/lib/sdk/crt/printf/wvsprintfW.c b/reactos/lib/sdk/crt/printf/wvsprintfW.c
new file mode 100644 (file)
index 0000000..bf9ced2
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * COPYRIGHT:       GNU GPL, see COPYING in the top level directory
+ * PROJECT:         ReactOS crt library
+ * FILE:            lib/sdk/crt/printf/wvsprintfW.c
+ * PURPOSE:         Implementation of wvsprintfW
+ * PROGRAMMER:      Timo Kreuzer
+ */
+
+#define _sxprintf wvsprintfW
+#define USE_COUNT 0
+#define USE_VARARGS 1
+#define USER32_WSPRINTF
+
+#include "_sxprintf.c"