OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/string_util.h" | 5 #include "base/string_util.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <ctype.h> | 9 #include <ctype.h> |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1006 formatted.reserve(format_string.length() + sub_length); | 1006 formatted.reserve(format_string.length() + sub_length); |
1007 | 1007 |
1008 std::vector<ReplacementOffset> r_offsets; | 1008 std::vector<ReplacementOffset> r_offsets; |
1009 for (typename FormatStringType::const_iterator i = format_string.begin(); | 1009 for (typename FormatStringType::const_iterator i = format_string.begin(); |
1010 i != format_string.end(); ++i) { | 1010 i != format_string.end(); ++i) { |
1011 if ('$' == *i) { | 1011 if ('$' == *i) { |
1012 if (i + 1 != format_string.end()) { | 1012 if (i + 1 != format_string.end()) { |
1013 ++i; | 1013 ++i; |
1014 DCHECK('$' == *i || '1' <= *i) << "Invalid placeholder: " << *i; | 1014 DCHECK('$' == *i || '1' <= *i) << "Invalid placeholder: " << *i; |
1015 if ('$' == *i) { | 1015 if ('$' == *i) { |
1016 formatted.push_back('$'); | 1016 while (i != format_string.end() && '$' == *i) { |
Miranda Callahan
2010/08/30 21:17:15
nice. :-)
| |
1017 formatted.push_back('$'); | |
1018 ++i; | |
1019 } | |
1020 --i; | |
1017 } else { | 1021 } else { |
1018 uintptr_t index = *i - '1'; | 1022 uintptr_t index = *i - '1'; |
1019 if (offsets) { | 1023 if (offsets) { |
1020 ReplacementOffset r_offset(index, | 1024 ReplacementOffset r_offset(index, |
1021 static_cast<int>(formatted.size())); | 1025 static_cast<int>(formatted.size())); |
1022 r_offsets.insert(std::lower_bound(r_offsets.begin(), | 1026 r_offsets.insert(std::lower_bound(r_offsets.begin(), |
1023 r_offsets.end(), r_offset, | 1027 r_offsets.end(), r_offset, |
1024 &CompareParameter), | 1028 &CompareParameter), |
1025 r_offset); | 1029 r_offset); |
1026 } | 1030 } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1241 int rstr_len = (max_len - 3) / 2; | 1245 int rstr_len = (max_len - 3) / 2; |
1242 int lstr_len = rstr_len + ((max_len - 3) % 2); | 1246 int lstr_len = rstr_len + ((max_len - 3) % 2); |
1243 output->assign(input.substr(0, lstr_len) + L"..." + | 1247 output->assign(input.substr(0, lstr_len) + L"..." + |
1244 input.substr(input.length() - rstr_len)); | 1248 input.substr(input.length() - rstr_len)); |
1245 break; | 1249 break; |
1246 } | 1250 } |
1247 } | 1251 } |
1248 | 1252 |
1249 return true; | 1253 return true; |
1250 } | 1254 } |
OLD | NEW |