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

Unified Diff: runtime/vm/object.cc

Issue 13529014: Use locale insensitive method to parse double literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address Srdjan's comments Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« runtime/lib/double.cc ('K') | « runtime/vm/double_conversion.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index aa1aac6319890ba3e63a236a9cbd33827415942c..7f2beae013038eaa322079300f7f1698ae65a6e5 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -10586,29 +10586,9 @@ RawDouble* Double::New(double d, Heap::Space space) {
}
-static bool IsWhiteSpace(char ch) {
- return ch == '\0' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\t';
-}
-
-
-static bool StringToDouble(const String& str, double* double_value) {
- ASSERT(double_value != NULL);
- // TODO(regis): For now, we use strtod to convert a string to double.
- const char* nptr = str.ToCString();
- char* endptr = NULL;
- *double_value = strtod(nptr, &endptr);
- // We do not treat overflow or underflow as an error and therefore do not
- // check errno for ERANGE.
- if (!IsWhiteSpace(*endptr)) {
- return false;
- }
- return true;
-}
-
-
RawDouble* Double::New(const String& str, Heap::Space space) {
double double_value;
- if (!StringToDouble(str, &double_value)) {
+ if (!CStringToDouble(str.ToCString(), str.Length(), &double_value)) {
return Double::Handle().raw();
}
return New(double_value, space);
@@ -10645,7 +10625,7 @@ RawDouble* Double::NewCanonical(double value) {
RawDouble* Double::NewCanonical(const String& str) {
double double_value;
- if (!StringToDouble(str, &double_value)) {
+ if (!CStringToDouble(str.ToCString(), str.Length(), &double_value)) {
return Double::Handle().raw();
}
return NewCanonical(double_value);
« runtime/lib/double.cc ('K') | « runtime/vm/double_conversion.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698