On Thu, 20 Feb 2020, Pali Rohár wrote:
In patch I also removed vsnprintf == _vsnprintf and snprintf == _snprintf aliases as they wrong, snprintf() is not same as msvcrt's _snprintf() function, and above __ms_snprintf() or __ms_vsnprintf() wrapper is needed.
While they are "wrong" in that sense, this now means that there is no symbol "snprintf" defined at all, which does break compilation of a number of projects. (That primarily happens within configure scripts of certain projects, that try to detect if "snprintf" exists, without including stdio.h.) In all sane cases, the calling code that includes stdio.h will end up calling __ms_snprintf anyway, where you get your fix.
So while this change is well-intended, it is also a bit too heavy handed, as there's many aspects to take into account with keeping as much software compiling while striving for good standards compliance.
So either I'd suggest reintroducing these again (reverting this bit of the patch), or making "snprintf" available as an alias for "__ms_snprintf". I can try making a patch for this, within a few days.
Also another detail I noticed in your patch:
diff --git a/mingw-w64-crt/stdio/snprintf.c b/mingw-w64-crt/stdio/snprintf.c index 93300113..0bb5556f 100644 --- a/mingw-w64-crt/stdio/snprintf.c +++ b/mingw-w64-crt/stdio/snprintf.c @@ -12,7 +12,27 @@ int __cdecl __ms_snprintf(char* buffer, size_t n, const char *format, ...) va_list argptr; va_start(argptr, format); + + /* _vsnprintf() does not work with zero length buffer + * so count number of character by _vscprintf() call */ + if (n == 0 || !buffer) + { + retval = _vscprintf(format, argptr); + va_end(argptr); + return retval; + } + retval = _vsnprintf (buffer, n, format, argptr); + + /* _vsnprintf() returns negative number if buffer is too small + * so count number of character by _vscprintf() call */ + if (retval < 0) + retval = _vscprintf(format, argptr);
Here you're reusing argptr again, after already using it once for _vsnprintf above. I think the correct solution to that is to make a new va_arg with va_copy, before calling _vsnprintf. // Martin _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public