Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: base/strings/string_number_conversions.cc

Issue 2063273002: XXX: not-working std::strtod for xref to https://codereview.chromium.org/2044643005/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/strings/string_number_conversions_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 413
414 bool StringToSizeT(const StringPiece16& input, size_t* output) { 414 bool StringToSizeT(const StringPiece16& input, size_t* output) {
415 return String16ToIntImpl(input, output); 415 return String16ToIntImpl(input, output);
416 } 416 }
417 417
418 bool StringToDouble(const std::string& input, double* output) { 418 bool StringToDouble(const std::string& input, double* output) {
419 // Thread-safe? It is on at least Mac, Linux, and Windows. 419 // Thread-safe? It is on at least Mac, Linux, and Windows.
420 ScopedClearErrno clear_errno; 420 ScopedClearErrno clear_errno;
421 421
422 char* endptr = NULL; 422 char* endptr = NULL;
423 *output = dmg_fp::strtod(input.c_str(), &endptr); 423 *output = std::strtod(input.c_str(), &endptr);
424 424
425 // Cases to return false: 425 // Cases to return false:
426 // - If errno is ERANGE, there was an overflow or underflow. 426 // - If errno is ERANGE, there was an overflow or underflow.
427 // - If the input string is empty, there was nothing to parse. 427 // - If the input string is empty, there was nothing to parse.
428 // - If endptr does not point to the end of the string, there are either 428 // - If endptr does not point to the end of the string, there are either
429 // characters remaining in the string after a parsed number, or the string 429 // characters remaining in the string after a parsed number, or the string
430 // does not begin with a parseable number. endptr is compared to the 430 // does not begin with a parseable number. endptr is compared to the
431 // expected end given the string's stated length to correctly catch cases 431 // expected end given the string's stated length to correctly catch cases
432 // where the string contains embedded NUL characters. 432 // where the string contains embedded NUL characters.
433 // - If the first character is a space, there was leading whitespace 433 // - If the first character is a space, there was leading whitespace
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 bool HexStringToUInt64(const StringPiece& input, uint64_t* output) { 477 bool HexStringToUInt64(const StringPiece& input, uint64_t* output) {
478 return IteratorRangeToNumber<HexIteratorRangeToUInt64Traits>::Invoke( 478 return IteratorRangeToNumber<HexIteratorRangeToUInt64Traits>::Invoke(
479 input.begin(), input.end(), output); 479 input.begin(), input.end(), output);
480 } 480 }
481 481
482 bool HexStringToBytes(const std::string& input, std::vector<uint8_t>* output) { 482 bool HexStringToBytes(const std::string& input, std::vector<uint8_t>* output) {
483 return HexStringToBytesT(input, output); 483 return HexStringToBytesT(input, output);
484 } 484 }
485 485
486 } // namespace base 486 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/strings/string_number_conversions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698