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

Unified Diff: runtime/lib/double.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
« no previous file with comments | « no previous file | runtime/vm/double_conversion.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/double.cc
diff --git a/runtime/lib/double.cc b/runtime/lib/double.cc
index 3fc2261b843032288b3fd21b80eb455fe6692767..abe5df2ea2b2f754641ea90a9351202ec96d5ca3 100644
--- a/runtime/lib/double.cc
+++ b/runtime/lib/double.cc
@@ -221,9 +221,8 @@ DEFINE_NATIVE_ENTRY(Double_parse, 1) {
}
}
if (dot_ok) {
- char* p_end = NULL;
- const double double_value = strtod(cstr, &p_end);
- if (p_end == (cstr + len)) {
+ double double_value;
+ if (CStringToDouble(cstr, len, &double_value)) {
return Double::New(double_value);
}
}
@@ -238,10 +237,14 @@ DEFINE_NATIVE_ENTRY(Double_parse, 1) {
Token::kDOUBLE,
&is_positive,
&number_string)) {
+ ASSERT(number_string->IsOneByteString());
Ivan Posva 2013/04/05 21:56:42 Please explain here why you are allowed to make th
Vyacheslav Egorov (Google) 2013/04/08 14:25:04 Done.
const char* cstr = number_string->ToCString();
- char* p_end = NULL;
- double double_value = strtod(cstr, &p_end);
- ASSERT(p_end != cstr);
+
+ double double_value;
+ bool ok = CStringToDouble(cstr, number_string->Length(), &double_value);
+ USE(ok);
Ivan Posva 2013/04/05 21:56:42 I would have thought USE is not necessary here.
Vyacheslav Egorov (Google) 2013/04/08 14:25:04 Done.
+ ASSERT(ok);
+
if (!is_positive) {
double_value = -double_value;
}
« no previous file with comments | « no previous file | runtime/vm/double_conversion.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698