Commit 85fa2ee5 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Added _vsnprintf* implementation.

parent 09a32152
...@@ -1048,11 +1048,11 @@ ...@@ -1048,11 +1048,11 @@
@ stub _vscwprintf_p @ stub _vscwprintf_p
@ stub _vscwprintf_p_l @ stub _vscwprintf_p_l
@ cdecl _vsnprintf(ptr long str ptr) msvcrt._vsnprintf @ cdecl _vsnprintf(ptr long str ptr) msvcrt._vsnprintf
@ stub _vsnprintf_c @ cdecl _vsnprintf_c(ptr long str ptr) msvcrt._vsnprintf
@ stub _vsnprintf_c_l @ cdecl _vsnprintf_c_l(ptr long str ptr ptr) msvcrt._vsnprintf_l
@ stub _vsnprintf_l @ cdecl _vsnprintf_l(ptr long str ptr ptr) msvcrt._vsnprintf_l
@ stub _vsnprintf_s @ cdecl _vsnprintf_s(ptr long long str ptr) msvcrt._vsnprintf_s
@ stub _vsnprintf_s_l @ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) msvcrt._vsnprintf_s_l
@ cdecl _vsnwprintf(ptr long wstr ptr) msvcrt._vsnwprintf @ cdecl _vsnwprintf(ptr long wstr ptr) msvcrt._vsnwprintf
@ stub _vsnwprintf_l @ stub _vsnwprintf_l
@ stub _vsnwprintf_s @ stub _vsnwprintf_s
......
...@@ -1035,11 +1035,11 @@ ...@@ -1035,11 +1035,11 @@
@ stub _vscwprintf_p @ stub _vscwprintf_p
@ stub _vscwprintf_p_l @ stub _vscwprintf_p_l
@ cdecl _vsnprintf(ptr long str ptr) msvcrt._vsnprintf @ cdecl _vsnprintf(ptr long str ptr) msvcrt._vsnprintf
@ stub _vsnprintf_c @ cdecl _vsnprintf_c(ptr long str ptr) msvcrt._vsnprintf
@ stub _vsnprintf_c_l @ cdecl _vsnprintf_c_l(ptr long str ptr ptr) msvcrt._vsnprintf_l
@ stub _vsnprintf_l @ cdecl _vsnprintf_l(ptr long str ptr ptr) msvcrt._vsnprintf_l
@ stub _vsnprintf_s @ cdecl _vsnprintf_s(ptr long long str ptr) msvcrt._vsnprintf_s
@ stub _vsnprintf_s_l @ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) msvcrt._vsnprintf_s_l
@ cdecl _vsnwprintf(ptr long wstr ptr) msvcrt._vsnwprintf @ cdecl _vsnwprintf(ptr long wstr ptr) msvcrt._vsnwprintf
@ stub _vsnwprintf_l @ stub _vsnwprintf_l
@ stub _vsnwprintf_s @ stub _vsnwprintf_s
......
...@@ -707,6 +707,8 @@ typedef void (__cdecl *MSVCRT___sighandler_t)(int); ...@@ -707,6 +707,8 @@ typedef void (__cdecl *MSVCRT___sighandler_t)(int);
#define _MB_CP_ANSI -3 #define _MB_CP_ANSI -3
#define _MB_CP_LOCALE -4 #define _MB_CP_LOCALE -4
#define _TRUNCATE ((MSVCRT_size_t)-1)
void __cdecl MSVCRT_free(void*); void __cdecl MSVCRT_free(void*);
void* __cdecl MSVCRT_malloc(MSVCRT_size_t); void* __cdecl MSVCRT_malloc(MSVCRT_size_t);
void* __cdecl MSVCRT_calloc(MSVCRT_size_t,MSVCRT_size_t); void* __cdecl MSVCRT_calloc(MSVCRT_size_t,MSVCRT_size_t);
...@@ -735,7 +737,7 @@ MSVCRT___time32_t __cdecl MSVCRT__time32(MSVCRT___time32_t*); ...@@ -735,7 +737,7 @@ MSVCRT___time32_t __cdecl MSVCRT__time32(MSVCRT___time32_t*);
MSVCRT___time64_t __cdecl MSVCRT__time64(MSVCRT___time64_t*); MSVCRT___time64_t __cdecl MSVCRT__time64(MSVCRT___time64_t*);
MSVCRT_FILE* __cdecl MSVCRT__fdopen(int, const char *); MSVCRT_FILE* __cdecl MSVCRT__fdopen(int, const char *);
MSVCRT_FILE* __cdecl MSVCRT__wfdopen(int, const MSVCRT_wchar_t *); MSVCRT_FILE* __cdecl MSVCRT__wfdopen(int, const MSVCRT_wchar_t *);
int __cdecl MSVCRT_vsnprintf(char *str, unsigned int len, const char *format, __ms_va_list valist); int __cdecl MSVCRT_vsnprintf(char *str, MSVCRT_size_t len, const char *format, __ms_va_list valist);
int __cdecl MSVCRT_vsnwprintf(MSVCRT_wchar_t *str, unsigned int len, int __cdecl MSVCRT_vsnwprintf(MSVCRT_wchar_t *str, unsigned int len,
const MSVCRT_wchar_t *format, __ms_va_list valist ); const MSVCRT_wchar_t *format, __ms_va_list valist );
int __cdecl MSVCRT_raise(int sig); int __cdecl MSVCRT_raise(int sig);
......
...@@ -977,11 +977,11 @@ ...@@ -977,11 +977,11 @@
# stub _vscwprintf_l # stub _vscwprintf_l
# stub _vscwprintf_p_l # stub _vscwprintf_p_l
@ cdecl _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf @ cdecl _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf
# stub _vsnprintf_c @ cdecl _vsnprintf_c(ptr long str ptr) MSVCRT_vsnprintf
# stub _vsnprintf_c_l @ cdecl _vsnprintf_c_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l
# stub _vsnprintf_l @ cdecl _vsnprintf_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l
# stub _vsnprintf_s @ cdecl _vsnprintf_s(ptr long long str ptr) MSVCRT_vsnprintf_s
# stub _vsnprintf_s_l @ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) MSVCRT_vsnprintf_s_l
@ cdecl _vsnwprintf(ptr long wstr ptr) MSVCRT_vsnwprintf @ cdecl _vsnwprintf(ptr long wstr ptr) MSVCRT_vsnwprintf
# stub _vsnwprintf_l # stub _vsnwprintf_l
# stub _vsnwprintf_s # stub _vsnwprintf_s
......
...@@ -814,10 +814,10 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, ...@@ -814,10 +814,10 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format,
} }
/********************************************************************* /*********************************************************************
* _vsnprintf (MSVCRT.@) * vsnprintf_internal (INTERNAL)
*/ */
int CDECL MSVCRT_vsnprintf( char *str, unsigned int len, static inline int vsnprintf_internal( char *str, MSVCRT_size_t len, const char *format,
const char *format, __ms_va_list valist ) MSVCRT__locale_t locale, BOOL valid, __ms_va_list valist )
{ {
DWORD sz; DWORD sz;
LPWSTR formatW = NULL; LPWSTR formatW = NULL;
...@@ -833,7 +833,7 @@ int CDECL MSVCRT_vsnprintf( char *str, unsigned int len, ...@@ -833,7 +833,7 @@ int CDECL MSVCRT_vsnprintf( char *str, unsigned int len,
formatW = HeapAlloc( GetProcessHeap(), 0, sz*sizeof(WCHAR) ); formatW = HeapAlloc( GetProcessHeap(), 0, sz*sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, format, -1, formatW, sz ); MultiByteToWideChar( CP_ACP, 0, format, -1, formatW, sz );
r = pf_vsnprintf( &out, formatW, NULL, FALSE, valist ); r = pf_vsnprintf( &out, formatW, locale, valid, valist );
HeapFree( GetProcessHeap(), 0, formatW ); HeapFree( GetProcessHeap(), 0, formatW );
...@@ -841,6 +841,63 @@ int CDECL MSVCRT_vsnprintf( char *str, unsigned int len, ...@@ -841,6 +841,63 @@ int CDECL MSVCRT_vsnprintf( char *str, unsigned int len,
} }
/********************************************************************* /*********************************************************************
* _vsnprintf (MSVCRT.@)
*/
int CDECL MSVCRT_vsnprintf( char *str, MSVCRT_size_t len,
const char *format, __ms_va_list valist )
{
return vsnprintf_internal(str, len, format, NULL, FALSE, valist);
}
/*********************************************************************
* _vsnprintf_l (MSVCRT.@)
*/
int CDECL MSVCRT_vsnprintf_l( char *str, MSVCRT_size_t len, const char *format,
MSVCRT__locale_t locale, __ms_va_list valist )
{
return vsnprintf_internal(str, len, format, locale, FALSE, valist);
}
/*********************************************************************
* _vsnprintf_s_l (MSVCRT.@)
*/
int CDECL MSVCRT_vsnprintf_s_l( char *str, MSVCRT_size_t sizeOfBuffer,
MSVCRT_size_t count, const char *format,
MSVCRT__locale_t locale, __ms_va_list valist )
{
int len, ret;
if(sizeOfBuffer<count+1 || count==-1)
len = sizeOfBuffer;
else
len = count+1;
ret = vsnprintf_internal(str, len, format, locale, TRUE, valist);
if(ret<0 || ret==len) {
if(count!=_TRUNCATE && count>sizeOfBuffer) {
MSVCRT__invalid_parameter( NULL, NULL, NULL, 0, 0 );
*MSVCRT__errno() = MSVCRT_ERANGE;
memset(str, 0, sizeOfBuffer);
} else
str[len-1] = '\0';
return -1;
}
return ret;
}
/*********************************************************************
* _vsnprintf_s (MSVCRT.@)
*/
int CDECL MSVCRT_vsnprintf_s( char *str, MSVCRT_size_t sizeOfBuffer,
MSVCRT_size_t count, const char *format, __ms_va_list valist )
{
return MSVCRT_vsnprintf_s_l(str,sizeOfBuffer, count, format, NULL, valist);
}
/*********************************************************************
* vsprintf (MSVCRT.@) * vsprintf (MSVCRT.@)
*/ */
int CDECL MSVCRT_vsprintf( char *str, const char *format, __ms_va_list valist) int CDECL MSVCRT_vsprintf( char *str, const char *format, __ms_va_list valist)
......
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