Go to file
Pali Rohár c50df03570 crt: Fix non-ISO (v)snwprintf() functions when __USE_MINGW_ANSI_STDIO=0
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>
2024-11-15 23:54:11 +02:00
build-aux Regenerate configure with autoconf 2.72 2024-01-09 22:26:23 +08:00
COPYING.MinGW-w64 Remove Fixme about csq.h 2010-02-23 15:17:58 +00:00
COPYING.MinGW-w64-runtime Add 2011-2013 to copyright years 2013-02-26 20:28:23 +00:00
mingw-w64-crt crt: Fix non-ISO (v)snwprintf() functions when __USE_MINGW_ANSI_STDIO=0 2024-11-15 23:54:11 +02:00
mingw-w64-doc doc: ucrt-vs-msvcrt.txt: Update information about CRT options and links how to obtain UCRT 2024-09-02 23:17:51 +03:00
mingw-w64-headers crt: Fix non-ISO (v)snwprintf() functions when __USE_MINGW_ANSI_STDIO=0 2024-11-15 23:54:11 +02:00
mingw-w64-libraries winpthreads: also use SetThreadDescription to set thread name 2024-10-29 22:39:01 +08:00
mingw-w64-tools widl: Import Wine version wine-9.20. 2024-10-18 23:16:01 +02:00
.gitignore winpthreads: Ignore MSVC object files and Autotools generated files 2023-12-19 15:25:13 +02:00
aclocal.m4 Regenerate configure with autoconf 2.72 2024-01-09 22:26:23 +08:00
AUTHORS Merge commit '954b97bcfc515152cb5e666411d3ca0b256d589b' 2019-06-03 10:37:03 +02:00
config.h.in Add top level configury system 2010-02-24 17:55:02 +00:00
configure Regenerate configure with autoconf 2.72 2024-01-09 22:26:23 +08:00
configure.ac build: enable specific tools and libraries 2017-11-06 23:05:00 +00:00
COPYING Add 2013 as copyright year. 2013-02-26 20:29:09 +00:00
DISCLAIMER removed svn:executable property. 2010-01-15 20:22:39 +00:00
DISCLAIMER.PD Replace 'w64 mingw-runtime' by 'mingw-w64 runtime' 2012-06-28 15:40:59 +00:00
Makefile.am build: autoconf: support winpthreads library 2017-10-07 23:36:26 +00:00
Makefile.in Regenerate autotools scripts with automake 1.16.5 2023-11-17 13:14:02 +08:00