mirror of
https://git.code.sf.net/p/mingw-w64/mingw-w64
synced 2024-11-26 19:33:27 +08:00
bafccb49a0
All non-UCRT crt library versions provide wcstok symbol which is not C95+ compatible. Its function prototype is missing the third argument. In UCRT version this function without third argument is named _wcstok(). So rename wcstok symbol to _wcstok in all non-UCRT import libraries for compatibility with UCRT. msvcr80+ provides wcstok_s symbol which is C95+ compatible wcstok() function. msvcr80+ wcstok_s() function has same function prototype as C95+ wcstok() and the only difference between MS wcstok_s and C95 wcstok is that MS wcstok_s validates parameters and sets errno. C95 version has undefined behavior when called with invalid parameters (e.g. Linux version crashes). So add appropriate aliases of wcstok_s in msvcr80+ import libraries to have C95+ compatible wcstok() function under the correct C95 name wcstok. For pre-msvcr80 import libraries, provide mingw-w64 implementation of wcstok_s() and C95+ wcstok() functions. So when linking with any crt library, the wcstok symbol resolve to the correct C95 compatible wcstok() function. mingw-w64 implementation of wcstok is copied from musl libc which is very compact and some parts from musl libc are already used in mingw-w64. Update header files to reflect these changes. With this change, C95+ compatible wcstok() function is available for all builds, not only UCRT as it was before this change. For compatibility with C99, add missing restrict keyword for last wcstok() argument in header files. mingw-w64 is currently missing MS _wcstok() function for UCRT builds. So provide it into UCRT import libraries. Visual Studio 2015+ redefines wcstok() to _wcstok() when macro _CRT_NON_CONFORMING_WCSTOK is defined. And in C++ mode it provides overloaded C++ function wcstok() with two arguments unless the macro _CRT_NO_INLINE_DEPRECATED_WCSTOK is defined. It is documented on: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/strtok-strtok-l-wcstok-wcstok-l-mbstok-mbstok-l Implement same logic for _CRT_NON_CONFORMING_WCSTOK to get the old behavior by default. And provides C++ inline two-argument function unless define _CRT_NO_INLINE_DEPRECATED_WCSTOK is set. With this change mingw-w64 always provides C95+ compatible wcstok() function and MS two-arg _wcstok() function in all CRT import libraries. Also every CRT import library provides MS wcstok_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 |