mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[SDK][CRT] Add _CRT_NON_CONFORMING_SWPRINTFS support
This allows us to easier port wine changes, where swprintf with a size is used a lot
This commit is contained in:
parent
958f1addcf
commit
f1132155d9
5 changed files with 76 additions and 20 deletions
|
@ -68,7 +68,11 @@ include(sdk/cmake/config.cmake)
|
||||||
# Compiler flags handling
|
# Compiler flags handling
|
||||||
include(sdk/cmake/compilerflags.cmake)
|
include(sdk/cmake/compilerflags.cmake)
|
||||||
|
|
||||||
add_definitions(-D__REACTOS__)
|
add_definitions(
|
||||||
|
-D__REACTOS__
|
||||||
|
# swprintf without count argument is used in most of the codebase
|
||||||
|
-D_CRT_NON_CONFORMING_SWPRINTFS
|
||||||
|
)
|
||||||
|
|
||||||
# There doesn't seem to be a standard for __FILE__ being relative or absolute, so detect it at runtime.
|
# There doesn't seem to be a standard for __FILE__ being relative or absolute, so detect it at runtime.
|
||||||
file(RELATIVE_PATH _PATH_PREFIX ${REACTOS_BINARY_DIR} ${REACTOS_SOURCE_DIR})
|
file(RELATIVE_PATH _PATH_PREFIX ${REACTOS_BINARY_DIR} ${REACTOS_SOURCE_DIR})
|
||||||
|
|
|
@ -9,13 +9,13 @@ list(APPEND SOURCE
|
||||||
heap.c
|
heap.c
|
||||||
locale.c
|
locale.c
|
||||||
misc.c
|
misc.c
|
||||||
printf.c
|
|
||||||
scanf.c
|
scanf.c
|
||||||
signal.c
|
signal.c
|
||||||
string.c
|
string.c
|
||||||
time.c)
|
time.c)
|
||||||
|
|
||||||
list(APPEND PCH_SKIP_SOURCE
|
list(APPEND PCH_SKIP_SOURCE
|
||||||
|
printf.c # _CRT_NON_CONFORMING_SWPRINTFS
|
||||||
testlist.c)
|
testlist.c)
|
||||||
|
|
||||||
add_executable(msvcrt_winetest
|
add_executable(msvcrt_winetest
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
/* With Visual Studio >= 2005, swprintf() takes an extra parameter unless
|
/* With Visual Studio >= 2005, swprintf() takes an extra parameter unless
|
||||||
* the following macro is defined.
|
* the following macro is defined.
|
||||||
*/
|
*/
|
||||||
|
#ifndef _CRT_NON_CONFORMING_SWPRINTFS
|
||||||
#define _CRT_NON_CONFORMING_SWPRINTFS
|
#define _CRT_NON_CONFORMING_SWPRINTFS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
|
@ -885,6 +885,7 @@ extern _CRTIMP int _commode;
|
||||||
_In_z_ _Printf_format_string_ const wchar_t *_Format,
|
_In_z_ _Printf_format_string_ const wchar_t *_Format,
|
||||||
va_list _ArgList);
|
va_list _ArgList);
|
||||||
|
|
||||||
|
#if defined __cplusplus || defined _CRT_NON_CONFORMING_SWPRINTFS
|
||||||
_Check_return_opt_
|
_Check_return_opt_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
int
|
int
|
||||||
|
@ -901,6 +902,7 @@ extern _CRTIMP int _commode;
|
||||||
_Out_ wchar_t*,
|
_Out_ wchar_t*,
|
||||||
const wchar_t*,
|
const wchar_t*,
|
||||||
va_list);
|
va_list);
|
||||||
|
#endif
|
||||||
|
|
||||||
_Check_return_opt_
|
_Check_return_opt_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
|
@ -948,15 +950,38 @@ extern _CRTIMP int _commode;
|
||||||
#include <vadefs.h>
|
#include <vadefs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0 //this is for MSVCRT80 and higher, which we don't use nor implement
|
#ifndef _CRT_NON_CONFORMING_SWPRINTFS
|
||||||
#ifdef _CRT_NON_CONFORMING_SWPRINTFS
|
_Check_return_opt_
|
||||||
#ifndef __cplusplus
|
static inline
|
||||||
#define swprintf _swprintf
|
int
|
||||||
#define vswprintf _vswprintf
|
__cdecl
|
||||||
#define _swprintf_l __swprintf_l
|
swprintf(
|
||||||
#define _vswprintf_l __vswprintf_l
|
_Out_writes_z_(_SizeInWords) wchar_t* _DstBuf,
|
||||||
#endif
|
_In_ size_t _SizeInWords,
|
||||||
#endif
|
_In_z_ _Printf_format_string_ const wchar_t* _Format,
|
||||||
|
...)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, _Format);
|
||||||
|
ret = _vsnwprintf(_DstBuf, _SizeInWords, _Format, args);
|
||||||
|
va_end(args);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Check_return_opt_
|
||||||
|
static inline
|
||||||
|
int
|
||||||
|
__cdecl
|
||||||
|
vswprintf(
|
||||||
|
_Out_writes_z_(_SizeInWords) wchar_t* _DstBuf,
|
||||||
|
_In_ size_t _SizeInWords,
|
||||||
|
_In_z_ _Printf_format_string_ const wchar_t* _Format,
|
||||||
|
va_list _ArgList)
|
||||||
|
{
|
||||||
|
return _vsnwprintf(_DstBuf, _SizeInWords, _Format, _ArgList);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_Check_return_
|
_Check_return_
|
||||||
|
|
|
@ -1072,6 +1072,7 @@ _CRTIMP int __cdecl iswblank(wint_t _C);
|
||||||
_In_z_ _Printf_format_string_ const wchar_t *_Format,
|
_In_z_ _Printf_format_string_ const wchar_t *_Format,
|
||||||
va_list _ArgList);
|
va_list _ArgList);
|
||||||
|
|
||||||
|
#if defined __cplusplus || defined _CRT_NON_CONFORMING_SWPRINTFS
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
int
|
int
|
||||||
__cdecl
|
__cdecl
|
||||||
|
@ -1087,6 +1088,7 @@ _CRTIMP int __cdecl iswblank(wint_t _C);
|
||||||
_Out_ wchar_t*,
|
_Out_ wchar_t*,
|
||||||
const wchar_t*,
|
const wchar_t*,
|
||||||
va_list);
|
va_list);
|
||||||
|
#endif
|
||||||
|
|
||||||
_Check_return_opt_
|
_Check_return_opt_
|
||||||
_CRTIMP
|
_CRTIMP
|
||||||
|
@ -1378,15 +1380,38 @@ _CRTIMP int __cdecl iswblank(wint_t _C);
|
||||||
_CRTIMP int __cdecl __swprintf_l(wchar_t *_Dest,const wchar_t *_Format,_locale_t _Plocinfo,...);
|
_CRTIMP int __cdecl __swprintf_l(wchar_t *_Dest,const wchar_t *_Format,_locale_t _Plocinfo,...);
|
||||||
_CRTIMP int __cdecl __vswprintf_l(wchar_t *_Dest,const wchar_t *_Format,_locale_t _Plocinfo,va_list _Args);
|
_CRTIMP int __cdecl __vswprintf_l(wchar_t *_Dest,const wchar_t *_Format,_locale_t _Plocinfo,va_list _Args);
|
||||||
|
|
||||||
#if 0 //this is for MSVCRT80 and higher, which we don't use nor implement
|
#ifndef _CRT_NON_CONFORMING_SWPRINTFS
|
||||||
#ifdef _CRT_NON_CONFORMING_SWPRINTFS
|
_Check_return_opt_
|
||||||
#ifndef __cplusplus
|
static inline
|
||||||
#define swprintf _swprintf
|
int
|
||||||
#define vswprintf _vswprintf
|
__cdecl
|
||||||
#define _swprintf_l __swprintf_l
|
swprintf(
|
||||||
#define _vswprintf_l __vswprintf_l
|
_Out_writes_z_(_SizeInWords) wchar_t* _DstBuf,
|
||||||
#endif
|
_In_ size_t _SizeInWords,
|
||||||
#endif
|
_In_z_ _Printf_format_string_ const wchar_t* _Format,
|
||||||
|
...)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, _Format);
|
||||||
|
ret = _vsnwprintf(_DstBuf, _SizeInWords, _Format, args);
|
||||||
|
va_end(args);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Check_return_opt_
|
||||||
|
static inline
|
||||||
|
int
|
||||||
|
__cdecl
|
||||||
|
vswprintf(
|
||||||
|
_Out_writes_z_(_SizeInWords) wchar_t* _DstBuf,
|
||||||
|
_In_ size_t _SizeInWords,
|
||||||
|
_In_z_ _Printf_format_string_ const wchar_t* _Format,
|
||||||
|
va_list _ArgList)
|
||||||
|
{
|
||||||
|
return _vsnwprintf(_DstBuf, _SizeInWords, _Format, _ArgList);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_Check_return_
|
_Check_return_
|
||||||
|
|
Loading…
Reference in a new issue