Ensure that all those __ms_* scanf functions calls __stdio_common_* scanf
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_*scanf function always with
_CRT_INTERNAL_SCANF_LEGACY_MSVCRT_COMPATIBILITY option.

And for wide functions use _CRT_INTERNAL_SCANF_LEGACY_WIDE_SPECIFIERS
option which ensures that %s for wide functions expects wide wchar_t*
string (instead of char*).
---
 mingw-w64-crt/Makefile.am                | 12 ++++++++++++
 mingw-w64-crt/stdio/ucrt/__ms_fscanf.c   | 22 ++++++++++++++++++++++
 mingw-w64-crt/stdio/ucrt/__ms_fwscanf.c  | 22 ++++++++++++++++++++++
 mingw-w64-crt/stdio/ucrt/__ms_scanf.c    | 22 ++++++++++++++++++++++
 mingw-w64-crt/stdio/ucrt/__ms_sscanf.c   | 22 ++++++++++++++++++++++
 mingw-w64-crt/stdio/ucrt/__ms_swscanf.c  | 22 ++++++++++++++++++++++
 mingw-w64-crt/stdio/ucrt/__ms_vfscanf.c  | 17 +++++++++++++++++
 mingw-w64-crt/stdio/ucrt/__ms_vfwscanf.c | 17 +++++++++++++++++
 mingw-w64-crt/stdio/ucrt/__ms_vscanf.c   | 16 ++++++++++++++++
 mingw-w64-crt/stdio/ucrt/__ms_vsscanf.c  | 17 +++++++++++++++++
 mingw-w64-crt/stdio/ucrt/__ms_vswscanf.c | 17 +++++++++++++++++
 mingw-w64-crt/stdio/ucrt/__ms_vwscanf.c  | 16 ++++++++++++++++
 mingw-w64-crt/stdio/ucrt/__ms_wscanf.c   | 22 ++++++++++++++++++++++
 13 files changed, 244 insertions(+)
 create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_fscanf.c
 create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_fwscanf.c
 create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_scanf.c
 create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_sscanf.c
 create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_swscanf.c
 create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vfscanf.c
 create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vfwscanf.c
 create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vscanf.c
 create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vsscanf.c
 create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vswscanf.c
 create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_vwscanf.c
 create mode 100644 mingw-w64-crt/stdio/ucrt/__ms_wscanf.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index f48661319a94..aae597f6eee0 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -396,21 +396,33 @@ src_ucrtbase=\
   stdio/ucrt_fprintf.c \
   stdio/ucrt_fscanf.c \
   stdio/ucrt/__ms_fprintf.c \
+  stdio/ucrt/__ms_fscanf.c \
   stdio/ucrt/__ms_fwprintf.c \
+  stdio/ucrt/__ms_fwscanf.c \
   stdio/ucrt/__ms_printf.c \
+  stdio/ucrt/__ms_scanf.c \
   stdio/ucrt/__ms_snprintf.c \
   stdio/ucrt/__ms_snwprintf.c \
   stdio/ucrt/__ms_sprintf.c \
+  stdio/ucrt/__ms_sscanf.c \
   stdio/ucrt/__ms_swprintf.c \
+  stdio/ucrt/__ms_swscanf.c \
   stdio/ucrt/__ms_vfprintf.c \
+  stdio/ucrt/__ms_vfscanf.c \
   stdio/ucrt/__ms_vfwprintf.c \
+  stdio/ucrt/__ms_vfwscanf.c \
   stdio/ucrt/__ms_vprintf.c \
+  stdio/ucrt/__ms_vscanf.c \
   stdio/ucrt/__ms_vsnprintf.c \
   stdio/ucrt/__ms_vsnwprintf.c \
   stdio/ucrt/__ms_vsprintf.c \
+  stdio/ucrt/__ms_vsscanf.c \
   stdio/ucrt/__ms_vswprintf.c \
+  stdio/ucrt/__ms_vswscanf.c \
   stdio/ucrt/__ms_vwprintf.c \
+  stdio/ucrt/__ms_vwscanf.c \
   stdio/ucrt/__ms_wprintf.c \
+  stdio/ucrt/__ms_wscanf.c \
   stdio/ucrt_fwprintf.c \
   stdio/ucrt_printf.c \
   stdio/ucrt_scanf.c \
diff --git a/mingw-w64-crt/stdio/ucrt/__ms_fscanf.c 
b/mingw-w64-crt/stdio/ucrt/__ms_fscanf.c
new file mode 100644
index 000000000000..74f00006b746
--- /dev/null
+++ b/mingw-w64-crt/stdio/ucrt/__ms_fscanf.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_fscanf(FILE * restrict file, const char * restrict format, 
...)
+{
+  va_list ap;
+  int ret;
+  va_start(ap, format);
+  ret = __ms_vfscanf(file, format, ap);
+  va_end(ap);
+  return ret;
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(__ms_fscanf))(FILE * restrict, const char * 
restrict, ...) = __ms_fscanf;
diff --git a/mingw-w64-crt/stdio/ucrt/__ms_fwscanf.c 
b/mingw-w64-crt/stdio/ucrt/__ms_fwscanf.c
new file mode 100644
index 000000000000..f18fdfb9252f
--- /dev/null
+++ b/mingw-w64-crt/stdio/ucrt/__ms_fwscanf.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_fwscanf(FILE * restrict file, const wchar_t * restrict 
format, ...)
+{
+  va_list ap;
+  int ret;
+  va_start(ap, format);
+  ret = __ms_vfwscanf(file, format, ap);
+  va_end(ap);
+  return ret;
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(__ms_fwscanf))(FILE * restrict, const wchar_t 
* restrict, ...) = __ms_fwscanf;
diff --git a/mingw-w64-crt/stdio/ucrt/__ms_scanf.c 
b/mingw-w64-crt/stdio/ucrt/__ms_scanf.c
new file mode 100644
index 000000000000..e9b84a89058b
--- /dev/null
+++ b/mingw-w64-crt/stdio/ucrt/__ms_scanf.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_scanf(const char * restrict format, ...)
+{
+  va_list ap;
+  int ret;
+  va_start(ap, format);
+  ret = __ms_vscanf(format, ap);
+  va_end(ap);
+  return ret;
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(__ms_scanf))(const char * restrict, ...) = 
__ms_scanf;
diff --git a/mingw-w64-crt/stdio/ucrt/__ms_sscanf.c 
b/mingw-w64-crt/stdio/ucrt/__ms_sscanf.c
new file mode 100644
index 000000000000..bb970b98e4c4
--- /dev/null
+++ b/mingw-w64-crt/stdio/ucrt/__ms_sscanf.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_sscanf(const char * restrict str, const char * restrict 
format, ...)
+{
+  va_list ap;
+  int ret;
+  va_start(ap, format);
+  ret = __ms_vsscanf(str, format, ap);
+  va_end(ap);
+  return ret;
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(__ms_sscanf))(const char * restrict, const 
char * restrict, ...) = __ms_sscanf;
diff --git a/mingw-w64-crt/stdio/ucrt/__ms_swscanf.c 
b/mingw-w64-crt/stdio/ucrt/__ms_swscanf.c
new file mode 100644
index 000000000000..a969e8294ee8
--- /dev/null
+++ b/mingw-w64-crt/stdio/ucrt/__ms_swscanf.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_swscanf(const wchar_t * restrict str, const wchar_t * 
restrict format, ...)
+{
+  va_list ap;
+  int ret;
+  va_start(ap, format);
+  ret = __ms_vswscanf(str, format, ap);
+  va_end(ap);
+  return ret;
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(__ms_swscanf))(const wchar_t * restrict, 
const wchar_t * restrict, ...) = __ms_swscanf;
diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vfscanf.c 
b/mingw-w64-crt/stdio/ucrt/__ms_vfscanf.c
new file mode 100644
index 000000000000..ba642f69cad7
--- /dev/null
+++ b/mingw-w64-crt/stdio/ucrt/__ms_vfscanf.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_vfscanf(FILE * restrict file, const char * restrict format, 
va_list ap)
+{
+  /* __ms_* scanf functions works in legacy msvcrt mode for compatibility with 
msvcrt.dll and tchar.h macros */
+  return 
__stdio_common_vfscanf(_CRT_INTERNAL_SCANF_LEGACY_MSVCRT_COMPATIBILITY, file, 
format, NULL, ap);
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vfscanf))(FILE * restrict, const char * 
restrict, va_list) = __ms_vfscanf;
diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vfwscanf.c 
b/mingw-w64-crt/stdio/ucrt/__ms_vfwscanf.c
new file mode 100644
index 000000000000..56c81588b6ac
--- /dev/null
+++ b/mingw-w64-crt/stdio/ucrt/__ms_vfwscanf.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_vfwscanf(FILE * restrict file, const wchar_t * restrict 
format, va_list ap)
+{
+  /* __ms_* scanf functions works in legacy msvcrt mode for compatibility with 
msvcrt.dll and tchar.h macros */
+  return 
__stdio_common_vfwscanf(_CRT_INTERNAL_SCANF_LEGACY_MSVCRT_COMPATIBILITY | 
_CRT_INTERNAL_SCANF_LEGACY_WIDE_SPECIFIERS, file, format, NULL, ap);
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vfwscanf))(FILE * restrict, const 
wchar_t * restrict, va_list) = __ms_vfwscanf;
diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vscanf.c 
b/mingw-w64-crt/stdio/ucrt/__ms_vscanf.c
new file mode 100644
index 000000000000..50c1990df644
--- /dev/null
+++ b/mingw-w64-crt/stdio/ucrt/__ms_vscanf.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_vscanf(const char * restrict format, va_list ap)
+{
+  return __ms_vfscanf(stdin, format, ap);
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vscanf))(const char * restrict, va_list) 
= __ms_vscanf;
diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vsscanf.c 
b/mingw-w64-crt/stdio/ucrt/__ms_vsscanf.c
new file mode 100644
index 000000000000..cca77bbd8221
--- /dev/null
+++ b/mingw-w64-crt/stdio/ucrt/__ms_vsscanf.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_vsscanf(const char * restrict str, const char * restrict 
format, va_list ap)
+{
+  /* __ms_* scanf functions works in legacy msvcrt mode for compatibility with 
msvcrt.dll and tchar.h macros */
+  return 
__stdio_common_vsscanf(_CRT_INTERNAL_SCANF_LEGACY_MSVCRT_COMPATIBILITY, str, 
(size_t)-1, format, NULL, ap);
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vsscanf))(const char * restrict, const 
char * restrict, va_list) = __ms_vsscanf;
diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vswscanf.c 
b/mingw-w64-crt/stdio/ucrt/__ms_vswscanf.c
new file mode 100644
index 000000000000..7652cca3fae8
--- /dev/null
+++ b/mingw-w64-crt/stdio/ucrt/__ms_vswscanf.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_vswscanf(const wchar_t * restrict str, const wchar_t * 
restrict format, va_list ap)
+{
+  /* __ms_* scanf functions works in legacy msvcrt mode for compatibility with 
msvcrt.dll and tchar.h macros */
+  return 
__stdio_common_vswscanf(_CRT_INTERNAL_SCANF_LEGACY_MSVCRT_COMPATIBILITY | 
_CRT_INTERNAL_SCANF_LEGACY_WIDE_SPECIFIERS, str, (size_t)-1, format, NULL, ap);
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vswscanf))(const wchar_t * restrict, 
const wchar_t * restrict, va_list) = __ms_vswscanf;
diff --git a/mingw-w64-crt/stdio/ucrt/__ms_vwscanf.c 
b/mingw-w64-crt/stdio/ucrt/__ms_vwscanf.c
new file mode 100644
index 000000000000..ee94d74a6739
--- /dev/null
+++ b/mingw-w64-crt/stdio/ucrt/__ms_vwscanf.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_vwscanf(const wchar_t * restrict format, va_list ap)
+{
+  return __ms_vfwscanf(stdin, format, ap);
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(__ms_vwscanf))(const wchar_t * restrict, 
va_list) = __ms_vwscanf;
diff --git a/mingw-w64-crt/stdio/ucrt/__ms_wscanf.c 
b/mingw-w64-crt/stdio/ucrt/__ms_wscanf.c
new file mode 100644
index 000000000000..de6a26e5abf9
--- /dev/null
+++ b/mingw-w64-crt/stdio/ucrt/__ms_wscanf.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_wscanf(const wchar_t * restrict format, ...)
+{
+  va_list ap;
+  int ret;
+  va_start(ap, format);
+  ret = __ms_vwscanf(format, ap);
+  va_end(ap);
+  return ret;
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(__ms_wscanf))(const wchar_t * restrict, ...) 
= __ms_wscanf;
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to