Module: wine Branch: master Commit: 0803575fd310cb16a146f8723aaad5f0131271a9 URL: http://source.winehq.org/git/wine.git/?a=commit;h=0803575fd310cb16a146f8723a...
Author: Hans Leidekker hans@codeweavers.com Date: Thu Mar 26 12:45:59 2009 +0100
msvcrt: Implement _vscprintf and _vscwprintf.
---
dlls/msvcrt/msvcrt.spec | 2 ++ dlls/msvcrt/wcs.c | 32 ++++++++++++++++++++++++-------- include/msvcrt/stdio.h | 2 ++ include/msvcrt/wchar.h | 1 + 4 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 1a9bc12..145b2b0 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -508,6 +508,8 @@ @ cdecl _unloaddll(long) @ cdecl _unlock(long) @ cdecl _utime(str ptr) +@ cdecl _vscprintf(str ptr) +@ cdecl _vscwprintf(wstr ptr) @ cdecl _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf @ cdecl _vsnwprintf(ptr long wstr ptr) MSVCRT_vsnwprintf @ cdecl _waccess(wstr long) diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index 37004cf..09c87dd 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -200,11 +200,11 @@ static inline int pf_output_stringW( pf_output *out, LPCWSTR str, int len )
if( space >= len ) { - memcpy( p, str, len*sizeof(WCHAR) ); + if (out->buf.W) memcpy( p, str, len*sizeof(WCHAR) ); out->used += len; return len; } - if( space > 0 ) + if( space > 0 && out->buf.W ) memcpy( p, str, space*sizeof(WCHAR) ); out->used += len; } @@ -215,11 +215,11 @@ static inline int pf_output_stringW( pf_output *out, LPCWSTR str, int len )
if( space >= n ) { - WideCharToMultiByte( CP_ACP, 0, str, len, p, n, NULL, NULL ); + if (out->buf.A) WideCharToMultiByte( CP_ACP, 0, str, len, p, n, NULL, NULL ); out->used += n; return len; } - if( space > 0 ) + if( space > 0 && out->buf.A ) WideCharToMultiByte( CP_ACP, 0, str, len, p, space, NULL, NULL ); out->used += n; } @@ -238,11 +238,11 @@ static inline int pf_output_stringA( pf_output *out, LPCSTR str, int len )
if( space >= len ) { - memcpy( p, str, len ); + if (out->buf.A) memcpy( p, str, len ); out->used += len; return len; } - if( space > 0 ) + if( space > 0 && out->buf.A ) memcpy( p, str, space ); out->used += len; } @@ -253,11 +253,11 @@ static inline int pf_output_stringA( pf_output *out, LPCSTR str, int len )
if( space >= n ) { - MultiByteToWideChar( CP_ACP, 0, str, len, p, n ); + if (out->buf.W) MultiByteToWideChar( CP_ACP, 0, str, len, p, n ); out->used += n; return len; } - if( space > 0 ) + if( space > 0 && out->buf.W ) MultiByteToWideChar( CP_ACP, 0, str, len, p, space ); out->used += n; } @@ -804,6 +804,14 @@ int CDECL MSVCRT_vsprintf( char *str, const char *format, __ms_va_list valist) }
/********************************************************************* + * _vscprintf (MSVCRT.@) + */ +int CDECL _vscprintf( const char *format, __ms_va_list valist ) +{ + return MSVCRT_vsnprintf( NULL, INT_MAX, format, valist ); +} + +/********************************************************************* * _snprintf (MSVCRT.@) */ int CDECL MSVCRT__snprintf(char *str, unsigned int len, const char *format, ...) @@ -882,6 +890,14 @@ int CDECL MSVCRT_vswprintf( MSVCRT_wchar_t* str, const MSVCRT_wchar_t* format, _ }
/********************************************************************* + * _vscwprintf (MSVCRT.@) + */ +int CDECL _vscwprintf( const MSVCRT_wchar_t *format, __ms_va_list args ) +{ + return MSVCRT_vsnwprintf( NULL, INT_MAX, format, args ); +} + +/********************************************************************* * vswprintf_s (MSVCRT.@) */ int CDECL MSVCRT_vswprintf_s( MSVCRT_wchar_t* str, MSVCRT_size_t num, const MSVCRT_wchar_t* format, __ms_va_list args ) diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h index b65a2b1..f2398b5 100644 --- a/include/msvcrt/stdio.h +++ b/include/msvcrt/stdio.h @@ -115,6 +115,7 @@ int __cdecl _setmaxstdio(int); int __cdecl _snprintf(char*,size_t,const char*,...); char* __cdecl _tempnam(const char*,const char*); int __cdecl _unlink(const char*); +int __cdecl _vscprintf(const char*,__ms_va_list); int __cdecl _vsnprintf(char*,size_t,const char*,__ms_va_list);
void __cdecl clearerr(FILE*); @@ -166,6 +167,7 @@ wint_t __cdecl _fputwchar(wint_t); wchar_t* __cdecl _getws(wchar_t*); int __cdecl _putws(const wchar_t*); int __cdecl _snwprintf(wchar_t*,size_t,const wchar_t*,...); +int __cdecl _vscwprintf(const wchar_t*,__ms_va_list); int __cdecl _vsnwprintf(wchar_t*,size_t,const wchar_t*,__ms_va_list); FILE* __cdecl _wfdopen(int,const wchar_t*); FILE* __cdecl _wfopen(const wchar_t*,const wchar_t*); diff --git a/include/msvcrt/wchar.h b/include/msvcrt/wchar.h index 77bcc10..03d6107 100644 --- a/include/msvcrt/wchar.h +++ b/include/msvcrt/wchar.h @@ -275,6 +275,7 @@ wint_t __cdecl _fputwchar(wint_t); wchar_t* __cdecl _getws(wchar_t*); int __cdecl _putws(const wchar_t*); int __cdecl _snwprintf(wchar_t*,size_t,const wchar_t*,...); +int __cdecl _vscwprintf(const wchar_t*,__ms_va_list); int __cdecl _vsnwprintf(wchar_t*,size_t,const wchar_t*,__ms_va_list); FILE* __cdecl _wfdopen(int,const wchar_t*); FILE* __cdecl _wfopen(const wchar_t*,const wchar_t*);