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

Unified Diff: frog/lib/math.dart

Issue 9595013: parseInt fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status file. Created 8 years, 10 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 | « frog/leg/lib/js_helper.dart ('k') | tests/co19/co19-leg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/lib/math.dart
diff --git a/frog/lib/math.dart b/frog/lib/math.dart
index 9e53624642af4707dbf01ae796d2bf850b25df0e..54cfdf59175eef1dd9fb6473b90d5a0ebc3d4625 100644
--- a/frog/lib/math.dart
+++ b/frog/lib/math.dart
@@ -51,8 +51,9 @@ class Math native 'Math' {
* cannot be parsed as an [int].
*/
static int parseInt(String str) native '''
- var isHex = (str.length > 2) && str[0] == '0' &&
- (str[1] == 'x' || str[1] == 'X');
+ var match = /^\\s*[+-]?(?:(0[xX][abcdefABCDEF0-9]+)|\\d+)\\s*\$/.exec(str);
+ if (!match) \$throw(new BadNumberFormatException(str));
+ var isHex = !!match[1];
var ret = parseInt(str, isHex ? 16 : 10);
if (isNaN(ret)) \$throw(new BadNumberFormatException(str));
return ret;''' { throw new BadNumberFormatException(""); }
« no previous file with comments | « frog/leg/lib/js_helper.dart ('k') | tests/co19/co19-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698