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 <errno.h> | 7 #include <errno.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
11 | 11 |
| 12 #include "base/macros.h" |
| 13 #include "build/build_config.h" |
| 14 |
12 #if !defined(NDEBUG) | 15 #if !defined(NDEBUG) |
13 // In debug builds, we use RAW_CHECK() to print useful error messages, if | 16 // In debug builds, we use RAW_CHECK() to print useful error messages, if |
14 // SafeSPrintf() is called with broken arguments. | 17 // SafeSPrintf() is called with broken arguments. |
15 // As our contract promises that SafeSPrintf() can be called from any | 18 // As our contract promises that SafeSPrintf() can be called from any |
16 // restricted run-time context, it is not actually safe to call logging | 19 // restricted run-time context, it is not actually safe to call logging |
17 // functions from it; and we only ever do so for debug builds and hope for the | 20 // functions from it; and we only ever do so for debug builds and hope for the |
18 // best. We should _never_ call any logging function other than RAW_CHECK(), | 21 // best. We should _never_ call any logging function other than RAW_CHECK(), |
19 // and we should _never_ include any logging code that is active in production | 22 // and we should _never_ include any logging code that is active in production |
20 // builds. Most notably, we should not include these logging functions in | 23 // builds. Most notably, we should not include these logging functions in |
21 // unofficial release builds, even though those builds would otherwise have | 24 // unofficial release builds, even though those builds would otherwise have |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 DEBUG_CHECK(src[0] != '%' || src[1] == '%'); | 677 DEBUG_CHECK(src[0] != '%' || src[1] == '%'); |
675 if (src[0] == '%' && src[1] == '%') { | 678 if (src[0] == '%' && src[1] == '%') { |
676 ++src; | 679 ++src; |
677 } | 680 } |
678 } | 681 } |
679 return buffer.GetCount(); | 682 return buffer.GetCount(); |
680 } | 683 } |
681 | 684 |
682 } // namespace strings | 685 } // namespace strings |
683 } // namespace base | 686 } // namespace base |
OLD | NEW |