Jacek Caban : stdio.h: Add ucrt version of vsnprintf inline wrapper.
Alexandre Julliard
julliard at winehq.org
Tue Feb 18 16:13:47 CST 2020
Module: wine
Branch: master
Commit: c60b21926ef2966835483d7f06202e33569c091f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c60b21926ef2966835483d7f06202e33569c091f
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Feb 18 15:21:29 2020 +0100
stdio.h: Add ucrt version of vsnprintf inline wrapper.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/vcruntime140/misc.c | 10 ----------
include/msvcrt/stdio.h | 27 +++++++++++++++++++++++++--
2 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/dlls/vcruntime140/misc.c b/dlls/vcruntime140/misc.c
index 028bde5b3d..cc64175438 100644
--- a/dlls/vcruntime140/misc.c
+++ b/dlls/vcruntime140/misc.c
@@ -22,10 +22,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(vcruntime);
-#define UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR (0x0002)
-int __cdecl __stdio_common_vsprintf(unsigned __int64 options, char *str, size_t len, const char *format,
- _locale_t locale, __ms_va_list valist);
-
int* CDECL __processing_throw(void);
/*********************************************************************
@@ -58,9 +54,3 @@ int __cdecl __uncaught_exceptions(void)
{
return *__processing_throw();
}
-
-int __cdecl _vsnprintf( char *buf, size_t size, const char *fmt, __ms_va_list args )
-{
- return __stdio_common_vsprintf( UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR,
- buf, size, fmt, NULL, args );
-}
diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h
index 2a66f008fa..7477ac171a 100644
--- a/include/msvcrt/stdio.h
+++ b/include/msvcrt/stdio.h
@@ -95,7 +95,6 @@ char* __cdecl _tempnam(const char*,const char*);
int __cdecl _unlink(const char*);
int WINAPIV _scprintf(const char*,...);
int __cdecl _vscprintf(const char*,__ms_va_list);
-int __cdecl _vsnprintf(char*,size_t,const char*,__ms_va_list);
int __cdecl _vsnprintf_s(char*,size_t,size_t,const char*,__ms_va_list);
int __cdecl _vsprintf_p_l(char*,size_t,const char*,_locale_t,__ms_va_list);
@@ -173,6 +172,31 @@ int __cdecl vsprintf_s(char*,size_t,const char*,__ms_va_list);
unsigned int __cdecl _get_output_format(void);
unsigned int __cdecl _set_output_format(void);
+#ifdef _UCRT
+
+_ACRTIMP int __cdecl __stdio_common_vsprintf(unsigned __int64,char*,size_t,const char*,_locale_t,__ms_va_list);
+
+static inline int __cdecl vsnprintf(char *buffer, size_t size, const char *format, __ms_va_list args)
+{
+ int ret = __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR,
+ buffer, size, format, NULL, args);
+ return ret < 0 ? -1 : ret;
+}
+
+static inline int __cdecl _vsnprintf(char *buffer, size_t size, const char *format, __ms_va_list args)
+{
+ int ret = __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION,
+ buffer, size, format, NULL, args);
+ return ret < 0 ? -1 : ret;
+}
+
+#else /* _UCRT */
+
+int __cdecl _vsnprintf(char*,size_t,const char*,__ms_va_list);
+static inline int vsnprintf(char *buffer, size_t size, const char *format, __ms_va_list args) { return _vsnprintf(buffer,size,format,args); }
+
+#endif /* _UCRT */
+
#endif /* _STDIO_DEFINED */
#ifdef __cplusplus
@@ -191,7 +215,6 @@ static inline char* tempnam(const char *dir, const char *prefix) { return _tempn
static inline int unlink(const char* path) { return _unlink(path); }
#define _UNLINK_DEFINED
#endif
-static inline int vsnprintf(char *buffer, size_t size, const char *format, __ms_va_list args) { return _vsnprintf(buffer,size,format,args); }
static inline int WINAPIV snprintf(char *buffer, size_t size, const char *format, ...)
{
More information about the wine-cvs
mailing list