Commit 1eaae093 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

msvcrt: Implemented _vc(w)printf.

parent 7d384d23
......@@ -564,7 +564,7 @@
@ cdecl _ctime64(ptr) msvcrt._ctime64
@ stub _ctime64_s
@ cdecl _cwait(ptr long long) msvcrt._cwait
@ stub _cwprintf
@ varargs _cwprintf(wstr) msvcrt._cwprintf
@ stub _cwprintf_l
@ stub _cwprintf_p
@ stub _cwprintf_p_l
......@@ -1216,13 +1216,13 @@
@ cdecl _unlock_file(ptr) msvcrt._unlock_file
@ cdecl _utime32(str ptr) msvcrt._utime32
@ cdecl _utime64(str ptr) msvcrt._utime64
@ stub _vcprintf
@ cdecl _vcprintf(str ptr) msvcrt._vcprintf
@ stub _vcprintf_l
@ stub _vcprintf_p
@ stub _vcprintf_p_l
@ stub _vcprintf_s
@ stub _vcprintf_s_l
@ stub _vcwprintf
@ cdecl _vcwprintf(wstr ptr) msvcrt._vcwprintf
@ stub _vcwprintf_l
@ stub _vcwprintf_p
@ stub _vcwprintf_p_l
......
......@@ -267,7 +267,7 @@
@ cdecl _ctime64(ptr) msvcrt._ctime64
@ extern _ctype msvcrt._ctype
@ cdecl _cwait(ptr long long) msvcrt._cwait
@ stub _cwprintf
@ varargs _cwprintf(str) msvcrt._cwprintf
@ varargs _cwscanf(wstr) msvcrt._cwscanf
@ extern _daylight msvcrt._daylight
@ extern _dstbias msvcrt._dstbias
......
......@@ -261,7 +261,7 @@
@ varargs _cscanf(str) msvcrt._cscanf
@ cdecl _ctime64(ptr) msvcrt._ctime64
@ cdecl _cwait(ptr long long) msvcrt._cwait
@ stub _cwprintf
@ varargs _cwprintf(wstr) msvcrt._cwprintf
@ varargs _cwscanf(wstr) msvcrt._cwscanf
@ extern _daylight msvcrt._daylight
@ extern _dstbias msvcrt._dstbias
......
......@@ -403,7 +403,7 @@
@ cdecl _ctime64(ptr) msvcrt._ctime64
@ stub _ctime64_s
@ cdecl _cwait(ptr long long) msvcrt._cwait
@ stub _cwprintf
@ varargs _cwprintf(wstr) msvcrt._cwprintf
@ stub _cwprintf_l
@ stub _cwprintf_p
@ stub _cwprintf_p_l
......@@ -1069,13 +1069,13 @@
@ cdecl _unlock_file(ptr) msvcrt._unlock_file
@ cdecl _utime32(str ptr) msvcrt._utime32
@ cdecl _utime64(str ptr) msvcrt._utime64
@ stub _vcprintf
@ cdecl _vcprintf(str ptr) msvcrt._vcprintf
@ stub _vcprintf_l
@ stub _vcprintf_p
@ stub _vcprintf_p_l
@ stub _vcprintf_s
@ stub _vcprintf_s_l
@ stub _vcwprintf
@ cdecl _vcwprintf(wstr ptr) msvcrt._vcwprintf
@ stub _vcwprintf_l
@ stub _vcwprintf_p
@ stub _vcwprintf_p_l
......
......@@ -395,7 +395,7 @@
@ cdecl _ctime64(ptr) msvcrt._ctime64
@ stub _ctime64_s
@ cdecl _cwait(ptr long long) msvcrt._cwait
@ stub _cwprintf
@ varargs _cwprintf(wstr) msvcrt._cwprintf
@ stub _cwprintf_l
@ stub _cwprintf_p
@ stub _cwprintf_p_l
......@@ -1056,13 +1056,13 @@
@ cdecl _unlock_file(ptr) msvcrt._unlock_file
@ cdecl _utime32(str ptr) msvcrt._utime32
@ cdecl _utime64(str ptr) msvcrt._utime64
@ stub _vcprintf
@ cdecl _vcprintf(str ptr) msvcrt._vcprintf
@ stub _vcprintf_l
@ stub _vcprintf_p
@ stub _vcprintf_p_l
@ stub _vcprintf_s
@ stub _vcprintf_s_l
@ stub _vcwprintf
@ cdecl _vcwprintf(wstr ptr) msvcrt._vcwprintf
@ stub _vcwprintf_l
@ stub _vcwprintf_p
@ stub _vcwprintf_p_l
......
......@@ -22,6 +22,7 @@
*/
#include "msvcrt.h"
#include "winnls.h"
#include "wincon.h"
#include "mtdll.h"
#include "wine/debug.h"
......@@ -299,35 +300,89 @@ int CDECL _kbhit(void)
/*********************************************************************
* _vcprintf (MSVCRT.@)
*/
int CDECL _vcprintf(const char* format, __ms_va_list valist)
{
char buf[2048];
LPWSTR formatW = NULL;
DWORD sz;
pf_output out;
int retval;
out.unicode = FALSE;
out.buf.A = out.grow.A = buf;
out.used = 0;
out.len = sizeof(buf);
sz = MultiByteToWideChar( CP_ACP, 0, format, -1, NULL, 0 );
formatW = HeapAlloc( GetProcessHeap(), 0, sz*sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, format, -1, formatW, sz );
if ((retval = pf_vsnprintf( &out, formatW, NULL, FALSE, valist )) > 0)
{
LOCK_CONSOLE;
retval = _cputs( out.buf.A );
UNLOCK_CONSOLE;
}
HeapFree( GetProcessHeap(), 0, formatW );
if (out.buf.A != buf)
MSVCRT_free (out.buf.A);
return retval;
}
/*********************************************************************
* _cprintf (MSVCRT.@)
*/
int CDECL _cprintf(const char* format, ...)
{
char buf[2048], *mem = buf;
int written, resize = sizeof(buf), retval;
int retval;
__ms_va_list valist;
__ms_va_start( valist, format );
/* There are two conventions for snprintf failing:
* Return -1 if we truncated, or
* Return the number of bytes that would have been written
* The code below handles both cases
retval = _vcprintf(format, valist);
__ms_va_end(valist);
return retval;
}
/*********************************************************************
* _vcwprintf (MSVCRT.@)
*/
while ((written = MSVCRT_vsnprintf( mem, resize, format, valist )) == -1 ||
written > resize)
int CDECL _vcwprintf(const MSVCRT_wchar_t* format, __ms_va_list valist)
{
MSVCRT_wchar_t buf[2048];
pf_output out;
int retval;
out.unicode = TRUE;
out.buf.W = out.grow.W = buf;
out.used = 0;
out.len = sizeof(buf) / sizeof(buf[0]);
if ((retval = pf_vsnprintf( &out, format, NULL, FALSE, valist )) >= 0)
{
resize = (written == -1 ? resize * 2 : written + 1);
if (mem != buf)
MSVCRT_free (mem);
if (!(mem = MSVCRT_malloc(resize)))
return MSVCRT_EOF;
__ms_va_start( valist, format );
}
__ms_va_end(valist);
LOCK_CONSOLE;
retval = _cputs( mem );
retval = _cputws( out.buf.W );
UNLOCK_CONSOLE;
if (mem != buf)
MSVCRT_free (mem);
}
if (out.buf.W != buf)
MSVCRT_free (out.buf.W);
return retval;
}
/*********************************************************************
* _cwprintf (MSVCRT.@)
*/
int CDECL _cwprintf(const MSVCRT_wchar_t* format, ...)
{
int retval;
__ms_va_list valist;
__ms_va_start( valist, format );
retval = _vcwprintf(format, valist);
__ms_va_end(valist);
return retval;
}
......@@ -361,7 +361,7 @@
# stub _ctime64_s
@ extern _ctype MSVCRT__ctype
@ cdecl _cwait(ptr long long)
# stub _cwprintf
@ varargs _cwprintf(wstr)
# stub _cwprintf_l
# stub _cwprintf_p
# stub _cwprintf_p_l
......@@ -992,13 +992,13 @@
@ cdecl _unlock_file(ptr) MSVCRT__unlock_file
@ cdecl _utime32(str ptr)
@ cdecl _utime64(str ptr)
# stub _vcprintf
@ cdecl _vcprintf(str ptr)
# stub _vcprintf_l
# stub _vcprintf_p
# stub _vcprintf_p_l
# stub _vcprintf_s
# stub _vcprintf_s_l
# stub _vcwprintf
@ cdecl _vcwprintf(wstr ptr)
# stub _vcwprintf_l
# stub _vcwprintf_p
# stub _vcwprintf_p_l
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment