Call snprintf when available in posix_api.cpp.

Fixes https://github.com/boostorg/regex/issues/184.
This commit is contained in:
jzmaddock
2022-12-02 17:25:16 +00:00
parent c23e7b857a
commit a142dfecda

View File

@ -177,7 +177,9 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA*
// We're converting an integer i to a string, and since i <= REG_E_UNKNOWN
// a five character string is *always* large enough:
//
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
#if BOOST_CXX_VERSION >= 201103
int r = (std::snprintf)(localbuf, 5, "%d", i);
#elif BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
int r = (::sprintf_s)(localbuf, 5, "%d", i);
#else
int r = (std::sprintf)(localbuf, "%d", i);
@ -189,7 +191,9 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA*
return std::strlen(localbuf) + 1;
}
}
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
#if BOOST_CXX_VERSION >= 201103
int r = (::snprintf)(localbuf, 5, "%d", 0);
#elif BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
int r = (::sprintf_s)(localbuf, 5, "%d", 0);
#else
int r = (std::sprintf)(localbuf, "%d", 0);