On Sun, 7 Aug 2022 10:39:01 +0900 Takashi Yano wrote: > Thansk for the comment. I attached v4 patch which fixed the > problems you mentioned. > v4-0001-crt-headers-Add-workaround-for-multibyte-string-o.patch > What changed are: > 1) Remove #ifdef _UCRT block in misc/mingw_msvcrt_mbfix.c. > 2) Use new function __isatty_on_non_ucrt(), which is alias of > _isatty() in libmsvcr*.a and is always FALSE in UCRT, instead > of GetModuleHandle("ucrtbase.dll"). > 3) Introduce mutex lock()/unlock() to avoid race issue.
I noticed two problems in v4 patch. 1) msvcr110.dll and msvcr120.dll also fail with Case 4 of the test case in my previous post. 2) The patch is not compatible with msvcrt10.dll, msvcrt20.dll, msvcrt40.dll, msvcr70.dll, msvcr71.dll and msvcr80.dll. These issues are fixed in v5 patch attached. -- Takashi Yano <takashi.y...@nifty.ne.jp>
From 2da2468493eea7a99b538a261b5140c558554986 Mon Sep 17 00:00:00 2001 From: Takashi Yano <takashi.y...@nifty.ne.jp> Date: Mon, 18 Jul 2022 21:55:37 +0900 Subject: [PATCH v5] crt,headers: Add workaround for multibyte string output issue. This patch adds the workaround for multibyte char output issue in msvcrt.dll. If printf("%ls\n", L"<multibyte string>") is called after setlocale(LC_CTYPE, ""), the multibyte string is not printed out correctly. Similarly, fwrite() to stdout fails to print multibyte string. Not only printf and fwrite, many of stdio functions have similar problem. This only occurs when the stdout is a console and setlocale() is called. Redirecting the output to pipe or file is not affected. This seems due to the problem of msvcrt.dll. To avoid this problem, byte-set of multibyte char is outputted in one action at once using the wrapper functions. --- mingw-w64-crt/Makefile.am | 6 +- mingw-w64-crt/crt/ucrtbase_compat.c | 110 ++++- .../def-include/msvcrt-common.def.in | 2 + mingw-w64-crt/def-include/msvcrt-mbfix.def.in | 33 ++ ...def => api-ms-win-crt-stdio-l1-1-0.def.in} | 3 + mingw-w64-crt/lib-common/ucrtbase.def.in | 1 + .../lib32/{msvcr70.def => msvcr70.def.in} | 5 + .../lib32/{msvcr71.def => msvcr71.def.in} | 5 + mingw-w64-crt/lib32/msvcr80.def.in | 1 + .../lib32/{msvcrt10.def => msvcrt10.def.in} | 5 + .../lib32/{msvcrt20.def => msvcrt20.def.in} | 5 + .../lib32/{msvcrt40.def => msvcrt40.def.in} | 5 + mingw-w64-crt/lib64/msvcr80.def.in | 1 + mingw-w64-crt/misc/mingw_msvcrt_mbfix.c | 437 ++++++++++++++++++ mingw-w64-crt/misc/mingw_secapi_mbfix.c | 255 ++++++++++ mingw-w64-crt/stdio/_vscwprintf.c | 86 ++++ mingw-w64-crt/stdio/mingw_pformat.c | 16 +- mingw-w64-crt/stdio/mingw_pformat.h | 6 +- mingw-w64-headers/crt/io.h | 14 + mingw-w64-headers/crt/sec_api/stdio_s.h | 271 +++++++++-- mingw-w64-headers/crt/sec_api/wchar_s.h | 35 +- mingw-w64-headers/crt/stdio.h | 140 +++++- mingw-w64-headers/crt/wchar.h | 109 ++++- 23 files changed, 1463 insertions(+), 88 deletions(-) create mode 100644 mingw-w64-crt/def-include/msvcrt-mbfix.def.in rename mingw-w64-crt/lib-common/{api-ms-win-crt-stdio-l1-1-0.def => api-ms-win-crt-stdio-l1-1-0.def.in} (98%) rename mingw-w64-crt/lib32/{msvcr70.def => msvcr70.def.in} (99%) rename mingw-w64-crt/lib32/{msvcr71.def => msvcr71.def.in} (99%) rename mingw-w64-crt/lib32/{msvcrt10.def => msvcrt10.def.in} (99%) rename mingw-w64-crt/lib32/{msvcrt20.def => msvcrt20.def.in} (99%) rename mingw-w64-crt/lib32/{msvcrt40.def => msvcrt40.def.in} (99%) create mode 100644 mingw-w64-crt/misc/mingw_msvcrt_mbfix.c create mode 100644 mingw-w64-crt/misc/mingw_secapi_mbfix.c create mode 100644 mingw-w64-crt/stdio/_vscwprintf.c diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 802657117..faf7905bd 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -450,6 +450,7 @@ src_msvcrt10=\ misc/seterrno.c \ stdio/_scprintf.c \ stdio/_vscprintf.c \ + stdio/_vscwprintf.c \ stdio/mingw_dummy__lock.c \ stdio/mingw_lock.c @@ -462,6 +463,7 @@ src_msvcrt20=\ misc/seterrno.c \ stdio/_scprintf.c \ stdio/_vscprintf.c \ + stdio/_vscwprintf.c \ stdio/mingw_dummy__lock.c \ stdio/mingw_lock.c @@ -472,6 +474,7 @@ src_msvcrt40=\ misc/seterrno.c \ stdio/_scprintf.c \ stdio/_vscprintf.c \ + stdio/_vscwprintf.c \ stdio/mingw_dummy__lock.c \ stdio/mingw_lock.c @@ -579,7 +582,8 @@ src_libmingwex=\ stdio/mingw_wvfscanf.c stdio/snprintf.c stdio/snwprintf.c stdio/strtof.c stdio/truncate.c \ stdio/ulltoa.c stdio/ulltow.c stdio/vasprintf.c stdio/vfscanf.c stdio/vfwscanf.c \ stdio/vscanf.c stdio/vsnprintf.c stdio/vsnwprintf.c stdio/vsscanf.c \ - stdio/vswscanf.c stdio/vwscanf.c stdio/wtoll.c stdio/mingw_asprintf.c stdio/mingw_vasprintf.c + stdio/vswscanf.c stdio/vwscanf.c stdio/wtoll.c stdio/mingw_asprintf.c stdio/mingw_vasprintf.c \ + misc/mingw_msvcrt_mbfix.c misc/mingw_secapi_mbfix.c # these go into both 32 and 64 bit x86 versions: src_libmingwex_x86=\ diff --git a/mingw-w64-crt/crt/ucrtbase_compat.c b/mingw-w64-crt/crt/ucrtbase_compat.c index 02910ff2f..691e9fb4d 100644 --- a/mingw-w64-crt/crt/ucrtbase_compat.c +++ b/mingw-w64-crt/crt/ucrtbase_compat.c @@ -38,7 +38,15 @@ int __cdecl __wgetmainargs(int * _Argc, wchar_t *** _Argv, wchar_t ***_Env, int void __cdecl _amsg_exit(int ret); unsigned int __cdecl _get_output_format(void); -int __cdecl __ms_fwprintf(FILE *, const wchar_t *, ...); +int __cdecl __ms_vfwprintf_p(FILE *, const wchar_t *, va_list); +int __cdecl __ms_vfwprintf_s(FILE *, const wchar_t *, va_list); +int __cdecl __ms_vfprintf_p(FILE *, const char *, va_list); +int __cdecl __ms_vfprintf_s(FILE *, const char *, va_list); +int __cdecl __ms_vprintf_p(const char *, va_list); +int __cdecl __ms_vprintf_s(const char *, va_list); +int __cdecl __ms_vwprintf_p(const wchar_t *, va_list); +int __cdecl __ms_vwprintf_s(const wchar_t *, va_list); +int __cdecl __isatty_on_non_ucrt(int); // Declarations of functions from ucrtbase.dll that we use below _CRTIMP int* __cdecl __p___argc(void); @@ -144,16 +152,92 @@ void __cdecl tzset(void) _tzset(); } -// This is called for wchar cases with __USE_MINGW_ANSI_STDIO enabled (where the -// char case just uses fputc). -int __cdecl __ms_fwprintf(FILE *file, const wchar_t *fmt, ...) +// This is called for wchar cases with __USE_MINGW_ANSI_STDIO enabled +// via misc/mingw_msvcrt_mbfix.c:___mingw_fwprintf(). (where the char +// case just uses fputc). +int __cdecl __ms_vfwprintf(FILE *_File, const wchar_t *_Format, va_list _ArgList) { - va_list ap; - int ret; - va_start(ap, fmt); - ret = __stdio_common_vfwprintf(_CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS, file, fmt, NULL, ap); - va_end(ap); - return ret; + return vfwprintf(_File, _Format, _ArgList); +} + +int __cdecl __ms_vfwprintf_p(FILE *_File, const wchar_t *_Format, va_list _ArgList) +{ + return _vfwprintf_p(_File, _Format, _ArgList); +} + +int __cdecl __ms_vfwprintf_s(FILE *_File, const wchar_t *_Format, va_list _ArgList) +{ + return vfwprintf_s(_File, _Format, _ArgList); +} + +int __cdecl __ms_vfprintf_p(FILE *_File, const char *_Format, va_list _ArgList) +{ + return _vfprintf_p(_File, _Format, _ArgList); +} + +int __cdecl __ms_vfprintf_s(FILE *_File, const char *_Format, va_list _ArgList) +{ + return vfprintf_s(_File, _Format, _ArgList); +} + +int __cdecl __ms_vprintf_p(const char *_Format, va_list _ArgList) +{ + return _vprintf_p(_Format, _ArgList); +} + +int __cdecl __ms_vprintf_s(const char *_Format, va_list _ArgList) +{ + return vprintf_s(_Format, _ArgList); +} + +int __cdecl __ms_vwprintf_p(const wchar_t *_Format, va_list _ArgList) +{ + return _vwprintf_p(_Format, _ArgList); +} + +int __cdecl __ms_vwprintf_s(const wchar_t *_Format, va_list _ArgList) +{ + return vwprintf_s(_Format, _ArgList); +} + +int __cdecl _vscwprintf(const wchar_t * __restrict__ _Format, va_list _ArgList) +{ + return _vscwprintf_l(_Format, NULL, _ArgList); +} + +int __cdecl _vscprintf_p(const char *_Format, va_list _ArgList) +{ + return _vscprintf_p_l(_Format, NULL, _ArgList); +} + +int __cdecl _vscwprintf_p(const wchar_t *_Format, va_list _ArgList) +{ + return _vscwprintf_p_l(_Format, NULL, _ArgList); +} + +int __cdecl _vswprintf_p(wchar_t *_DstBuf, size_t _DstSize, const wchar_t *_Format, va_list _ArgList) +{ + return _vswprintf_p_l(_DstBuf, _DstSize, _Format, NULL, _ArgList); +} + +int __cdecl vswprintf_s(wchar_t *_DstBuf, size_t _DstSize, const wchar_t *_Format, va_list _ArgList) +{ + return _vswprintf_s_l(_DstBuf, _DstSize, _Format, NULL, _ArgList); +} + +int __cdecl _vsprintf_p(char *_Dst, size_t _MaxCount, const char *_Format, va_list _ArgList) +{ + return _vsprintf_p_l(_Dst, _MaxCount, _Format, NULL, _ArgList); +} + +int __cdecl vsprintf_s(char *_DstBuf, size_t _Size, const char *_Format, va_list _ArgList) +{ + return _vsprintf_s_l(_DstBuf, _Size, _Format, NULL, _ArgList); +} + +int __cdecl __isatty_on_non_ucrt(int fd) +{ + return 0; } // Dummy/unused __imp_ wrappers, to make GNU ld not autoexport these symbols. @@ -162,7 +246,11 @@ int __cdecl (*__MINGW_IMP_SYMBOL(__wgetmainargs))(int *, wchar_t ***, wchar_t ** void __cdecl (*__MINGW_IMP_SYMBOL(_amsg_exit))(int) = _amsg_exit; unsigned int __cdecl (*__MINGW_IMP_SYMBOL(_get_output_format))(void) = _get_output_format; void __cdecl (*__MINGW_IMP_SYMBOL(tzset))(void) = tzset; -int __cdecl (*__MINGW_IMP_SYMBOL(__ms_fwprintf))(FILE *, const wchar_t *, ...) = __ms_fwprintf; +int __cdecl (*__MINGW_IMP_SYMBOL(vsprintf_s))(char *, size_t, const char *, va_list) = vsprintf_s; +int __cdecl (*__MINGW_IMP_SYMBOL(_vswprintf_p))(wchar_t *, size_t, const wchar_t *,va_list) = _vswprintf_p; +int __cdecl (*__MINGW_IMP_SYMBOL(_vscwprintf_p))(const wchar_t *, va_list) = _vscwprintf_p; +int __cdecl (*__MINGW_IMP_SYMBOL(_vscprintf_p))(const char *, va_list) = _vscprintf_p; + #ifdef __GNUC__ #pragma GCC diagnostic pop #endif diff --git a/mingw-w64-crt/def-include/msvcrt-common.def.in b/mingw-w64-crt/def-include/msvcrt-common.def.in index c31c6b631..8ddf6d38f 100644 --- a/mingw-w64-crt/def-include/msvcrt-common.def.in +++ b/mingw-w64-crt/def-include/msvcrt-common.def.in @@ -155,3 +155,5 @@ ADD_UNDERSCORE(tzname) ADD_UNDERSCORE(vsnprintf_s) #endif + +#include "msvcrt-mbfix.def.in" diff --git a/mingw-w64-crt/def-include/msvcrt-mbfix.def.in b/mingw-w64-crt/def-include/msvcrt-mbfix.def.in new file mode 100644 index 000000000..e039a16f7 --- /dev/null +++ b/mingw-w64-crt/def-include/msvcrt-mbfix.def.in @@ -0,0 +1,33 @@ +; Used by mingw_msvcrt_mbfix.c +__ms_fputchar == _fputchar +__ms_fputwchar == _fputwchar +__ms_putws == _putws +__ms_write == _write +__ms_fputc == fputc +__ms_fputs == fputs +__ms_fputwc == fputwc +__ms_fputws == fputws +__ms_fwrite == fwrite +__ms_putc == putc +__ms_putchar == putchar +__ms_puts == puts +__ms_putwc == putwc +__ms_putwchar == putwchar +#ifdef UCRT +; following functions are defined in crt/ucrtbase_compat.c +#else +#ifdef NO_SEC_API +#else +__ms_vfprintf_p == _vfprintf_p +__ms_vfwprintf_p == _vfwprintf_p +__ms_vprintf_p == _vprintf_p +__ms_vwprintf_p == _vwprintf_p +__ms_vfprintf_s == vfprintf_s +__ms_vfwprintf_s == vfwprintf_s +__ms_vprintf_s == vprintf_s +__ms_vwprintf_s == vwprintf_s +#endif +__isatty_on_non_ucrt == _isatty +; Used in vsprintf_s.c +__ms_vsnprintf == _vsnprintf +#endif diff --git a/mingw-w64-crt/lib-common/api-ms-win-crt-stdio-l1-1-0.def b/mingw-w64-crt/lib-common/api-ms-win-crt-stdio-l1-1-0.def.in similarity index 98% rename from mingw-w64-crt/lib-common/api-ms-win-crt-stdio-l1-1-0.def rename to mingw-w64-crt/lib-common/api-ms-win-crt-stdio-l1-1-0.def.in index d59859ced..931acbfb1 100644 --- a/mingw-w64-crt/lib-common/api-ms-win-crt-stdio-l1-1-0.def +++ b/mingw-w64-crt/lib-common/api-ms-win-crt-stdio-l1-1-0.def.in @@ -2,6 +2,9 @@ LIBRARY api-ms-win-crt-stdio-l1-1-0 EXPORTS +#define UCRT +#include "msvcrt-mbfix.def.in" + __acrt_iob_func __p__commode __p__fmode diff --git a/mingw-w64-crt/lib-common/ucrtbase.def.in b/mingw-w64-crt/lib-common/ucrtbase.def.in index a90fd72b7..f5d96a99f 100644 --- a/mingw-w64-crt/lib-common/ucrtbase.def.in +++ b/mingw-w64-crt/lib-common/ucrtbase.def.in @@ -3,6 +3,7 @@ EXPORTS #include "func.def.in" #define UCRTBASE +#define UCRT #include "msvcrt-common.def.in" #ifdef DEF_I386 diff --git a/mingw-w64-crt/lib32/msvcr70.def b/mingw-w64-crt/lib32/msvcr70.def.in similarity index 99% rename from mingw-w64-crt/lib32/msvcr70.def rename to mingw-w64-crt/lib32/msvcr70.def.in index 5ec73e781..3a8aeaa7a 100644 --- a/mingw-w64-crt/lib32/msvcr70.def +++ b/mingw-w64-crt/lib32/msvcr70.def.in @@ -5,6 +5,11 @@ ; LIBRARY "MSVCR70.dll" EXPORTS + +#define NO_SEC_API +#include "msvcrt-mbfix.def.in" +__ms_vfwprintf == vfwprintf + ; public: __thiscall __non_rtti_object::__non_rtti_object(class __non_rtti_object const &) ??0__non_rtti_object@@QAE@ABV0@@Z ; has WINAPI (@4) ; public: __thiscall __non_rtti_object::__non_rtti_object(char const *) diff --git a/mingw-w64-crt/lib32/msvcr71.def b/mingw-w64-crt/lib32/msvcr71.def.in similarity index 99% rename from mingw-w64-crt/lib32/msvcr71.def rename to mingw-w64-crt/lib32/msvcr71.def.in index 1db6d0b58..06630d4a8 100644 --- a/mingw-w64-crt/lib32/msvcr71.def +++ b/mingw-w64-crt/lib32/msvcr71.def.in @@ -5,6 +5,11 @@ ; LIBRARY "MSVCR71.dll" EXPORTS + +#define NO_SEC_API +#include "msvcrt-mbfix.def.in" +__ms_vfwprintf == vfwprintf + ; public: __thiscall __non_rtti_object::__non_rtti_object(class __non_rtti_object const &) ??0__non_rtti_object@@QAE@ABV0@@Z ; has WINAPI (@4) ; public: __thiscall __non_rtti_object::__non_rtti_object(char const *) diff --git a/mingw-w64-crt/lib32/msvcr80.def.in b/mingw-w64-crt/lib32/msvcr80.def.in index bb1ec8444..76cf9873b 100644 --- a/mingw-w64-crt/lib32/msvcr80.def.in +++ b/mingw-w64-crt/lib32/msvcr80.def.in @@ -1,6 +1,7 @@ LIBRARY "msvcr80.dll" EXPORTS +#define NO_SEC_API #include "msvcrt-common.def.in" _CIacos diff --git a/mingw-w64-crt/lib32/msvcrt10.def b/mingw-w64-crt/lib32/msvcrt10.def.in similarity index 99% rename from mingw-w64-crt/lib32/msvcrt10.def rename to mingw-w64-crt/lib32/msvcrt10.def.in index 5a3edf6e6..c29279666 100644 --- a/mingw-w64-crt/lib32/msvcrt10.def +++ b/mingw-w64-crt/lib32/msvcrt10.def.in @@ -5,6 +5,11 @@ ; LIBRARY "MSVCRT10.dll" EXPORTS + +#define NO_SEC_API +#include "msvcrt-mbfix.def.in" +__ms_vfwprintf == vfwprintf + ; public: __thiscall Iostream_init::Iostream_init(class ios &,int) ??0Iostream_init@@QAE@AAVios@@H@Z ; has WINAPI (@8) ; public: __thiscall Iostream_init::Iostream_init(void) diff --git a/mingw-w64-crt/lib32/msvcrt20.def b/mingw-w64-crt/lib32/msvcrt20.def.in similarity index 99% rename from mingw-w64-crt/lib32/msvcrt20.def rename to mingw-w64-crt/lib32/msvcrt20.def.in index 48d0487b9..4f7b6b962 100644 --- a/mingw-w64-crt/lib32/msvcrt20.def +++ b/mingw-w64-crt/lib32/msvcrt20.def.in @@ -5,6 +5,11 @@ ; LIBRARY "MSVCRT20.dll" EXPORTS + +#define NO_SEC_API +#include "msvcrt-mbfix.def.in" +__ms_vfwprintf == vfwprintf + ; public: __thiscall Iostream_init::Iostream_init(class ios &,int) ??0Iostream_init@@QAE@AAVios@@H@Z ; has WINAPI (@8) ; public: __thiscall Iostream_init::Iostream_init(void) diff --git a/mingw-w64-crt/lib32/msvcrt40.def b/mingw-w64-crt/lib32/msvcrt40.def.in similarity index 99% rename from mingw-w64-crt/lib32/msvcrt40.def rename to mingw-w64-crt/lib32/msvcrt40.def.in index 648f792df..c5072528c 100644 --- a/mingw-w64-crt/lib32/msvcrt40.def +++ b/mingw-w64-crt/lib32/msvcrt40.def.in @@ -5,6 +5,11 @@ ; LIBRARY "MSVCRT40.dll" EXPORTS + +#define NO_SEC_API +#include "msvcrt-mbfix.def.in" +__ms_vfwprintf == vfwprintf + ; public: __thiscall Iostream_init::Iostream_init(class ios &,int) ??0Iostream_init@@QAE@AAVios@@H@Z ; has WINAPI (@8) ; public: __thiscall Iostream_init::Iostream_init(void) diff --git a/mingw-w64-crt/lib64/msvcr80.def.in b/mingw-w64-crt/lib64/msvcr80.def.in index 045052ec8..df13b6acf 100644 --- a/mingw-w64-crt/lib64/msvcr80.def.in +++ b/mingw-w64-crt/lib64/msvcr80.def.in @@ -7,6 +7,7 @@ LIBRARY "msvcr80.dll" EXPORTS +#define NO_SEC_API #include "msvcrt-common.def.in" $I10_OUTPUT diff --git a/mingw-w64-crt/misc/mingw_msvcrt_mbfix.c b/mingw-w64-crt/misc/mingw_msvcrt_mbfix.c new file mode 100644 index 000000000..0a02df664 --- /dev/null +++ b/mingw-w64-crt/misc/mingw_msvcrt_mbfix.c @@ -0,0 +1,437 @@ +/* This file contains the workaround for multibyte char output + issue in msvcrt.dll. If printf("%ls\n", L"<multibyte string>") + is called after setlocale(LC_CTYPE, ""), the multibyte string + is not printed out correctly. Similarly, fwrite() to stdout + fails to print multibyte string. Not only printf and fwrite, + many of stdio functions have similar problem. This only occurs + when the stdout is a console and setlocale() is called. + Redirecting the output to pipe or file is not affected. This + seems due to the problem of msvcrt.dll. To avoid this problem, + byte-set of multibyte char is outputted in one action at once + using the following wrapper functions. */ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <io.h> +#include <fcntl.h> +#include <errno.h> +#include <windows.h> + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wmissing-prototypes" +#endif + +static int maxfd = -1; +/* For raw write and unbuffered stream */ +static char (*mbbuf)[MB_LEN_MAX+1]; +static int *mbcnt; +/* For buffered stream */ +static char (*mbsbuf)[MB_LEN_MAX+1]; +static int *mbscnt; + +static HANDLE mbfix_mutex; + +static __inline void lock() +{ + if (mbfix_mutex == NULL) { + char name[]="mingw-mbfix-mutex-0x00000000"; + sprintf(name, "mingw-mbfix-mutex-0x%08lx", GetCurrentProcessId()); + mbfix_mutex = CreateMutex(NULL, FALSE, name); + } + WaitForSingleObject(mbfix_mutex, INFINITE); +} + +static __inline void unlock() +{ + ReleaseMutex(mbfix_mutex); +} + +int __cdecl __ms_fputs(const char *, FILE *); +int __cdecl __ms_fputc(int, FILE *); +int __cdecl __ms_write(int, const void *, unsigned int); +static int __fputc (int _Ch, FILE *_File) +{ + int fd = _fileno(_File); + char *buf; + int *cnt; + if (fd > maxfd) { + void *p; + if ((p = realloc(mbbuf, (MB_LEN_MAX+1) * (fd + 1))) == NULL) + return EOF; + mbbuf = (char (*)[MB_LEN_MAX+1]) p; + if ((p = realloc(mbcnt, sizeof(int) * (fd + 1))) == NULL) + return EOF; + mbcnt = (int *) p; + if ((p = realloc(mbsbuf, (MB_LEN_MAX+1) * (fd + 1))) == NULL) + return EOF; + mbsbuf = (char (*)[MB_LEN_MAX+1]) p; + if ((p = realloc(mbscnt, sizeof(int) * (fd + 1))) == NULL) + return EOF; + mbscnt = (int *) p; + memset(mbcnt + maxfd + 1, 0, (fd - maxfd) * sizeof(int)); + memset(mbscnt + maxfd + 1, 0, (fd - maxfd) * sizeof(int)); + maxfd = fd; + } + if (_File->_bufsiz != 0 && (_File->_flag & _IONBF) == 0) { + buf = mbsbuf[fd]; + cnt = &mbscnt[fd]; + } else { + buf = mbbuf[fd]; + cnt = &mbcnt[fd]; + } + if (_Ch) + buf[(*cnt)++] = _Ch; + if ((_Ch == 0 && *cnt) || *cnt == MB_CUR_MAX + || mbtowc(NULL, buf, *cnt) == *cnt) { + int len = *cnt; + *cnt = 0; + buf[len] = '\0'; + if (_File->_bufsiz != 0 && (_File->_flag & _IONBF) == 0 + && _File->_ptr != _File->_base + && _File->_bufsiz - (_File->_ptr - _File->_base) < len) + /* Is buffered && the buffer is not empty + && not enough space for the multibyte char in the buffer */ + fflush(stdout); + if (_File->_bufsiz != 0 && (_File->_flag & _IONBF) == 0 + && _File->_bufsiz < len) { + /* Is buffered && the buffer is too small for the multibyte char. */ + if (__ms_write(fd, buf, len) < 0) + return EOF; + } else if (__ms_fputs(buf, _File) == EOF) { + return EOF; + } + } + if (_Ch == 0) + return __ms_fputc(_Ch, _File); + return _Ch; +} + +int __mbfix_fputs(const char *_Str, FILE *_File, int cont_on_err) +{ + int ret = 0; + const char *p; + for (p = _Str; *p; p++) + if (__fputc(*p, _File) == EOF) { + ret = EOF; + if (!cont_on_err) + break; + } + return ret; +} + +wint_t __cdecl __ms_fputwc(wchar_t, FILE *); +static __inline wint_t __fputwc(wchar_t _Ch, FILE *_File) +{ + char buf[MB_LEN_MAX+1]; + int l; + if (_Ch == L'\0') + return __ms_fputwc(_Ch, _File); + l = wctomb(buf, _Ch); + if (l == -1) + return WEOF; + buf[l] = '\0'; + if (__mbfix_fputs(buf, _File, 1) == EOF) + return WEOF; + return _Ch; +} + +int __mbfix_fputws(const wchar_t *_Str, FILE *_File, int cont_on_err) +{ + int ret = 0; + const wchar_t *p; + for (p = _Str; *p; p++) + if (__fputwc(*p, _File) == WEOF) { + ret = EOF; + if (!cont_on_err) + break; + } + return ret; +} + +static __inline int __getmode(int _Fd) +{ + int orig_mode = _setmode(_Fd, _O_TEXT); + _setmode(_Fd, orig_mode); + return orig_mode; +} + +static __inline int __is_textmode(int _Fd) +{ + return __getmode(_Fd) == _O_TEXT; +} + +int __cdecl __isatty_on_non_ucrt(int); +int __mb_to_be_fixed(int _Fd) +{ + return (MB_CUR_MAX > 1 && __isatty_on_non_ucrt(_Fd) && __is_textmode(_Fd)); +} + +int __cdecl __ms_fputchar(int); +int __cdecl __mingw_fputchar(int _Ch) +{ + if (__mb_to_be_fixed(_fileno(stdout))) { + int ret; + lock(); + ret = __fputc(_Ch, stdout); + unlock(); + return ret; + } + return __ms_fputchar(_Ch); +} + +wint_t __cdecl __ms_fputwchar(wchar_t); +wint_t __cdecl __mingw_fputwchar(wchar_t _Ch) +{ + if (__mb_to_be_fixed(_fileno(stdout))) { + wint_t ret; + lock(); + ret = __fputwc (_Ch, stdout); + unlock(); + return ret; + } + return __ms_fputwchar(_Ch); +} + +int __cdecl __mingw_fputc(int _Ch, FILE *_File) +{ + if (__mb_to_be_fixed(_fileno(_File))) { + int ret; + lock(); + ret = __fputc(_Ch, _File); + unlock(); + return ret; + } + return __ms_fputc(_Ch, _File); +} + +int __cdecl __mingw_fputs(const char *_Str, FILE *_File) +{ + if (__mb_to_be_fixed(_fileno(_File))) { + int ret; + lock(); + ret = __mbfix_fputs(_Str, _File, 0); + unlock(); + return ret; + } + return __ms_fputs(_Str, _File); +} + +wint_t __cdecl __mingw_fputwc(wchar_t _Ch, FILE *_File) +{ + if (__mb_to_be_fixed(_fileno(_File))) { + wint_t ret; + lock(); + ret = __fputwc(_Ch, _File); + unlock(); + return ret; + } + return __ms_fputwc(_Ch, _File); +} + +int __cdecl __ms_fputws(const wchar_t *, FILE *); +int __cdecl __mingw_fputws(const wchar_t *_Str, FILE *_File) +{ + if (__mb_to_be_fixed(_fileno(_File))) { + int ret; + lock(); + ret = __mbfix_fputws(_Str, _File, 0); + unlock(); + return ret; + } + return __ms_fputws(_Str, _File); +} + +size_t __cdecl __ms_fwrite(const void *, size_t, size_t, FILE *); +size_t __cdecl __mingw_fwrite(const void *_Buf, size_t _Size, size_t _Cnt, FILE * _File) +{ + if (__isatty_on_non_ucrt(_fileno(_File))) { + int mode; + size_t i; + if (MB_CUR_MAX > 1 && __is_textmode(_fileno(_File))) { + lock(); + for (i = 0; i < _Size * _Cnt; i++) + if (__fputc(((char *)_Buf)[i], _File) == EOF) + break; + unlock(); + return i / _Size; + } + mode = __getmode(_fileno(_File)); + if (mode == _O_WTEXT || mode == _O_U8TEXT || mode == _O_U16TEXT) { + if ((_Size * _Cnt) % sizeof(wchar_t)) { + errno = EINVAL; + return 0; + } + lock(); + for (i = 0; i < _Size * _Cnt / sizeof(wchar_t); i++) + if (__ms_fputwc(((wchar_t *)_Buf)[i], _File) == WEOF) + break; + unlock(); + return i * sizeof(wchar_t) / _Size; + } + /* _O_BINARY || _O_TEXT with no multibyte locale */ + return __ms_fwrite(_Buf, _Size, _Cnt, _File); + } + return __ms_fwrite(_Buf, _Size, _Cnt, _File); +} + +int __cdecl __ms_putc(int, FILE *); +int __cdecl __mingw_putc(int _Ch, FILE *_File) +{ + if (__mb_to_be_fixed(_fileno(_File))) { + int ret; + lock(); + ret = __fputc(_Ch, _File); + unlock(); + return ret; + } + return __ms_putc(_Ch, _File); +} + +int __cdecl __ms_putchar(int); +int __cdecl __mingw_putchar(int _Ch) +{ + if (__mb_to_be_fixed(_fileno(stdout))) { + int ret; + lock(); + ret = __fputc(_Ch, stdout); + unlock(); + return ret; + } + return __ms_putchar(_Ch); +} + +int __cdecl __ms_puts(const char *); +int __cdecl __mingw_puts(const char *_Str) +{ + if (__mb_to_be_fixed(_fileno(stdout))) { + lock(); + if (__mbfix_fputs(_Str, stdout, 0) == EOF) { + unlock(); + return EOF; + } + if (__ms_fputc('\n', stdout) == EOF) { + unlock(); + return EOF; + } + unlock(); + return 0; + } + return __ms_puts(_Str); +} + +wint_t __cdecl __ms_putwc(wchar_t, FILE *); +wint_t __cdecl __mingw_putwc(wchar_t _Ch, FILE *_File) +{ + if (__mb_to_be_fixed(_fileno(_File))) { + wint_t ret; + lock(); + ret = __fputwc(_Ch, _File); + unlock(); + return ret; + } + return __ms_putwc(_Ch, _File); +} + +wint_t __cdecl __ms_putwchar(wchar_t); +wint_t __cdecl __mingw_putwchar(wchar_t _Ch) +{ + if (__mb_to_be_fixed(_fileno(stdout))) { + wint_t ret; + lock(); + ret = __fputwc(_Ch, stdout); + unlock(); + return ret; + } + return __ms_fputwchar(_Ch); +} + +int __cdecl __ms_putws(const wchar_t *); +int __cdecl __mingw_putws(const wchar_t *_Str) +{ + if (__mb_to_be_fixed(_fileno(stdout))) { + lock(); + if (__mbfix_fputws(_Str, stdout, 0) == EOF) { + unlock(); + return WEOF; + } + if (__ms_fputc('\n', stdout) == EOF) { + unlock(); + return WEOF; + } + unlock(); + return 0; + } + return __ms_putws(_Str); +} + +int __cdecl __mingw_write(int _Fd, const void *_Buf, unsigned int _Count) +{ + unsigned int i; + if (!__mb_to_be_fixed(_Fd)) + return __ms_write (_Fd, _Buf, _Count); + + lock(); + if (_Fd > maxfd) { + void *p; + if ((p = realloc(mbbuf, (MB_LEN_MAX+1) * (_Fd + 1))) == NULL) { + unlock(); + return EOF; + } + mbbuf = (char (*)[MB_LEN_MAX+1]) p; + if ((p = realloc(mbcnt, sizeof(int) * (_Fd + 1))) == NULL) { + unlock(); + return EOF; + } + mbcnt = (int *) p; + if ((p = realloc(mbsbuf, (MB_LEN_MAX+1) * (_Fd + 1))) == NULL) { + unlock(); + return EOF; + } + mbsbuf = (char (*)[MB_LEN_MAX+1]) p; + if ((p = realloc(mbscnt, sizeof(int) * (_Fd + 1))) == NULL) { + unlock(); + return EOF; + } + mbscnt = (int *) p; + memset(mbcnt + maxfd + 1, 0, (_Fd - maxfd) * sizeof(int)); + memset(mbscnt + maxfd + 1, 0, (_Fd - maxfd) * sizeof(int)); + maxfd = _Fd; + } + for (i = 0; i < _Count; i++) { + mbbuf[_Fd][mbcnt[_Fd]++] = ((char *)_Buf)[i]; + if (mbcnt[_Fd] == MB_CUR_MAX || mbtowc(NULL, mbbuf[_Fd], mbcnt[_Fd]) == mbcnt[_Fd]) { + if (__ms_write(_Fd, mbbuf[_Fd], mbcnt[_Fd]) < 0) + break; + mbcnt[_Fd] = 0; + } + } + unlock(); + return i; +} + +int __cdecl ___mingw_fwprintf(FILE *_File, const wchar_t *_Fmt, ...) +{ + __builtin_va_list _Va; + int ret; + __builtin_va_start(_Va, _Fmt); + if (__mb_to_be_fixed(_fileno(_File))) { + wchar_t *buf; + int len = _vscwprintf(_Fmt, _Va) + 1; + if (len < 1) + len = 1024; /* vswprintf() can set buf even if error occurs. */ + buf = (wchar_t *) malloc(len * sizeof(wchar_t)); + if (buf == NULL) + return -1; + ret = vswprintf(buf, len, _Fmt, _Va); + buf[len - 1] = L'\0'; + lock(); + if (__mbfix_fputws(buf, _File, 1) == EOF) + ret = -1; + unlock(); + free(buf); + } else { + ret = __ms_vfwprintf(_File, _Fmt, _Va); + } + __builtin_va_end(_Va); + return ret; +} diff --git a/mingw-w64-crt/misc/mingw_secapi_mbfix.c b/mingw-w64-crt/misc/mingw_secapi_mbfix.c new file mode 100644 index 000000000..7d24e2a43 --- /dev/null +++ b/mingw-w64-crt/misc/mingw_secapi_mbfix.c @@ -0,0 +1,255 @@ +/* This file contains the workaround for multibyte char output + issue in msvcrt.dll. If printf("%ls\n", L"<multibyte string>") + is called after setlocale(LC_CTYPE, ""), the multibyte string + is not printed out correctly. Similarly, fwrite() to stdout + fails to print multibyte string. Not only printf and fwrite, + many of stdio functions have similar problem. This only occurs + when the stdout is a console and setlocale() is called. + Redirecting the output to pipe or file is not affected. This + seems due to the problem of msvcrt.dll. To avoid this problem, + byte-set of multibyte char is outputted in one action at once + using the following wrapper functions. */ +#include <stdio.h> +#include <stdlib.h> +#include <windows.h> + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wmissing-prototypes" +#endif + +static HANDLE mbfix_mutex; + +static __inline void lock() +{ + if (mbfix_mutex == NULL) { + char name[]="mingw-mbfix-mutex-0x00000000"; + sprintf(name, "mingw-mbfix-mutex-0x%08lx", GetCurrentProcessId()); + mbfix_mutex = CreateMutex(NULL, FALSE, name); + } + WaitForSingleObject(mbfix_mutex, INFINITE); +} + +static __inline void unlock() +{ + ReleaseMutex(mbfix_mutex); +} + +int __mb_to_be_fixed(int _Fd); +int __mbfix_fputs(const char *_Str, FILE *_File, int cont_on_err); +int __mbfix_fputws(const wchar_t *_Str, FILE *_File, int cont_on_err); + +int __cdecl __ms_vfprintf_p(FILE *, const char *, va_list); +int __cdecl __mingw_vfprintf_p(FILE *_File, const char *_Fmt, va_list _Va) +{ + if (__mb_to_be_fixed(_fileno(_File))) { + int ret; + char *buf; + int len = _vscprintf_p(_Fmt, _Va) + 1; + if (len < 1) + len = 1024; /* _vsprintf_p() can set buf even if error occurs. */ + buf = (char *) malloc(len); + if (buf == NULL) + return -1; + ret = _vsprintf_p(buf, len, _Fmt, _Va); + lock(); + if (__mbfix_fputs(buf, _File, 1) == EOF) + ret = -1; + unlock(); + free(buf); + return ret; + } + return __ms_vfprintf_p(_File, _Fmt, _Va); +} + +int __cdecl __ms_vfwprintf_p(FILE *, const wchar_t *, va_list); +int __cdecl __mingw_vfwprintf_p(FILE *_File, const wchar_t *_Fmt, va_list _Va) +{ + if (__mb_to_be_fixed(_fileno(_File))) { + int ret; + wchar_t *buf; + int len = _vscwprintf_p(_Fmt, _Va) + 1; + if (len < 1) + len = 1024; /* _vswprintf_p() can set buf even if error occurs. */ + buf = (wchar_t *) malloc(len * sizeof(wchar_t)); + if (buf == NULL) + return -1; + ret = _vswprintf_p(buf, len, _Fmt, _Va); + lock(); + if (__mbfix_fputws(buf, _File, 1) == EOF) + ret = -1; + unlock(); + free(buf); + return ret; + } + return __ms_vfwprintf_p(_File, _Fmt, _Va); +} + +int __cdecl __ms_vprintf_p(const char *, va_list); +int __cdecl __mingw_vprintf_p(const char *_Fmt, va_list _Va) +{ + if (__mb_to_be_fixed(_fileno(stdout))) { + int ret; + char *buf; + int len = _vscprintf_p(_Fmt, _Va) + 1; + if (len < 1) + len = 1024; /* _vsprintf_p() can set buf even if error occurs. */ + buf = (char *) malloc(len); + if (buf == NULL) + return -1; + ret = _vsprintf_p(buf, len, _Fmt, _Va); + lock(); + if (__mbfix_fputs(buf, stdout, 1) == EOF) + ret = -1; + unlock(); + free(buf); + return ret; + } + return __ms_vprintf_p(_Fmt, _Va); +} + +int __cdecl __ms_vwprintf_p(const wchar_t *, va_list); +int __cdecl __mingw_vwprintf_p(const wchar_t *_Fmt, va_list _Va) +{ + if (__mb_to_be_fixed(_fileno(stdout))) { + int ret; + wchar_t *buf; + int len = _vscwprintf_p(_Fmt, _Va) + 1; + if (len < 1) + len = 1024; /* _vswprintf_p() can set buf even if error occurs. */ + buf = (wchar_t *) malloc(len * sizeof(wchar_t)); + if (buf == NULL) + return -1; + ret = _vswprintf_p(buf, len, _Fmt, _Va); + lock(); + if (__mbfix_fputws(buf, stdout, 1) == EOF) + ret = -1; + unlock(); + free(buf); + return ret; + } + return __ms_vwprintf_p(_Fmt, _Va); +} + +int __cdecl __ms_vfprintf_s(FILE *, const char *, va_list); +int __cdecl __mingw_vfprintf_s(FILE *_File, const char *_Fmt, va_list _Va) +{ + if (__mb_to_be_fixed(_fileno(_File))) { + int ret; + int error_maybe = 0; + char *buf; + int len = _vscprintf(_Fmt, _Va) + 1; + if (len < 1) { + len = 1024; /* _vsnprintf() can set buf even if error occurs. */ + error_maybe = 1; + } + buf = (char *) malloc(len); + if (buf == NULL) + return -1; + if (error_maybe) { + ret = _vsnprintf(buf, len, _Fmt, _Va); + buf[len - 1] = '\0'; + } else { + ret = vsprintf_s(buf, len, _Fmt, _Va); + } + lock(); + if (__mbfix_fputs(buf, _File, 1) == EOF) + ret = -1; + unlock(); + free(buf); + return ret; + } + return __ms_vfprintf_s(_File, _Fmt, _Va); +} + +int __cdecl __ms_vfwprintf_s(FILE *, const wchar_t *, va_list); +int __cdecl __mingw_vfwprintf_s(FILE *_File, const wchar_t *_Fmt, va_list _Va) +{ + if (__mb_to_be_fixed(_fileno(_File))) { + int ret; + int error_maybe = 0; + wchar_t *buf; + int len = _vscwprintf(_Fmt, _Va) + 1; + if (len < 1) { + len = 1024; /* _vsnwprintf() can set buf even if error occurs. */ + error_maybe = 1; + } + buf = (wchar_t *) malloc(len * sizeof(wchar_t)); + if (buf == NULL) + return -1; + if (error_maybe) { + ret = _vsnwprintf(buf, len, _Fmt, _Va); + buf[len - 1] = L'\0'; + } else { + ret = vswprintf_s(buf, len, _Fmt, _Va); + } + lock(); + if (__mbfix_fputws(buf, _File, 1) == EOF) + ret = -1; + unlock(); + free(buf); + return ret; + } + return __ms_vfwprintf_s(_File, _Fmt, _Va); +} + +int __cdecl __ms_vprintf_s(const char *, va_list); +int __cdecl __mingw_vprintf_s(const char *_Fmt, va_list _Va) +{ + if (__mb_to_be_fixed(_fileno(stdout))) { + int ret; + int error_maybe = 0; + char *buf; + int len = _vscprintf(_Fmt, _Va) + 1; + if (len < 1) { + len = 1024; /* _vsnprintf() can set buf even if error occurs. */ + error_maybe = 1; + } + buf = (char *) malloc(len); + if (buf == NULL) + return -1; + if (error_maybe) { + ret = _vsnprintf(buf, len, _Fmt, _Va); + buf[len - 1] = '\0'; + } else { + ret = vsprintf_s(buf, len, _Fmt, _Va); + } + lock(); + if (__mbfix_fputs(buf, stdout, 1) == EOF) + ret = -1; + unlock(); + free(buf); + return ret; + } + return __ms_vprintf_s(_Fmt, _Va); +} + +int __cdecl __ms_vwprintf_s(const wchar_t *, va_list); +int __cdecl __mingw_vwprintf_s(const wchar_t *_Fmt, va_list _Va) +{ + if (__mb_to_be_fixed(_fileno(stdout))) { + int ret; + int error_maybe = 0; + wchar_t *buf; + int len = _vscwprintf(_Fmt, _Va) + 1; + if (len < 1) { + len = 1024; /* _vsnwprintf() can set buf even if error occurs. */ + error_maybe = 1; + } + buf = (wchar_t *) malloc(len * sizeof(wchar_t)); + if (buf == NULL) + return -1; + if (error_maybe) { + ret = _vsnwprintf(buf, len, _Fmt, _Va); + buf[len - 1] = L'\0'; + } else { + ret = vswprintf_s(buf, len, _Fmt, _Va); + } + lock(); + if (__mbfix_fputws(buf, stdout, 1) == EOF) + ret = -1; + unlock(); + free(buf); + return ret; + } + return __ms_vwprintf_s(_Fmt, _Va); +} diff --git a/mingw-w64-crt/stdio/_vscwprintf.c b/mingw-w64-crt/stdio/_vscwprintf.c new file mode 100644 index 000000000..5f0b118e4 --- /dev/null +++ b/mingw-w64-crt/stdio/_vscwprintf.c @@ -0,0 +1,86 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ +#include <windows.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> + +/* emulation of _vscwprintf() via _vsnwprintf() */ +static int __cdecl emu_vscwprintf(const wchar_t * __restrict__ format, va_list arglist) +{ + wchar_t *buffer, *new_buffer; + size_t size; + int ret; + + /* if format is a null pointer, _vscwprintf() returns -1 and sets errno to EINVAL */ + if (!format) { + _set_errno(EINVAL); + return -1; + } + + /* size for _vsnwprintf() must be non-zero and buffer must have place for terminating null character */ + size = wcslen(format) * 2 + 1; + buffer = (wchar_t *) malloc(size * sizeof(wchar_t)); + + if (!buffer) { + _set_errno(ENOMEM); + return -1; + } + + /* if the number of characters to write is greater than size, _vsnwprintf() returns -1 */ + while (size < SIZE_MAX/2 && (ret = _vsnwprintf(buffer, size, format, arglist)) < 0) { + /* in this case try with larger buffer */ + size *= 2; + new_buffer = (wchar_t *) realloc(buffer, size * sizeof(wchar_t)); + if (!new_buffer) + break; + buffer = new_buffer; + } + + free(buffer); + + if (ret < 0) { + _set_errno(ENOMEM); + return -1; + } + + return ret; +} + +#ifndef __LIBMSVCRT_OS__ + +int (__cdecl *__MINGW_IMP_SYMBOL(_vscwprintf))(const wchar_t * __restrict__, va_list) = emu_vscwprintf; + +#else + +#include <msvcrt.h> + +static int __cdecl init_vscwprintf(const wchar_t * __restrict__ format, va_list arglist); + +int (__cdecl *__MINGW_IMP_SYMBOL(_vscwprintf))(const wchar_t * __restrict__, va_list) = init_vscwprintf; + +static int __cdecl init_vscwprintf(const wchar_t * __restrict__ format, va_list arglist) +{ + HMODULE msvcrt = __mingw_get_msvcrt_handle(); + int (__cdecl *func)(const wchar_t * __restrict__, va_list) = NULL; + + if (msvcrt) + func = (int (__cdecl *)(const wchar_t * __restrict__, va_list))GetProcAddress(msvcrt, "_vscwprintf"); + + if (!func) + func = emu_vscwprintf; + + return (__MINGW_IMP_SYMBOL(_vscwprintf) = func)(format, arglist); +} + +#endif + +int __cdecl _vscwprintf(const wchar_t * __restrict__ format, va_list arglist) +{ + return __MINGW_IMP_SYMBOL(_vscwprintf)(format, arglist); +} diff --git a/mingw-w64-crt/stdio/mingw_pformat.c b/mingw-w64-crt/stdio/mingw_pformat.c index d9f5de7ce..60ab9f116 100644 --- a/mingw-w64-crt/stdio/mingw_pformat.c +++ b/mingw-w64-crt/stdio/mingw_pformat.c @@ -478,18 +478,18 @@ void __pformat_putchars( const char *s, int count, __pformat_t *stream ) if( (stream->flags & PFORMAT_TO_FILE) && (stream->flags & PFORMAT_NOLIMIT) ) { - int __cdecl __ms_fwprintf(FILE *, const wchar_t *, ...); + int __cdecl ___mingw_fwprintf(FILE *, const wchar_t *, ...); if( stream->width > count ) { if( (stream->flags & PFORMAT_LJUSTIFY) == 0 ) - len = __ms_fwprintf( (FILE *)(stream->dest), L"%*.*S", stream->width, count, s ); + len = ___mingw_fwprintf( (FILE *)(stream->dest), L"%*.*S", stream->width, count, s ); else - len = __ms_fwprintf( (FILE *)(stream->dest), L"%-*.*S", stream->width, count, s ); + len = ___mingw_fwprintf( (FILE *)(stream->dest), L"%-*.*S", stream->width, count, s ); } else { - len = __ms_fwprintf( (FILE *)(stream->dest), L"%.*S", count, s ); + len = ___mingw_fwprintf( (FILE *)(stream->dest), L"%.*S", count, s ); } if( len > 0 ) stream->count += len; @@ -629,18 +629,18 @@ void __pformat_wputchars( const wchar_t *s, int count, __pformat_t *stream ) if( (stream->flags & PFORMAT_TO_FILE) && (stream->flags & PFORMAT_NOLIMIT) ) { - int __cdecl __ms_fwprintf(FILE *, const wchar_t *, ...); + int __cdecl ___mingw_fwprintf(FILE *, const wchar_t *, ...); if( stream->width > count ) { if( (stream->flags & PFORMAT_LJUSTIFY) == 0 ) - len = __ms_fwprintf( (FILE *)(stream->dest), L"%*.*s", stream->width, count, s ); + len = ___mingw_fwprintf( (FILE *)(stream->dest), L"%*.*s", stream->width, count, s ); else - len = __ms_fwprintf( (FILE *)(stream->dest), L"%-*.*s", stream->width, count, s ); + len = ___mingw_fwprintf( (FILE *)(stream->dest), L"%-*.*s", stream->width, count, s ); } else { - len = __ms_fwprintf( (FILE *)(stream->dest), L"%.*s", count, s ); + len = ___mingw_fwprintf( (FILE *)(stream->dest), L"%.*s", count, s ); } if( len > 0 ) stream->count += len; diff --git a/mingw-w64-crt/stdio/mingw_pformat.h b/mingw-w64-crt/stdio/mingw_pformat.h index 477780432..13ad8063b 100644 --- a/mingw-w64-crt/stdio/mingw_pformat.h +++ b/mingw-w64-crt/stdio/mingw_pformat.h @@ -68,7 +68,8 @@ */ #ifdef __BUILD_WIDEAPI # define __pformat __mingw_wpformat -#define __fputc(X,STR) fputwc((wchar_t) (X), (STR)) +wint_t __cdecl __mingw_fputwc(wchar_t, FILE *); +#define __fputc(X,STR) __mingw_fputwc((wchar_t) (X), (STR)) # define __printf __mingw_wprintf # define __fprintf __mingw_fwprintf @@ -81,7 +82,8 @@ # define __vsnprintf __mingw_vsnwprintf #else # define __pformat __mingw_pformat -#define __fputc(X,STR) fputc((X), (STR)) +int __cdecl __mingw_fputc(int, FILE*); +#define __fputc(X,STR) __mingw_fputc((X), (STR)) # define __printf __mingw_printf # define __fprintf __mingw_fprintf diff --git a/mingw-w64-headers/crt/io.h b/mingw-w64-headers/crt/io.h index 8986931a5..9b0736ab6 100644 --- a/mingw-w64-headers/crt/io.h +++ b/mingw-w64-headers/crt/io.h @@ -224,7 +224,14 @@ _CRTIMP char* __cdecl _getcwd (char*, int); _CRTIMP long __cdecl _tell(int _FileHandle); _CRTIMP int __cdecl _umask(int _Mode) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; _SECIMP errno_t __cdecl _umask_s (int _NewMode,int *_OldMode); +#ifndef _UCRT + __mingw_ovr int _write(int _FileHandle,const void *_Buf,unsigned int _MaxCharCount) { + int __cdecl __mingw_write(int, const void *, unsigned int); + return __mingw_write(_FileHandle, _Buf, _MaxCharCount); + } +#else _CRTIMP int __cdecl _write(int _FileHandle,const void *_Buf,unsigned int _MaxCharCount); +#endif __MINGW_EXTENSION _CRTIMP __int64 __cdecl _filelengthi64(int _FileHandle); _CRTIMP intptr_t __cdecl _findfirst32i64(const char *_Filename,struct _finddata32i64_t *_FindData); @@ -343,8 +350,15 @@ _CRTIMP char* __cdecl _getcwd (char*, int); int __cdecl sopen(const char *_Filename,int _OpenFlag,int _ShareFlag,...) __MINGW_ATTRIB_DEPRECATED_MSVC2005; long __cdecl tell(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005; int __cdecl umask(int _Mode) __MINGW_ATTRIB_DEPRECATED_MSVC2005; +#ifndef _UCRT + __mingw_ovr int write(int _FileHandle,const void *_Buf,unsigned int _MaxCharCount) { + int __cdecl __mingw_write(int, const void *, unsigned int); + return __mingw_write(_FileHandle, _Buf, _MaxCharCount); + } +#else int __cdecl write(int _Filehandle,const void *_Buf,unsigned int _MaxCharCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005; #endif +#endif #ifndef _FILE_OFFSET_BITS_SET_LSEEK #define _FILE_OFFSET_BITS_SET_LSEEK diff --git a/mingw-w64-headers/crt/sec_api/stdio_s.h b/mingw-w64-headers/crt/sec_api/stdio_s.h index 8a736311e..1fc13fe2c 100644 --- a/mingw-w64-headers/crt/sec_api/stdio_s.h +++ b/mingw-w64-headers/crt/sec_api/stdio_s.h @@ -293,10 +293,7 @@ extern "C" { { return __stdio_common_vsprintf_s(0, _DstBuf, _DstSize, _Format, _Locale, _ArgList); } - __mingw_ovr int __cdecl vsprintf_s(char *_DstBuf, size_t _Size, const char *_Format, va_list _ArgList) - { - return _vsprintf_s_l(_DstBuf, _Size, _Format, NULL, _ArgList); - } + int __cdecl vsprintf_s(char *_DstBuf, size_t _Size, const char *_Format, va_list _ArgList); __mingw_ovr int __cdecl _sprintf_s_l(char *_DstBuf, size_t _DstSize, const char *_Format, _locale_t _Locale, ...) { __builtin_va_list _ArgList; @@ -373,10 +370,7 @@ extern "C" { { return __stdio_common_vsprintf_p(0, _DstBuf, _MaxCount, _Format, _Locale, _ArgList); } - __mingw_ovr int __cdecl _vsprintf_p(char *_Dst, size_t _MaxCount, const char *_Format, va_list _ArgList) - { - return _vsprintf_p_l(_Dst, _MaxCount, _Format, NULL, _ArgList); - } + int __cdecl _vsprintf_p(char *_Dst, size_t _MaxCount, const char *_Format, va_list _ArgList); __mingw_ovr int __cdecl _sprintf_p_l(char *_DstBuf, size_t _MaxCount, const char *_Format, _locale_t _Locale, ...) { __builtin_va_list _ArgList; @@ -400,10 +394,7 @@ extern "C" { { return __stdio_common_vsprintf_p(_CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, NULL, 0, _Format, _Locale, _ArgList); } - __mingw_ovr int __cdecl _vscprintf_p(const char *_Format, va_list _ArgList) - { - return _vscprintf_p_l(_Format, NULL, _ArgList); - } + int __cdecl _vscprintf_p(const char *_Format, va_list _ArgList); __mingw_ovr int __cdecl _scprintf_p_l(const char *_Format, _locale_t _Locale, ...) { __builtin_va_list _ArgList; @@ -491,10 +482,26 @@ extern "C" { return _Ret; } #else /* _UCRT */ - int __cdecl fprintf_s(FILE *_File,const char *_Format,...); + __mingw_ovr int fprintf_s(FILE *_File,const char *_Format,...) { + int __cdecl __mingw_vfprintf_s (FILE *, const char *, va_list); + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = __mingw_vfprintf_s (_File, _Format, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } _CRTIMP int __cdecl _fscanf_s_l(FILE *_File,const char *_Format,_locale_t _Locale,...); _CRTIMP int __cdecl fscanf_s(FILE *_File, const char *_Format, ...); - int __cdecl printf_s(const char *_Format,...); + __mingw_ovr int printf_s(const char *_Format,...) { + int __cdecl __mingw_vprintf_s (const char *, va_list); + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = __mingw_vprintf_s (_Format, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } _CRTIMP int __cdecl _scanf_l(const char *_Format,_locale_t _Locale,...); _CRTIMP int __cdecl _scanf_s_l(const char *_Format,_locale_t _Locale,...); _CRTIMP int __cdecl scanf_s(const char *_Format, ...); @@ -508,8 +515,14 @@ extern "C" { _CRTIMP int __cdecl _snscanf_s(const char *_Src,size_t _MaxCount,const char *_Format,...); _CRTIMP int __cdecl _snscanf_l(const char *_Src,size_t _MaxCount,const char *_Format,_locale_t _Locale,...); _CRTIMP int __cdecl _snscanf_s_l(const char *_Src,size_t _MaxCount,const char *_Format,_locale_t _Locale,...); - int __cdecl vfprintf_s(FILE *_File,const char *_Format,va_list _ArgList); - int __cdecl vprintf_s(const char *_Format,va_list _ArgList); + __mingw_ovr int vfprintf_s(FILE *_File,const char *_Format,va_list _ArgList) { + int __cdecl __mingw_vfprintf_s(FILE *,const char *,va_list); + return __mingw_vfprintf_s(_File, _Format, _ArgList); + } + __mingw_ovr int vprintf_s(const char *_Format,va_list _ArgList) { + int __cdecl __mingw_vprintf_s(const char *,va_list); + return __mingw_vprintf_s(_Format, _ArgList); + } int __cdecl vsnprintf_s(char *_DstBuf,size_t _DstSize,size_t _MaxCount,const char *_Format,va_list _ArgList); @@ -521,11 +534,33 @@ extern "C" { _CRTIMP int __cdecl _snprintf_s(char *_DstBuf,size_t _DstSize,size_t _MaxCount,const char *_Format,...); - _CRTIMP int __cdecl _fprintf_p(FILE *_File,const char *_Format,...); - _CRTIMP int __cdecl _printf_p(const char *_Format,...); + __mingw_ovr int _fprintf_p(FILE *_File,const char *_Format,...) { + int __cdecl __mingw_vfprintf_p (FILE *, const char *, va_list); + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = __mingw_vfprintf_p (_File, _Format, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int _printf_p(const char *_Format,...) { + int __cdecl __mingw_vprintf_p (const char *, va_list); + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = __mingw_vprintf_p (_Format, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } _CRTIMP int __cdecl _sprintf_p(char *_Dst,size_t _MaxCount,const char *_Format,...); - _CRTIMP int __cdecl _vfprintf_p(FILE *_File,const char *_Format,va_list _ArgList); - _CRTIMP int __cdecl _vprintf_p(const char *_Format,va_list _ArgList); + __mingw_ovr int _vfprintf_p(FILE *_File,const char *_Format,va_list _ArgList) { + int __cdecl __mingw_vfprintf_p(FILE *,const char *,va_list); + return __mingw_vfprintf_p(_File, _Format, _ArgList); + } + __mingw_ovr int _vprintf_p(const char *_Format,va_list _ArgList) { + int __cdecl __mingw_vprintf_p(const char *,va_list); + return __mingw_vprintf_p(_Format, _ArgList); + } _CRTIMP int __cdecl _vsprintf_p(char *_Dst,size_t _MaxCount,const char *_Format,va_list _ArgList); _CRTIMP int __cdecl _scprintf_p(const char *_Format,...); _SECIMP int __cdecl _vscprintf_p(const char *_Format,va_list _ArgList); @@ -735,10 +770,7 @@ extern "C" { { return __stdio_common_vswprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _DstBuf, _DstSize, _Format, _Locale, _ArgList); } - __mingw_ovr int __cdecl vswprintf_s(wchar_t *_DstBuf, size_t _DstSize, const wchar_t *_Format, va_list _ArgList) - { - return _vswprintf_s_l(_DstBuf, _DstSize, _Format, NULL, _ArgList); - } + int __cdecl vswprintf_s(wchar_t *_DstBuf, size_t _DstSize, const wchar_t *_Format, va_list _ArgList); __mingw_ovr int __cdecl _swprintf_s_l(wchar_t *_DstBuf, size_t _DstSize, const wchar_t *_Format, _locale_t _Locale, ...) { __builtin_va_list _ArgList; @@ -784,11 +816,164 @@ extern "C" { __builtin_va_end(_ArgList); return _Ret; } + + int __cdecl __stdio_common_vswprintf_p(unsigned __int64 _Options, wchar_t *_Str, size_t _Len, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList); + int __cdecl __stdio_common_vfwprintf_p(unsigned __int64 _Options, FILE *_File, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList); + int __cdecl __stdio_common_vsnwprintf_p(unsigned __int64 _Options, wchar_t *_Str, size_t _Len, size_t _MaxCount, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList); + + __mingw_ovr int __cdecl _vsnwprintf_p_l(wchar_t *_DstBuf, size_t _DstSize, size_t _MaxCount, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList) + { + return __stdio_common_vsnwprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _DstBuf, _DstSize, _MaxCount, _Format, _Locale, _ArgList); + } + __mingw_ovr int __cdecl _vsnwprintf_p(wchar_t *_DstBuf, size_t _DstSize, size_t _MaxCount, const wchar_t *_Format, va_list _ArgList) + { + return _vsnwprintf_p_l(_DstBuf, _DstSize, _MaxCount, _Format, NULL, _ArgList); + } + __mingw_ovr int __cdecl _snwprintf_p_l(wchar_t *_DstBuf, size_t _DstSize, size_t _MaxCount, const wchar_t *_Format, _locale_t _Locale, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Locale); + _Ret = _vsnwprintf_p_l(_DstBuf, _DstSize, _MaxCount, _Format, _Locale, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int __cdecl _snwprintf_p(wchar_t *_DstBuf, size_t _DstSize, size_t _MaxCount, const wchar_t *_Format, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = _vsnwprintf_p_l(_DstBuf, _DstSize, _MaxCount, _Format, NULL, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int __cdecl _vfwprintf_p_l(FILE *_File, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList) + { + return __stdio_common_vfwprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _File, _Format, _Locale, _ArgList); + } + __mingw_ovr int __cdecl _vwprintf_p_l(const wchar_t *_Format, _locale_t _Locale, va_list _ArgList) + { + return _vfwprintf_p_l(stdout, _Format, _Locale, _ArgList); + } + __mingw_ovr int __cdecl _vfwprintf_p(FILE *_File, const wchar_t *_Format, va_list _ArgList) + { + return _vfwprintf_p_l(_File, _Format, NULL, _ArgList); + } + __mingw_ovr int __cdecl _vwprintf_p(const wchar_t *_Format, va_list _ArgList) + { + return _vfwprintf_p_l(stdout, _Format, NULL, _ArgList); + } + __mingw_ovr int __cdecl _fwprintf_p_l(FILE *_File, const wchar_t *_Format, _locale_t _Locale, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Locale); + _Ret = _vfwprintf_p_l(_File, _Format, _Locale, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int __cdecl _wprintf_p_l(const wchar_t *_Format, _locale_t _Locale, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Locale); + _Ret = _vfwprintf_p_l(stdout, _Format, _Locale, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int __cdecl _fwprintf_p(FILE *_File, const wchar_t *_Format, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = _vfwprintf_p_l(_File, _Format, NULL, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int __cdecl _wprintf_p(const wchar_t *_Format, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = _vfwprintf_p_l(stdout, _Format, NULL, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + + __mingw_ovr int __cdecl _vswprintf_p_l(wchar_t *_DstBuf, size_t _MaxCount, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList) + { + return __stdio_common_vswprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _DstBuf, _MaxCount, _Format, _Locale, _ArgList); + } + int __cdecl _vswprintf_p(wchar_t *_DstBuf, size_t _MaxCount, const wchar_t *_Format, va_list _ArgList); + __mingw_ovr int __cdecl _swprintf_p_l(wchar_t *_DstBuf, size_t _MaxCount, const wchar_t *_Format, _locale_t _Locale, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Locale); + _Ret = _vswprintf_p_l(_DstBuf, _MaxCount, _Format, _Locale, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int __cdecl _swprintf_p(wchar_t *_DstBuf, size_t _MaxCount, const wchar_t *_Format, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = _vswprintf_p_l(_DstBuf, _MaxCount, _Format, NULL, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + + __mingw_ovr int __cdecl _vscwprintf_p_l(const wchar_t *_Format, _locale_t _Locale, va_list _ArgList) + { + return __stdio_common_vswprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, NULL, 0, _Format, _Locale, _ArgList); + } + int __cdecl _vscwprintf_p(const wchar_t *_Format, va_list _ArgList); + __mingw_ovr int __cdecl _scwprintf_p_l(const wchar_t *_Format, _locale_t _Locale, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Locale); + _Ret = _vscwprintf_p_l(_Format, _Locale, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int __cdecl _scwprintf_p(const wchar_t *_Format, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = _vscwprintf_p_l(_Format, NULL, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } #else /* _UCRT */ - int __cdecl fwprintf_s(FILE *_File,const wchar_t *_Format,...); - int __cdecl wprintf_s(const wchar_t *_Format,...); - int __cdecl vfwprintf_s(FILE *_File,const wchar_t *_Format,va_list _ArgList); - int __cdecl vwprintf_s(const wchar_t *_Format,va_list _ArgList); + __mingw_ovr int fwprintf_s(FILE *_File,const wchar_t *_Format,...) { + int __cdecl __mingw_vfwprintf_s(FILE *, const wchar_t *, va_list); + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = __mingw_vfwprintf_s (_File, _Format, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int wprintf_s(const wchar_t *_Format,...) { + int __cdecl __mingw_vwprintf_s(const wchar_t *, va_list); + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = __mingw_vwprintf_s (_Format, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int vfwprintf_s(FILE *_File,const wchar_t *_Format,va_list _ArgList) { + int __cdecl __mingw_vfwprintf_s(FILE *,const wchar_t *,va_list); + return __mingw_vfwprintf_s(_File, _Format, _ArgList); + } + __mingw_ovr int vwprintf_s(const wchar_t *_Format,va_list _ArgList) { + int __cdecl __mingw_vwprintf_s(const wchar_t *,va_list); + return __mingw_vwprintf_s(_Format, _ArgList); + } int __cdecl vswprintf_s(wchar_t *_Dst,size_t _SizeInWords,const wchar_t *_Format,va_list _ArgList); @@ -829,10 +1014,32 @@ extern "C" { __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(errno_t,_wtmpnam_s,wchar_t,_DstBuf) #ifndef _UCRT - _CRTIMP int __cdecl _fwprintf_p(FILE *_File,const wchar_t *_Format,...); - _CRTIMP int __cdecl _wprintf_p(const wchar_t *_Format,...); - _CRTIMP int __cdecl _vfwprintf_p(FILE *_File,const wchar_t *_Format,va_list _ArgList); - _CRTIMP int __cdecl _vwprintf_p(const wchar_t *_Format,va_list _ArgList); + __mingw_ovr int _fwprintf_p(FILE *_File,const wchar_t *_Format,...) { + int __cdecl __mingw_vfwprintf_p(FILE *, const wchar_t *, va_list); + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = __mingw_vfwprintf_p(_File, _Format, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int _wprintf_p(const wchar_t *_Format,...) { + int __cdecl __mingw_vwprintf_p(const wchar_t *, va_list); + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = __mingw_vwprintf_p(_Format, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int _vfwprintf_p(FILE *_File,const wchar_t *_Format,va_list _ArgList) { + int __cdecl __mingw_vfwprintf_p(FILE *,const wchar_t *,va_list); + return __mingw_vfwprintf_p(_File, _Format, _ArgList); + } + __mingw_ovr int _vwprintf_p(const wchar_t *_Format,va_list _ArgList) { + int __cdecl __mingw_vwprintf_p(const wchar_t *,va_list); + return __mingw_vwprintf_p(_Format, _ArgList); + } _CRTIMP int __cdecl _swprintf_p(wchar_t *_DstBuf,size_t _MaxCount,const wchar_t *_Format,...); _SECIMP int __cdecl _vswprintf_p(wchar_t *_DstBuf,size_t _MaxCount,const wchar_t *_Format,va_list _ArgList); _CRTIMP int __cdecl _scwprintf_p(const wchar_t *_Format,...); diff --git a/mingw-w64-headers/crt/sec_api/wchar_s.h b/mingw-w64-headers/crt/sec_api/wchar_s.h index 9a3889091..2e28a306b 100644 --- a/mingw-w64-headers/crt/sec_api/wchar_s.h +++ b/mingw-w64-headers/crt/sec_api/wchar_s.h @@ -196,10 +196,7 @@ extern "C" { { return __stdio_common_vswprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _DstBuf, _DstSize, _Format, _Locale, _ArgList); } - __mingw_ovr int __cdecl vswprintf_s(wchar_t *_DstBuf, size_t _DstSize, const wchar_t *_Format, va_list _ArgList) - { - return _vswprintf_s_l(_DstBuf, _DstSize, _Format, NULL, _ArgList); - } + int __cdecl vswprintf_s(wchar_t *_DstBuf, size_t _DstSize, const wchar_t *_Format, va_list _ArgList); __mingw_ovr int __cdecl _swprintf_s_l(wchar_t *_DstBuf, size_t _DstSize, const wchar_t *_Format, _locale_t _Locale, ...) { __builtin_va_list _ArgList; @@ -246,10 +243,32 @@ extern "C" { return _Ret; } #else /* _UCRT */ - int __cdecl fwprintf_s(FILE *_File,const wchar_t *_Format,...); - int __cdecl wprintf_s(const wchar_t *_Format,...); - int __cdecl vfwprintf_s(FILE *_File,const wchar_t *_Format,va_list _ArgList); - int __cdecl vwprintf_s(const wchar_t *_Format,va_list _ArgList); + __mingw_ovr int fwprintf_s(FILE *_File,const wchar_t *_Format,...) { + int __cdecl __mingw_vfwprintf_s(FILE *, const wchar_t *, va_list); + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = __mingw_vfwprintf_s (_File, _Format, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int wprintf_s(const wchar_t *_Format,...) { + int __cdecl __mingw_vwprintf_s(const wchar_t *, va_list); + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = __mingw_vwprintf_s (_Format, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int vfwprintf_s(FILE *_File,const wchar_t *_Format,va_list _ArgList) { + int __cdecl __mingw_vfwprintf_s(FILE *,const wchar_t *,va_list); + return __mingw_vfwprintf_s(_File, _Format, _ArgList); + } + __mingw_ovr int vwprintf_s(const wchar_t *_Format,va_list _ArgList) { + int __cdecl __mingw_vwprintf_s(const wchar_t *,va_list); + return __mingw_vwprintf_s(_Format, _ArgList); + } int __cdecl vswprintf_s(wchar_t *_Dst,size_t _SizeInWords,const wchar_t *_Format,va_list _ArgList); diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h index 76fffa177..4b04bb5b3 100644 --- a/mingw-w64-headers/crt/stdio.h +++ b/mingw-w64-headers/crt/stdio.h @@ -542,10 +542,14 @@ int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_li __attribute__((__format__ (ms_printf, 2, 3))) __MINGW_ATTRIB_NONNULL(2) int __cdecl sprintf(char * __restrict__ _Dest,const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; - __attribute__((__format__ (ms_printf, 2, 0))) __MINGW_ATTRIB_NONNULL(2) - int __cdecl vfprintf(FILE * __restrict__ _File,const char * __restrict__ _Format,va_list _ArgList); - __attribute__((__format__ (ms_printf, 1, 0))) __MINGW_ATTRIB_NONNULL(1) - int __cdecl vprintf(const char * __restrict__ _Format,va_list _ArgList); + __mingw_ovr int vfprintf(FILE * __restrict__ _File,const char * __restrict__ _Format,va_list _ArgList) { + int __cdecl __mingw_vfprintf(FILE *, const char *, va_list); + return __mingw_vfprintf(_File, _Format, _ArgList); + } + __mingw_ovr int vprintf(const char * __restrict__ _Format,va_list _ArgList) { + int __cdecl __mingw_vprintf(const char *, va_list); + return __mingw_vprintf(_Format, _ArgList); + } __attribute__((__format__ (ms_printf, 2, 0))) __MINGW_ATTRIB_NONNULL(2) int __cdecl vsprintf(char * __restrict__ _Dest,const char * __restrict__ _Format,va_list _Args) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; @@ -631,9 +635,24 @@ int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_li _CRTIMP int __cdecl _flushall(void); FILE *__cdecl fopen(const char * __restrict__ _Filename,const char * __restrict__ _Mode) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; FILE *fopen64(const char * __restrict__ filename,const char * __restrict__ mode); +#ifndef _UCRT + __mingw_ovr int fputc(int _Ch,FILE *_File) { + int __cdecl __mingw_fputc(int, FILE *); + return __mingw_fputc(_Ch, _File); + } + __mingw_ovr int _fputchar(int _Ch) { + int __cdecl __mingw_fputchar(int); + return __mingw_fputchar(_Ch); + } + __mingw_ovr int fputs(const char * __restrict__ _Str,FILE * __restrict__ _File) { + int __cdecl __mingw_fputs(const char *, FILE *); + return __mingw_fputs(_Str, _File); + } +#else int __cdecl fputc(int _Ch,FILE *_File); _CRTIMP int __cdecl _fputchar(int _Ch); int __cdecl fputs(const char * __restrict__ _Str,FILE * __restrict__ _File); +#endif size_t __cdecl fread(void * __restrict__ _DstBuf,size_t _ElementSize,size_t _Count,FILE * __restrict__ _File); FILE *__cdecl freopen(const char * __restrict__ _Filename,const char * __restrict__ _Mode,FILE * __restrict__ _File) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; int __cdecl fsetpos(FILE *_File,const fpos_t *_Pos); @@ -680,7 +699,14 @@ int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_li #endif /* (defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)) */ #endif /* _FILE_OFFSET_BITS_SET_FTELLO */ +#ifndef _UCRT + __mingw_ovr size_t fwrite(const void * __restrict__ _Str,size_t _Size,size_t _Count,FILE * __restrict__ _File) { + size_t __cdecl __mingw_fwrite(const void *, size_t, size_t, FILE *); + return __mingw_fwrite(_Str, _Size, _Count, _File); + } +#else size_t __cdecl fwrite(const void * __restrict__ _Str,size_t _Size,size_t _Count,FILE * __restrict__ _File); +#endif int __cdecl getc(FILE *_File); int __cdecl getchar(void); _CRTIMP int __cdecl _getmaxstdio(void); @@ -698,9 +724,24 @@ int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_li #define pclose _pclose #endif #endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ +#ifndef _UCRT + __mingw_ovr int putc(int _Ch,FILE *_File) { + int __cdecl __mingw_putc(int, FILE *); + return __mingw_putc(_Ch, _File); + } + __mingw_ovr int putchar(int _Ch) { + int __cdecl __mingw_putchar(int); + return __mingw_putchar(_Ch); + } + __mingw_ovr int puts(const char * __restrict__ _Str) { + int __cdecl __mingw_puts(const char *); + return __mingw_puts(_Str); + } +#else int __cdecl putc(int _Ch,FILE *_File); int __cdecl putchar(int _Ch); int __cdecl puts(const char *_Str); +#endif _CRTIMP int __cdecl _putw(int _Word,FILE *_File); #ifndef _CRT_DIRECTORY_DEFINED #define _CRT_DIRECTORY_DEFINED @@ -1271,19 +1312,96 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti wint_t __cdecl fgetwc(FILE *_File); _CRTIMP wint_t __cdecl _fgetwchar(void); +#ifndef _UCRT + __mingw_ovr wint_t fputwc(wchar_t _Ch,FILE *_File) { + wint_t __cdecl __mingw_fputwc(wchar_t, FILE *); + return __mingw_fputwc(_Ch, _File); + } + __mingw_ovr wint_t _fputwchar(wchar_t _Ch) { + wint_t __cdecl __mingw_fputwchar(wchar_t); + return __mingw_fputwchar(_Ch); + } +#else wint_t __cdecl fputwc(wchar_t _Ch,FILE *_File); _CRTIMP wint_t __cdecl _fputwchar(wchar_t _Ch); +#endif wint_t __cdecl getwc(FILE *_File); wint_t __cdecl getwchar(void); +#ifndef _UCRT + __mingw_ovr wint_t putwc(wchar_t _Ch,FILE *_File) { + wint_t __cdecl __mingw_putwc(wchar_t, FILE *); + return __mingw_putwc(_Ch, _File); + } + __mingw_ovr wint_t putwchar(wchar_t _Ch) { + wint_t __cdecl __mingw_putwchar(wchar_t); + return __mingw_putwchar(_Ch); + } +#else wint_t __cdecl putwc(wchar_t _Ch,FILE *_File); wint_t __cdecl putwchar(wchar_t _Ch); +#endif wint_t __cdecl ungetwc(wint_t _Ch,FILE *_File); wchar_t *__cdecl fgetws(wchar_t * __restrict__ _Dst,int _SizeInWords,FILE * __restrict__ _File); +#ifndef _UCRT + __mingw_ovr int fputws(const wchar_t * __restrict__ _Str,FILE * __restrict__ _File) { + int __cdecl __mingw_fputws(const wchar_t *,FILE *); + return __mingw_fputws(_Str, _File); + } +#else int __cdecl fputws(const wchar_t * __restrict__ _Str,FILE * __restrict__ _File); +#endif _CRTIMP wchar_t *__cdecl _getws(wchar_t *_String) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; +#ifndef _UCRT + __mingw_ovr int _putws(const wchar_t *_Str) { + int __cdecl __mingw_putws(const wchar_t *); + return __mingw_putws(_Str); + } +#else _CRTIMP int __cdecl _putws(const wchar_t *_Str); +#endif #ifdef _UCRT + __mingw_ovr int __cdecl _vfwprintf_l(FILE *_File, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList) + { + return __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _File, _Format, _Locale, _ArgList); + } + __mingw_ovr int __cdecl _vwprintf_l(const wchar_t *_Format, _locale_t _Locale, va_list _ArgList) + { + return _vfwprintf_l(stdout, _Format, _Locale, _ArgList); + } + __mingw_ovr int __cdecl _fwprintf_l(FILE *_File, const wchar_t *_Format, _locale_t _Locale, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Locale); + _Ret = _vfwprintf_l(_File, _Format, _Locale, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int __cdecl _wprintf_l(const wchar_t *_Format, _locale_t _Locale, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Locale); + _Ret = _vfwprintf_l(stdout, _Format, _Locale, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + + __mingw_ovr int __cdecl _vscwprintf_l(const wchar_t *_Format, _locale_t _Locale, va_list _ArgList) + { + return __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, NULL, 0, _Format, _Locale, _ArgList); + } + int __cdecl _vscwprintf(const wchar_t *_Format, va_list _ArgList); + __mingw_ovr int __cdecl _scwprintf_l(const wchar_t *_Format, _locale_t _Locale, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Locale); + _Ret = _vscwprintf_l(_Format, _Locale, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } __mingw_ovr int __cdecl _scwprintf(const wchar_t * __restrict__ _Format,...) { @@ -1341,12 +1459,7 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti return __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Dest, (size_t)-1, _Format, NULL, _Args); } - __mingw_ovr - int __cdecl _vscwprintf(const wchar_t * __restrict__ _Format, va_list _ArgList) - { - int _Result = __stdio_common_vswprintf(_CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, NULL, 0, _Format, NULL, _ArgList); - return _Result < 0 ? -1 : _Result; - } + int __cdecl _vscwprintf(const wchar_t * __restrict__ _Format, va_list _ArgList); #else _CRTIMP int __cdecl _scwprintf(const wchar_t * __restrict__ _Format,...); _CRTIMP int __cdecl _swprintf_c(wchar_t * __restrict__ _DstBuf,size_t _SizeInWords,const wchar_t * __restrict__ _Format,...); @@ -1477,7 +1590,14 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti int __cdecl fgetchar(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005; int __cdecl fileno(FILE *_File) __MINGW_ATTRIB_DEPRECATED_MSVC2005; int __cdecl flushall(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005; +#ifndef _UCRT + __mingw_ovr int fputchar(int _Ch) { + int __cdecl __mingw_fputchar(int); + return __mingw_fputchar(_Ch); + } +#else int __cdecl fputchar(int _Ch) __MINGW_ATTRIB_DEPRECATED_MSVC2005; +#endif int __cdecl getw(FILE *_File) __MINGW_ATTRIB_DEPRECATED_MSVC2005; int __cdecl putw(int _Ch,FILE *_File) __MINGW_ATTRIB_DEPRECATED_MSVC2005; int __cdecl rmtmp(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005; diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h index ab7187721..7a306548c 100644 --- a/mingw-w64-headers/crt/wchar.h +++ b/mingw-w64-headers/crt/wchar.h @@ -457,6 +457,7 @@ extern FILE (* __MINGW_IMP_SYMBOL(_iob))[]; /* A pointer to an array of FILE */ #ifdef _UCRT int __cdecl __stdio_common_vswprintf_p(unsigned __int64 _Options, wchar_t *_Str, size_t _Len, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList); int __cdecl __stdio_common_vfwprintf_p(unsigned __int64 _Options, FILE *_File, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList); + int __cdecl __stdio_common_vsnwprintf_p(unsigned __int64 _Options, wchar_t *_Str, size_t _Len, size_t _MaxCount, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList); #endif #ifndef _WSTDIO_DEFINED @@ -786,17 +787,53 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti wint_t __cdecl fgetwc(FILE *_File); _CRTIMP wint_t __cdecl _fgetwchar(void); +#ifndef _UCRT + __mingw_ovr wint_t fputwc(wchar_t _Ch,FILE *_File) { + wint_t __cdecl __mingw_fputwc(wchar_t, FILE *); + return __mingw_fputwc(_Ch, _File); + } + __mingw_ovr wint_t _fputwchar(wchar_t _Ch) { + wint_t __cdecl __mingw_fputwchar(wchar_t); + return __mingw_fputwchar(_Ch); + } +#else wint_t __cdecl fputwc(wchar_t _Ch,FILE *_File); _CRTIMP wint_t __cdecl _fputwchar(wchar_t _Ch); +#endif wint_t __cdecl getwc(FILE *_File); wint_t __cdecl getwchar(void); +#ifndef _UCRT + __mingw_ovr wint_t putwc(wchar_t _Ch,FILE *_File) { + wint_t __cdecl __mingw_putwc(wchar_t, FILE *); + return __mingw_putwc(_Ch, _File); + } + __mingw_ovr wint_t putwchar(wchar_t _Ch) { + wint_t __cdecl __mingw_putwchar(wchar_t); + return __mingw_putwchar(_Ch); + } +#else wint_t __cdecl putwc(wchar_t _Ch,FILE *_File); wint_t __cdecl putwchar(wchar_t _Ch); +#endif wint_t __cdecl ungetwc(wint_t _Ch,FILE *_File); wchar_t *__cdecl fgetws(wchar_t * __restrict__ _Dst,int _SizeInWords,FILE * __restrict__ _File); +#ifndef _UCRT + __mingw_ovr int fputws(const wchar_t * __restrict__ _Str,FILE * __restrict__ _File) { + int __cdecl __mingw_fputws(const wchar_t *,FILE *); + return __mingw_fputws(_Str, _File); + } +#else int __cdecl fputws(const wchar_t * __restrict__ _Str,FILE * __restrict__ _File); +#endif _CRTIMP wchar_t *__cdecl _getws(wchar_t *_String) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; +#ifndef _UCRT + __mingw_ovr int _putws(const wchar_t *_Str) { + int __cdecl __mingw_putws(const wchar_t *); + return __mingw_putws(_Str); + } +#else _CRTIMP int __cdecl _putws(const wchar_t *_Str); +#endif #ifdef _UCRT __mingw_ovr @@ -1030,10 +1067,7 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti { return __stdio_common_vswprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _DstBuf, _MaxCount, _Format, _Locale, _ArgList); } - __mingw_ovr int __cdecl _vswprintf_p(wchar_t *_DstBuf, size_t _MaxCount, const wchar_t *_Format, va_list _ArgList) - { - return _vswprintf_p_l(_DstBuf, _MaxCount, _Format, NULL, _ArgList); - } + int __cdecl _vswprintf_p(wchar_t *_DstBuf, size_t _MaxCount, const wchar_t *_Format, va_list _ArgList); __mingw_ovr int __cdecl _swprintf_p_l(wchar_t *_DstBuf, size_t _MaxCount, const wchar_t *_Format, _locale_t _Locale, ...) { __builtin_va_list _ArgList; @@ -1071,10 +1105,7 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti { return __stdio_common_vswprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, NULL, 0, _Format, _Locale, _ArgList); } - __mingw_ovr int __cdecl _vscwprintf_p(const wchar_t *_Format, va_list _ArgList) - { - return _vscwprintf_p_l(_Format, NULL, _ArgList); - } + int __cdecl _vscwprintf_p(const wchar_t *_Format, va_list _ArgList); __mingw_ovr int __cdecl _scwprintf_p_l(const wchar_t *_Format, _locale_t _Locale, ...) { __builtin_va_list _ArgList; @@ -1098,10 +1129,7 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti { return __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, NULL, 0, _Format, _Locale, _ArgList); } - __mingw_ovr int __cdecl _vscwprintf(const wchar_t *_Format, va_list _ArgList) - { - return _vscwprintf_l(_Format, NULL, _ArgList); - } + int __cdecl _vscwprintf(const wchar_t *_Format, va_list _ArgList); __mingw_ovr int __cdecl _scwprintf_l(const wchar_t *_Format, _locale_t _Locale, ...) { __builtin_va_list _ArgList; @@ -1155,11 +1183,60 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti __builtin_va_end(_ArgList); return _Ret; } + + __mingw_ovr int __cdecl _vsnwprintf_p_l(wchar_t *_DstBuf, size_t _DstSize, size_t _MaxCount, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList) + { + return __stdio_common_vsnwprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _DstBuf, _DstSize, _MaxCount, _Format, _Locale, _ArgList); + } + __mingw_ovr int __cdecl _vsnwprintf_p(wchar_t *_DstBuf, size_t _DstSize, size_t _MaxCount, const wchar_t *_Format, va_list _ArgList) + { + return _vsnwprintf_p_l(_DstBuf, _DstSize, _MaxCount, _Format, NULL, _ArgList); + } + __mingw_ovr int __cdecl _snwprintf_p_l(wchar_t *_DstBuf, size_t _DstSize, size_t _MaxCount, const wchar_t *_Format, _locale_t _Locale, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Locale); + _Ret = _vsnwprintf_p_l(_DstBuf, _DstSize, _MaxCount, _Format, _Locale, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int __cdecl _snwprintf_p(wchar_t *_DstBuf, size_t _DstSize, size_t _MaxCount, const wchar_t *_Format, ...) + { + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = _vsnwprintf_p_l(_DstBuf, _DstSize, _MaxCount, _Format, NULL, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } #else /* _UCRT */ - _CRTIMP int __cdecl _fwprintf_p(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...); - _CRTIMP int __cdecl _wprintf_p(const wchar_t * __restrict__ _Format,...); - _CRTIMP int __cdecl _vfwprintf_p(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,va_list _ArgList); - _CRTIMP int __cdecl _vwprintf_p(const wchar_t * __restrict__ _Format,va_list _ArgList); + __mingw_ovr int _fwprintf_p(FILE *_File,const wchar_t *_Format,...) { + int __cdecl __mingw_vfwprintf_p(FILE *, const wchar_t *, va_list); + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = __mingw_vfwprintf_p(_File, _Format, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int _wprintf_p(const wchar_t *_Format,...) { + int __cdecl __mingw_vwprintf_p(const wchar_t *, va_list); + __builtin_va_list _ArgList; + int _Ret; + __builtin_va_start(_ArgList, _Format); + _Ret = __mingw_vwprintf_p(_Format, _ArgList); + __builtin_va_end(_ArgList); + return _Ret; + } + __mingw_ovr int _vfwprintf_p(FILE *_File,const wchar_t *_Format,va_list _ArgList) { + int __cdecl __mingw_vfwprintf_p(FILE *,const wchar_t *,va_list); + return __mingw_vfwprintf_p(_File, _Format, _ArgList); + } + __mingw_ovr int _vwprintf_p(const wchar_t *_Format,va_list _ArgList) { + int __cdecl __mingw_vwprintf_p(const wchar_t *,va_list); + return __mingw_vwprintf_p(_Format, _ArgList); + } _CRTIMP int __cdecl _swprintf_p(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,...); _SECIMP int __cdecl _vswprintf_p(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,va_list _ArgList); _CRTIMP int __cdecl _scwprintf_p(const wchar_t * __restrict__ _Format,...); -- 2.37.1
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public