mirror of
https://git.code.sf.net/p/mingw-w64/mingw-w64
synced 2024-11-23 01:44:43 +08:00
c50df03570
ISO C does not define (v)snwprintf() function. But ISO C11 in optional Appendix K defines (v)snwprintf_s() function which has same behavior as non-wide ISO C11 Appendix K (v)snprintf_s() function (which is secure variant of (v)snprintf()). Function (v)snwprintf() is not provided by any MS CRT library and neither by any MS header file. mingw32 runtime and mingw-w64 runtime since beginning provide function named (v)snwprintf (without leading underscore) and define it under symbol name __mingw_(v)snwprintf. This function differs from ISO C (v)swprintf() just in return value. ISO C (v)swprintf() when buffer is too small returns negative value but this (v)snwprintf() returns size of buffer in wide characters, similarly to non-wide ISO C (v)snprintf() function, and also similarly to ISO C11 Annex K (v)snwprintf_s(). This non-ISO (v)snwprintf() and both ISO C (v)snwprintf_s() and (v)snprintf() always fill trailing nul character. But when __USE_MINGW_ANSI_STDIO=0 the (v)snwprintf() is redirected to __ms_(v)snwprintf() function, which is just wrapper around msvcrt _vsnwprintf() function. And msvcrt _vsnwprintf() function does not fill trailing nul character and does not return required buffer size when output buffer is too small. So fix __ms_(v)snwprintf() functions to properly fill trailing nul character and return required size of bufer, like ISO C vsnprintf(). Also adjust header files and remove wrong symbol aliases for (v)snwprintf symbols from def files. This will make API of (v)snwprintf() function compatible for both __USE_MINGW_ANSI_STDIO=0 and __USE_MINGW_ANSI_STDIO=1 modes and also to mimics API of ISO C (v)snwprintf_s() function. Signed-off-by: Martin Storsjö <martin@martin.st> |
||
---|---|---|
build-aux | ||
COPYING.MinGW-w64 | ||
COPYING.MinGW-w64-runtime | ||
mingw-w64-crt | ||
mingw-w64-doc | ||
mingw-w64-headers | ||
mingw-w64-libraries | ||
mingw-w64-tools | ||
.gitignore | ||
aclocal.m4 | ||
AUTHORS | ||
config.h.in | ||
configure | ||
configure.ac | ||
COPYING | ||
DISCLAIMER | ||
DISCLAIMER.PD | ||
Makefile.am | ||
Makefile.in |