Blame view

3rdparty/boost_1_81_0/boost/system/detail/snprintf.hpp 1.43 KB
0b6a182c   Hu Chunming   添加无鉴权注册和注销
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  #ifndef BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED
  #define BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED
  
  // Copyright 2018, 2020, 2021 Peter Dimov
  //
  // Distributed under the Boost Software License, Version 1.0. (See accompanying
  // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  //
  // See library home page at http://www.boost.org/libs/system
  
  #include <boost/config.hpp>
  #include <cstdio>
  #include <cstdarg>
  
  //
  
  namespace boost
  {
  
  namespace system
  {
  
  namespace detail
  {
  
  #if ( defined(_MSC_VER) && _MSC_VER < 1900 ) || ( defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) )
  
  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 system
  
  } // namespace boost
  
  #endif // #ifndef BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED