OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/string_number_conversions.h" | 5 #include "base/strings/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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 const_iterator end, | 179 const_iterator end, |
180 value_type* output) { | 180 value_type* output) { |
181 bool valid = true; | 181 bool valid = true; |
182 | 182 |
183 while (begin != end && LocalIsWhitespace(*begin)) { | 183 while (begin != end && LocalIsWhitespace(*begin)) { |
184 valid = false; | 184 valid = false; |
185 ++begin; | 185 ++begin; |
186 } | 186 } |
187 | 187 |
188 if (begin != end && *begin == '-') { | 188 if (begin != end && *begin == '-') { |
189 if (!Negative::Invoke(begin + 1, end, output)) { | 189 if (!std::numeric_limits<value_type>::is_signed) { |
| 190 valid = false; |
| 191 } else if (!Negative::Invoke(begin + 1, end, output)) { |
190 valid = false; | 192 valid = false; |
191 } | 193 } |
192 } else { | 194 } else { |
193 if (begin != end && *begin == '+') { | 195 if (begin != end && *begin == '+') { |
194 ++begin; | 196 ++begin; |
195 } | 197 } |
196 if (!Positive::Invoke(begin, end, output)) { | 198 if (!Positive::Invoke(begin, end, output)) { |
197 valid = false; | 199 valid = false; |
198 } | 200 } |
199 } | 201 } |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 bool HexStringToUInt64(const StringPiece& input, uint64* output) { | 504 bool HexStringToUInt64(const StringPiece& input, uint64* output) { |
503 return IteratorRangeToNumber<HexIteratorRangeToUInt64Traits>::Invoke( | 505 return IteratorRangeToNumber<HexIteratorRangeToUInt64Traits>::Invoke( |
504 input.begin(), input.end(), output); | 506 input.begin(), input.end(), output); |
505 } | 507 } |
506 | 508 |
507 bool HexStringToBytes(const std::string& input, std::vector<uint8>* output) { | 509 bool HexStringToBytes(const std::string& input, std::vector<uint8>* output) { |
508 return HexStringToBytesT(input, output); | 510 return HexStringToBytesT(input, output); |
509 } | 511 } |
510 | 512 |
511 } // namespace base | 513 } // namespace base |
OLD | NEW |