Prefer use of __MINGW_PRINTF/SCANF_FORMAT if available.

Mingw headers sometimes like to define alternative scanf/printf
format attributes depending on whether they're using clang, UCRT,
MINGW_ANSI_STDIO, or the microsoft version of printf/scanf.  This
change attempts to use the right one on the given platform.

This is an attempt to fix part of #40355.
This commit is contained in:
Nick Mathewson
2021-11-05 12:08:48 -04:00
parent 1c77deca4f
commit c93114ec9e
5 changed files with 37 additions and 10 deletions
+2 -2
View File
@@ -8,9 +8,9 @@
* \brief Compatibility wrappers around snprintf and its friends
**/
#include "lib/cc/torint.h"
#include "lib/string/printf.h"
#include "lib/err/torerr.h"
#include "lib/cc/torint.h"
#include "lib/malloc/malloc.h"
#include <stdlib.h>
@@ -45,7 +45,7 @@ tor_vsnprintf(char *str, size_t size, const char *format, va_list args)
return -1; /* no place for the NUL */
if (size > SIZE_T_CEILING)
return -1;
#ifdef _WIN32
#if defined(_WIN32) && !defined(HAVE_VSNPRINTF)
r = _vsnprintf(str, size, format, args);
#else
r = vsnprintf(str, size, format, args);