From ddfb5e0b6909fbd75ec04109eb6a70d42fddb5c1 Mon Sep 17 00:00:00 2001 From: Adam King Date: Mon, 15 Apr 2002 03:11:12 +0000 Subject: natDouble.cc (parseDouble): Allow a number to end with the f/F/d/D modifiers. 2002-04-13 Adam King * java/lang/natDouble.cc (parseDouble): Allow a number to end with the f/F/d/D modifiers. From-SVN: r52308 --- libjava/java/lang/natDouble.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'libjava/java/lang') diff --git a/libjava/java/lang/natDouble.cc b/libjava/java/lang/natDouble.cc index b0b24a7..329795d 100644 --- a/libjava/java/lang/natDouble.cc +++ b/libjava/java/lang/natDouble.cc @@ -161,9 +161,19 @@ jdouble java::lang::Double::parseDouble(jstring str) { int length = str->length(); + while (length > 0 && Character::isWhitespace(str->charAt(length - 1))) length--; + + // The String could end with a f/F/d/D which is valid but we don't need. + if (length > 0) + { + jchar last = str->charAt(length-1); + if (last == 'f' || last == 'F' || last == 'd' || last == 'D') + length--; + } + jsize start = 0; while (length > 0 && Character::isWhitespace(str->charAt(start))) @@ -184,7 +194,7 @@ java::lang::Double::parseDouble(jstring str) if (endptr == data + blength) return val; } - throw new NumberFormatException; + throw new NumberFormatException(str); } void -- cgit v1.1