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