msvcrt: Implemented _vc(w)printf.

This commit is contained in:
Eric Pouech 2010-11-07 19:11:38 +01:00 committed by Alexandre Julliard
parent 7d384d23f8
commit 1eaae093e2
7 changed files with 91 additions and 36 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -22,6 +22,7 @@
*/
#include "msvcrt.h"
#include "winnls.h"
#include "wincon.h"
#include "mtdll.h"
#include "wine/debug.h"
@ -298,36 +299,90 @@ 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
*/
while ((written = MSVCRT_vsnprintf( mem, resize, format, valist )) == -1 ||
written > resize)
{
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 );
}
retval = _vcprintf(format, valist);
__ms_va_end(valist);
LOCK_CONSOLE;
retval = _cputs( mem );
UNLOCK_CONSOLE;
if (mem != buf)
MSVCRT_free (mem);
return retval;
}
/*********************************************************************
* _vcwprintf (MSVCRT.@)
*/
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)
{
LOCK_CONSOLE;
retval = _cputws( out.buf.W );
UNLOCK_CONSOLE;
}
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;
}

View file

@ -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