OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/strings/safe_sprintf.h" | 5 #include "base/strings/safe_sprintf.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #if !defined(NDEBUG) | 9 #if !defined(NDEBUG) |
10 // In debug builds, we use RAW_CHECK() to print useful error messages, if | 10 // In debug builds, we use RAW_CHECK() to print useful error messages, if |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 size_(size - 1), // Account for trailing NUL byte | 108 size_(size - 1), // Account for trailing NUL byte |
109 count_(0) { | 109 count_(0) { |
110 // The following assertion does not build on Mac and Android. This is because | 110 // The following assertion does not build on Mac and Android. This is because |
111 // static_assert only works with compile-time constants, but mac uses | 111 // static_assert only works with compile-time constants, but mac uses |
112 // libstdc++4.2 and android uses stlport, which both don't mark | 112 // libstdc++4.2 and android uses stlport, which both don't mark |
113 // numeric_limits::max() as constexp. Likewise, MSVS2013's standard library | 113 // numeric_limits::max() as constexp. Likewise, MSVS2013's standard library |
114 // also doesn't mark max() as constexpr yet. cl.exe supports static_cast but | 114 // also doesn't mark max() as constexpr yet. cl.exe supports static_cast but |
115 // doesn't really implement constexpr yet so it doesn't complain, but clang | 115 // doesn't really implement constexpr yet so it doesn't complain, but clang |
116 // does. | 116 // does. |
117 #if __cplusplus >= 201103 && !defined(OS_ANDROID) && !defined(OS_MACOSX) && \ | 117 #if __cplusplus >= 201103 && !defined(OS_ANDROID) && !defined(OS_MACOSX) && \ |
118 !defined(OS_IOS) && !(defined(__clang__) && defined(OS_WIN)) | 118 !defined(OS_IOS) && !(defined(__clang__)) |
119 COMPILE_ASSERT(kSSizeMaxConst == \ | 119 COMPILE_ASSERT(kSSizeMaxConst == \ |
120 static_cast<size_t>(std::numeric_limits<ssize_t>::max()), | 120 static_cast<size_t>(std::numeric_limits<ssize_t>::max()), |
121 kSSizeMax_is_the_max_value_of_an_ssize_t); | 121 kSSizeMax_is_the_max_value_of_an_ssize_t); |
122 #endif | 122 #endif |
123 DEBUG_CHECK(size > 0); | 123 DEBUG_CHECK(size > 0); |
124 DEBUG_CHECK(size <= kSSizeMax); | 124 DEBUG_CHECK(size <= kSSizeMax); |
125 } | 125 } |
126 | 126 |
127 ~Buffer() { | 127 ~Buffer() { |
128 // The code calling the constructor guaranteed that there was enough space | 128 // The code calling the constructor guaranteed that there was enough space |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 DEBUG_CHECK(src[0] != '%' || src[1] == '%'); | 676 DEBUG_CHECK(src[0] != '%' || src[1] == '%'); |
677 if (src[0] == '%' && src[1] == '%') { | 677 if (src[0] == '%' && src[1] == '%') { |
678 ++src; | 678 ++src; |
679 } | 679 } |
680 } | 680 } |
681 return buffer.GetCount(); | 681 return buffer.GetCount(); |
682 } | 682 } |
683 | 683 |
684 } // namespace strings | 684 } // namespace strings |
685 } // namespace base | 685 } // namespace base |
OLD | NEW |