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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 const Arg& arg = args[cur_arg++]; | 503 const Arg& arg = args[cur_arg++]; |
504 if (arg.type != Arg::INT && arg.type != Arg::UINT) { | 504 if (arg.type != Arg::INT && arg.type != Arg::UINT) { |
505 DEBUG_CHECK(arg.type == Arg::INT || arg.type == Arg::UINT); | 505 DEBUG_CHECK(arg.type == Arg::INT || arg.type == Arg::UINT); |
506 goto fail_to_expand; | 506 goto fail_to_expand; |
507 } | 507 } |
508 | 508 |
509 // Apply padding, if needed. | 509 // Apply padding, if needed. |
510 buffer.Pad(' ', padding, 1); | 510 buffer.Pad(' ', padding, 1); |
511 | 511 |
512 // Convert the argument to an ASCII character and output it. | 512 // Convert the argument to an ASCII character and output it. |
513 char ch = static_cast<char>(arg.integer.i); | 513 char as_char = static_cast<char>(arg.integer.i); |
514 if (!ch) { | 514 if (!as_char) { |
515 goto end_of_output_buffer; | 515 goto end_of_output_buffer; |
516 } | 516 } |
517 buffer.Out(ch); | 517 buffer.Out(as_char); |
518 break; } | 518 break; } |
519 case 'd': // Output a possibly signed decimal value. | 519 case 'd': // Output a possibly signed decimal value. |
520 case 'o': // Output an unsigned octal value. | 520 case 'o': // Output an unsigned octal value. |
521 case 'x': // Output an unsigned hexadecimal value. | 521 case 'x': // Output an unsigned hexadecimal value. |
522 case 'X': | 522 case 'X': |
523 case 'p': { // Output a pointer value. | 523 case 'p': { // Output a pointer value. |
524 // Check that there are arguments left to be inserted. | 524 // Check that there are arguments left to be inserted. |
525 if (cur_arg >= max_args) { | 525 if (cur_arg >= max_args) { |
526 DEBUG_CHECK(cur_arg < max_args); | 526 DEBUG_CHECK(cur_arg < max_args); |
527 goto fail_to_expand; | 527 goto fail_to_expand; |
(...skipping 148 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 |