Commit 9545f3a9 by Mark Anderson Committed by Tom Tromey

natDouble.cc (parseDouble): Handle NaN, Infinity and -Infinity as parameters.

2005-04-01 Mark Anderson <mark@panonet.net>

	* java/lang/natDouble.cc (parseDouble): Handle NaN, Infinity and
	-Infinity as parameters.

From-SVN: r97424
parent 55b01ba0
2005-04-01 Mark Anderson <mark@panonet.net>
* java/lang/natDouble.cc (parseDouble): Handle NaN, Infinity and
-Infinity as parameters.
2005-04-01 Michael Koch <konqueror@gmx.de> 2005-04-01 Michael Koch <konqueror@gmx.de>
* java/io/PipedInputStream.java * java/io/PipedInputStream.java
......
// natDouble.cc - Implementation of java.lang.Double native methods. // natDouble.cc - Implementation of java.lang.Double native methods.
/* Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation /* Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -167,11 +167,15 @@ java::lang::Double::parseDouble(jstring str) ...@@ -167,11 +167,15 @@ java::lang::Double::parseDouble(jstring str)
length--; length--;
// The String could end with a f/F/d/D which is valid but we don't need. // The String could end with a f/F/d/D which is valid but we don't need.
bool saw_trailer = false;
if (length > 0) if (length > 0)
{ {
jchar last = str->charAt(length-1); jchar last = str->charAt(length-1);
if (last == 'f' || last == 'F' || last == 'd' || last == 'D') if (last == 'f' || last == 'F' || last == 'd' || last == 'D')
length--; {
length--;
saw_trailer = true;
}
} }
jsize start = 0; jsize start = 0;
...@@ -186,6 +190,17 @@ java::lang::Double::parseDouble(jstring str) ...@@ -186,6 +190,17 @@ java::lang::Double::parseDouble(jstring str)
jsize blength = _Jv_GetStringUTFRegion (str, start, length, data); jsize blength = _Jv_GetStringUTFRegion (str, start, length, data);
data[blength] = 0; data[blength] = 0;
if (! saw_trailer)
{
if (! strcmp (data, "NaN") || ! strcmp (data, "+NaN")
|| ! strcmp (data, "-NaN"))
return NaN;
else if (! strcmp (data, "Infinity") || ! strcmp (data, "+Infinity"))
return POSITIVE_INFINITY;
else if (! strcmp (data, "-Infinity"))
return NEGATIVE_INFINITY;
}
struct _Jv_reent reent; struct _Jv_reent reent;
memset (&reent, 0, sizeof reent); memset (&reent, 0, sizeof reent);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment