mirror of
https://github.com/boostorg/system.git
synced 2025-07-30 04:27:14 +02:00
Use std::snprintf in detail/snprintf.hpp
This commit is contained in:
@ -8,66 +8,21 @@
|
|||||||
//
|
//
|
||||||
// See library home page at http://www.boost.org/libs/system
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdarg>
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace system
|
namespace system
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
#if ( defined(_MSC_VER) && _MSC_VER < 1900 ) || ( defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) )
|
using std::snprintf;
|
||||||
|
|
||||||
inline void snprintf( char * buffer, std::size_t len, char const * format, ... )
|
|
||||||
{
|
|
||||||
# if defined( BOOST_MSVC )
|
|
||||||
# pragma warning( push )
|
|
||||||
# pragma warning( disable: 4996 )
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if( len == 0 ) return;
|
|
||||||
|
|
||||||
va_list args;
|
|
||||||
va_start( args, format );
|
|
||||||
|
|
||||||
_vsnprintf( buffer, len - 1, format, args );
|
|
||||||
buffer[ len - 1 ] = 0;
|
|
||||||
|
|
||||||
va_end( args );
|
|
||||||
|
|
||||||
# if defined( BOOST_MSVC )
|
|
||||||
# pragma warning( pop )
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
|
||||||
__attribute__((__format__ (__printf__, 3, 4)))
|
|
||||||
#endif
|
|
||||||
inline void snprintf( char * buffer, std::size_t len, char const * format, ... )
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
va_start( args, format );
|
|
||||||
|
|
||||||
std::vsnprintf( buffer, len, format, args );
|
|
||||||
|
|
||||||
va_end( args );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
} // namespace system
|
} // namespace system
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED
|
||||||
|
Reference in New Issue
Block a user