| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_number_conversions.h" | 5 #include "base/string_number_conversions.h" |
| 6 | 6 |
| 7 #include <ctype.h> | 7 #include <ctype.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <wctype.h> | 10 #include <wctype.h> |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 static bool Invoke(const_iterator begin, const_iterator end, | 213 static bool Invoke(const_iterator begin, const_iterator end, |
| 214 typename traits::value_type* output) { | 214 typename traits::value_type* output) { |
| 215 *output = 0; | 215 *output = 0; |
| 216 | 216 |
| 217 if (begin == end) { | 217 if (begin == end) { |
| 218 return false; | 218 return false; |
| 219 } | 219 } |
| 220 | 220 |
| 221 // Note: no performance difference was found when using template | 221 // Note: no performance difference was found when using template |
| 222 // specialization to remove this check in bases other than 16 | 222 // specialization to remove this check in bases other than 16 |
| 223 if (traits::kBase == 16 && end - begin >= 2 && *begin == '0' && | 223 if (traits::kBase == 16 && end - begin > 2 && *begin == '0' && |
| 224 (*(begin + 1) == 'x' || *(begin + 1) == 'X')) { | 224 (*(begin + 1) == 'x' || *(begin + 1) == 'X')) { |
| 225 begin += 2; | 225 begin += 2; |
| 226 } | 226 } |
| 227 | 227 |
| 228 for (const_iterator current = begin; current != end; ++current) { | 228 for (const_iterator current = begin; current != end; ++current) { |
| 229 uint8 new_digit = 0; | 229 uint8 new_digit = 0; |
| 230 | 230 |
| 231 if (!CharToDigit<traits::kBase>(*current, &new_digit)) { | 231 if (!CharToDigit<traits::kBase>(*current, &new_digit)) { |
| 232 return false; | 232 return false; |
| 233 } | 233 } |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 end, | 536 end, |
| 537 output); | 537 output); |
| 538 } | 538 } |
| 539 #endif | 539 #endif |
| 540 | 540 |
| 541 bool HexStringToBytes(const std::string& input, std::vector<uint8>* output) { | 541 bool HexStringToBytes(const std::string& input, std::vector<uint8>* output) { |
| 542 return HexStringToBytesT(input, output); | 542 return HexStringToBytesT(input, output); |
| 543 } | 543 } |
| 544 | 544 |
| 545 } // namespace base | 545 } // namespace base |
| OLD | NEW |