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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart

Issue 15868003: Revert "Rewrite double.parse." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | « runtime/vm/dart_api_impl_test.cc ('k') | sdk/lib/core/double.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
index 016418fb4cca44f9585bfeed676ebf0ee13329f6..56e7221611d77157a65130c7eda8a4ef69e00968 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
@@ -275,22 +275,18 @@ class Primitives {
if (handleError == null) handleError = _throwFormatException;
// Notice that JS parseFloat accepts garbage at the end of the string.
// Accept only:
- // - [+/-]NaN
+ // - NaN
// - [+/-]Infinity
// - a Dart double literal
- // We do allow leading or trailing whitespace.
+ // We do not allow leading or trailing whitespace.
if (!JS('bool',
- r'/^\s*[+-]?(?:Infinity|NaN|'
- r'(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s*$/.test(#)',
+ r'/^\s*(?:NaN|[+-]?(?:Infinity|'
+ r'(?:\.\d+|\d+(?:\.\d+)?)(?:[eE][+-]?\d+)?))\s*$/.test(#)',
source)) {
return handleError(source);
}
var result = JS('num', r'parseFloat(#)', source);
- if (result.isNaN) {
- var trimmed = source.trim();
- if (trimmed == 'NaN' || trimmed == '+NaN' || trimmed == '-NaN') {
- return result;
- }
+ if (result.isNaN && source != 'NaN') {
return handleError(source);
}
return result;
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | sdk/lib/core/double.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698