Ensure that all those __ms_* printf functions calls __stdio_common_* printf functions with compatibility options, as it is required for msvcrt.dll compatibility and also because tchar.h macros depends on that old legacy behavior.
For compatibility call __stdio_common_*printf function always with _CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY and _CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS options. And for wide functions use _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS option which ensures that %s for wide functions expects wide wchar_t* string (instead of char*). Functions (v)snprintf() and (v)snwprintf() needs additional _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR option which ensures that return value contains number of characters required to format whole string. --- mingw-w64-crt/Makefile.am | 18 +++++++++++++-- .../__ms_fprintf.c} | 2 +- .../__ms_fwprintf.c} | 10 ++++----- mingw-w64-crt/stdio/ucrt/__ms_printf.c | 22 +++++++++++++++++++ mingw-w64-crt/stdio/ucrt/__ms_snprintf.c | 22 +++++++++++++++++++ mingw-w64-crt/stdio/ucrt/__ms_snwprintf.c | 22 +++++++++++++++++++ mingw-w64-crt/stdio/ucrt/__ms_sprintf.c | 22 +++++++++++++++++++ mingw-w64-crt/stdio/ucrt/__ms_swprintf.c | 22 +++++++++++++++++++ mingw-w64-crt/stdio/ucrt/__ms_vfprintf.c | 17 ++++++++++++++ mingw-w64-crt/stdio/ucrt/__ms_vfwprintf.c | 17 ++++++++++++++ mingw-w64-crt/stdio/ucrt/__ms_vprintf.c | 16 ++++++++++++++ mingw-w64-crt/stdio/ucrt/__ms_vsnprintf.c | 17 ++++++++++++++ mingw-w64-crt/stdio/ucrt/__ms_vsnwprintf.c | 17 ++++++++++++++ mingw-w64-crt/stdio/ucrt/__ms_vsprintf.c | 16 ++++++++++++++ mingw-w64-crt/stdio/ucrt/__ms_vswprintf.c | 17 ++++++++++++++ mingw-w64-crt/stdio/ucrt/__ms_vwprintf.c | 16 ++++++++++++++ mingw-w64-crt/stdio/ucrt/__ms_wprintf.c | 22 +++++++++++++++++++ 17 files changed, 286 insertions(+), 9 deletions(-) rename mingw-w64-crt/stdio/{ucrt_ms_fprintf.c => ucrt/__ms_fprintf.c} (85%) rename mingw-w64-crt/stdio/{ucrt_ms_fwprintf.c => ucrt/__ms_fwprintf.c} (47%) create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_printf.c create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_snprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_snwprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_sprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_swprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vfprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vfwprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vsnprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vsnwprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vsprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vswprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vwprintf.c create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_wprintf.c diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 5f5655b3b96b..f48661319a94 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -395,8 +395,22 @@ src_ucrtbase=\ misc/ucrt-access.c \ stdio/ucrt_fprintf.c \ stdio/ucrt_fscanf.c \ - stdio/ucrt_ms_fprintf.c \ - stdio/ucrt_ms_fwprintf.c \ + stdio/ucrt/__ms_fprintf.c \ + stdio/ucrt/__ms_fwprintf.c \ + stdio/ucrt/__ms_printf.c \ + stdio/ucrt/__ms_snprintf.c \ + stdio/ucrt/__ms_snwprintf.c \ + stdio/ucrt/__ms_sprintf.c \ + stdio/ucrt/__ms_swprintf.c \ + stdio/ucrt/__ms_vfprintf.c \ + stdio/ucrt/__ms_vfwprintf.c \ + stdio/ucrt/__ms_vprintf.c \ + stdio/ucrt/__ms_vsnprintf.c \ + stdio/ucrt/__ms_vsnwprintf.c \ + stdio/ucrt/__ms_vsprintf.c \ + stdio/ucrt/__ms_vswprintf.c \ + stdio/ucrt/__ms_vwprintf.c \ + stdio/ucrt/__ms_wprintf.c \ stdio/ucrt_fwprintf.c \ stdio/ucrt_printf.c \ stdio/ucrt_scanf.c \ diff --git a/mingw-w64-crt/stdio/ucrt_ms_fprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_fprintf.c similarity index 85% rename from mingw-w64-crt/stdio/ucrt_ms_fprintf.c rename to mingw-w64-crt/stdio/ucrt/__ms_fprintf.c index 15588bcae709..2df228a3d946 100644 --- a/mingw-w64-crt/stdio/ucrt_ms_fprintf.c +++ b/mingw-w64-crt/stdio/ucrt/__ms_fprintf.c @@ -15,7 +15,7 @@ int __cdecl __ms_fprintf(FILE * restrict file, const char * restrict format, ... va_list ap; int ret; va_start(ap, format); - ret = __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, file, format, NULL, ap); + ret = __ms_vfprintf(file, format, ap); va_end(ap); return ret; } diff --git a/mingw-w64-crt/stdio/ucrt_ms_fwprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_fwprintf.c similarity index 47% rename from mingw-w64-crt/stdio/ucrt_ms_fwprintf.c rename to mingw-w64-crt/stdio/ucrt/__ms_fwprintf.c index f44c78d941e9..13b560bee87f 100644 --- a/mingw-w64-crt/stdio/ucrt_ms_fwprintf.c +++ b/mingw-w64-crt/stdio/ucrt/__ms_fwprintf.c @@ -10,15 +10,13 @@ #include <stdio.h> #include <stdarg.h> -// 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, ...) +int __cdecl __ms_fwprintf(FILE * restrict file, const wchar_t * restrict format, ...) { va_list ap; int ret; - va_start(ap, fmt); - ret = __stdio_common_vfwprintf(_CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS, file, fmt, NULL, ap); + va_start(ap, format); + ret = __ms_vfwprintf(file, format, ap); va_end(ap); return ret; } -int __cdecl (*__MINGW_IMP_SYMBOL(__ms_fwprintf))(FILE *, const wchar_t *, ...) = __ms_fwprintf; +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_fwprintf))(FILE * restrict, const wchar_t * restrict, ...) = __ms_fwprintf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_printf.c b/mingw-w64-crt/stdio/ucrt/__ms_printf.c new file mode 100644 index 000000000000..f982e5dba56e --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_printf.c @@ -0,0 +1,22 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> +#include <stdarg.h> + +int __cdecl __ms_printf(const char * restrict format, ...) +{ + va_list ap; + int ret; + va_start(ap, format); + ret = __ms_vprintf(format, ap); + va_end(ap); + return ret; +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_printf))(const char * restrict, ...) = __ms_printf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_snprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_snprintf.c new file mode 100644 index 000000000000..fed6c23829b4 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_snprintf.c @@ -0,0 +1,22 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> +#include <stdarg.h> + +int __cdecl __ms_snprintf(char * restrict str, size_t size, const char * restrict format, ...) +{ + va_list ap; + int ret; + va_start(ap, format); + ret = __ms_vsnprintf(str, size, format, ap); + va_end(ap); + return ret; +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_snprintf))(char * restrict, size_t, const char * restrict, ...) = __ms_snprintf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_snwprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_snwprintf.c new file mode 100644 index 000000000000..50a567250deb --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_snwprintf.c @@ -0,0 +1,22 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> +#include <stdarg.h> + +int __cdecl __ms_snwprintf(wchar_t * restrict str, size_t size, const wchar_t * restrict format, ...) +{ + va_list ap; + int ret; + va_start(ap, format); + ret = __ms_vsnwprintf(str, size, format, ap); + va_end(ap); + return ret; +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_snwprintf))(wchar_t * restrict, size_t, const wchar_t * restrict, ...) = __ms_snwprintf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_sprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_sprintf.c new file mode 100644 index 000000000000..5ac55551e29d --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_sprintf.c @@ -0,0 +1,22 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> +#include <stdarg.h> + +int __cdecl __ms_sprintf(char * restrict str, const char * restrict format, ...) +{ + va_list ap; + int ret; + va_start(ap, format); + ret = __ms_vsnprintf(str, (size_t)-1, format, ap); + va_end(ap); + return ret; +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_sprintf))(char * restrict, const char * restrict, ...) = __ms_sprintf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_swprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_swprintf.c new file mode 100644 index 000000000000..bf05043e9bd2 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_swprintf.c @@ -0,0 +1,22 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> +#include <stdarg.h> + +int __cdecl __ms_swprintf(wchar_t * restrict str, size_t size, const wchar_t * restrict format, ...) +{ + va_list ap; + int ret; + va_start(ap, format); + ret = __ms_vswprintf(str, size, format, ap); + va_end(ap); + return ret; +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_swprintf))(wchar_t * restrict, size_t, const wchar_t * restrict, ...) = __ms_swprintf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vfprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_vfprintf.c new file mode 100644 index 000000000000..c53788230df7 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_vfprintf.c @@ -0,0 +1,17 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> + +int __cdecl __ms_vfprintf(FILE * restrict file, const char * restrict format, va_list ap) +{ + /* __ms_* printf functions works in legacy msvcrt mode for compatibility with msvcrt.dll and tchar.h macros */ + return __stdio_common_vfprintf(_CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY | _CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS, file, format, NULL, ap); +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vfprintf))(FILE * restrict, const char * restrict, va_list) = __ms_vfprintf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vfwprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_vfwprintf.c new file mode 100644 index 000000000000..f3ba5a60dda8 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_vfwprintf.c @@ -0,0 +1,17 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> + +int __cdecl __ms_vfwprintf(FILE * restrict file, const wchar_t * restrict format, va_list ap) +{ + /* __ms_* printf functions works in legacy msvcrt mode for compatibility with msvcrt.dll and tchar.h macros */ + return __stdio_common_vfwprintf(_CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY | _CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS | _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS, file, format, NULL, ap); +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vfwprintf))(FILE * restrict, const wchar_t * restrict, va_list) = __ms_vfwprintf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_vprintf.c new file mode 100644 index 000000000000..a9bfc36d298e --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_vprintf.c @@ -0,0 +1,16 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> + +int __cdecl __ms_vprintf(const char * restrict format, va_list ap) +{ + return __ms_vfprintf(stdout, format, ap); +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vprintf))(const char * restrict, va_list) = __ms_vprintf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vsnprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_vsnprintf.c new file mode 100644 index 000000000000..9bc1cbad6568 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_vsnprintf.c @@ -0,0 +1,17 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> + +int __cdecl __ms_vsnprintf(char * restrict str, size_t size, const char * restrict format, va_list ap) +{ + /* __ms_* printf functions works in legacy msvcrt mode for compatibility with msvcrt.dll and tchar.h macros */ + return __stdio_common_vsprintf(_CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY | _CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, str, size, format, NULL, ap); +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vsnprintf))(char * restrict, size_t, const char * restrict, va_list) = __ms_vsnprintf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vsnwprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_vsnwprintf.c new file mode 100644 index 000000000000..f1f20cdeb4e4 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_vsnwprintf.c @@ -0,0 +1,17 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> + +int __cdecl __ms_vsnwprintf(wchar_t * restrict str, size_t size, const wchar_t * restrict format, va_list ap) +{ + /* __ms_* printf functions works in legacy msvcrt mode for compatibility with msvcrt.dll and tchar.h macros */ + return __stdio_common_vswprintf(_CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY | _CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS | _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, str, size, format, NULL, ap); +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vsnwprintf))(wchar_t * restrict, size_t, const wchar_t * restrict, va_list) = __ms_vsnwprintf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vsprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_vsprintf.c new file mode 100644 index 000000000000..1823ddffa173 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_vsprintf.c @@ -0,0 +1,16 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> + +int __cdecl __ms_vsprintf(char * restrict str, const char * restrict format, va_list ap) +{ + return __ms_vsnprintf(str, (size_t)-1, format, ap); +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vsprintf))(char * restrict, const char * restrict, va_list) = __ms_vsprintf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vswprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_vswprintf.c new file mode 100644 index 000000000000..ab69f4f8b64f --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_vswprintf.c @@ -0,0 +1,17 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> + +int __cdecl __ms_vswprintf(wchar_t * restrict str, size_t size, const wchar_t * restrict format, va_list ap) +{ + /* __ms_* printf functions works in legacy msvcrt mode for compatibility with msvcrt.dll and tchar.h macros */ + return __stdio_common_vswprintf(_CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY | _CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS | _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS, str, size, format, NULL, ap); +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vswprintf))(wchar_t * restrict, size_t, const wchar_t * restrict, va_list) = __ms_vswprintf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vwprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_vwprintf.c new file mode 100644 index 000000000000..0481cb102fd4 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_vwprintf.c @@ -0,0 +1,16 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> + +int __cdecl __ms_vwprintf(const wchar_t * restrict format, va_list ap) +{ + return __ms_vfwprintf(stdout, format, ap); +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vwprintf))(const wchar_t * restrict, va_list) = __ms_vwprintf; diff --git a/mingw-w64-crt/stdio/ucrt/__ms_wprintf.c b/mingw-w64-crt/stdio/ucrt/__ms_wprintf.c new file mode 100644 index 000000000000..5e96f182bce7 --- /dev/null +++ b/mingw-w64-crt/stdio/ucrt/__ms_wprintf.c @@ -0,0 +1,22 @@ +/** + * 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. + */ + +#undef __MSVCRT_VERSION__ +#define _UCRT + +#include <stdio.h> +#include <stdarg.h> + +int __cdecl __ms_wprintf(const wchar_t * restrict format, ...) +{ + va_list ap; + int ret; + va_start(ap, format); + ret = __ms_vwprintf(format, ap); + va_end(ap); + return ret; +} +int __cdecl (*__MINGW_IMP_SYMBOL(__ms_wprintf))(const wchar_t * restrict, ...) = __ms_wprintf; -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public