Browse Source

[java/cs] Accept + before a parseInt/parseFloat string

Caue Waneck 12 years ago
parent
commit
a5dda0f61b
2 changed files with 6 additions and 4 deletions
  1. 2 2
      std/cs/_std/Std.hx
  2. 4 2
      std/java/_std/Std.hx

+ 2 - 2
std/cs/_std/Std.hx

@@ -95,7 +95,7 @@ import cs.internal.Exceptions;
 					case '-'.code:
 					case '-'.code:
 						isNeg = true;
 						isNeg = true;
 						continue;
 						continue;
-					case ' '.code, '\t'.code, '\n'.code, '\r'.code:
+					case ' '.code, '\t'.code, '\n'.code, '\r'.code, '+'.code:
 						if (isNeg)
 						if (isNeg)
 							return null;
 							return null;
 						continue;
 						continue;
@@ -155,7 +155,7 @@ import cs.internal.Exceptions;
 					case '-'.code:
 					case '-'.code:
 						isNeg = true;
 						isNeg = true;
 						continue;
 						continue;
-					case ' '.code, '\t'.code, '\n'.code, '\r'.code:
+					case ' '.code, '\t'.code, '\n'.code, '\r'.code, '+'.code:
 						if (isNeg)
 						if (isNeg)
 							return Math.NaN;
 							return Math.NaN;
 						continue;
 						continue;

+ 4 - 2
std/java/_std/Std.hx

@@ -91,6 +91,7 @@ import java.internal.Exceptions;
 					case \'-\':
 					case \'-\':
 						isNeg = true;
 						isNeg = true;
 						continue;
 						continue;
+          case \'+\':
 					case \'\\n\':
 					case \'\\n\':
 					case \'\\t\':
 					case \'\\t\':
 					case \'\\r\':
 					case \'\\r\':
@@ -155,6 +156,7 @@ import java.internal.Exceptions;
 					case \'-\':
 					case \'-\':
 						isNeg = true;
 						isNeg = true;
 						continue;
 						continue;
+          case \'+\':
 					case \'\\n\':
 					case \'\\n\':
 					case \'\\t\':
 					case \'\\t\':
 					case \'\\r\':
 					case \'\\r\':
@@ -237,11 +239,11 @@ import java.internal.Exceptions;
 	public static function parseFloat( x : String ) : Float {
 	public static function parseFloat( x : String ) : Float {
 		return 0.0;
 		return 0.0;
 	}
 	}
-	
+
 	public static function instance<T>( v : { }, c : Class<T> ) : T {
 	public static function instance<T>( v : { }, c : Class<T> ) : T {
 		return Std.is(v, c) ? cast v : null;
 		return Std.is(v, c) ? cast v : null;
 	}
 	}
-	
+
 	public static function random( x : Int ) : Int {
 	public static function random( x : Int ) : Int {
 		if (x <= 0) return 0;
 		if (x <= 0) return 0;
 		return Std.int(Math.random() * x);
 		return Std.int(Math.random() * x);