This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch Ping: Double.parseDouble cannot handle NaN, Infinity or-Infinity


On Wednesday 30 March 2005 20:41, Bryce McKinlay wrote:
> Tom Tromey wrote:
> >Mark> So do we have a final decision so I can produce a final patch
> >Mark> for this bug?
> >
> >You're probably not going to get a real final decision.  Write it one
> >way, I will approve it.  Write it the other way, Bryce will approve
> >it.  It will all come out in the wash when we do the Big Classpath
> >Merge anyway.
>
> Yeah. I think my solution is somewhat more elegant, but avoiding
> divergances from Classpath is the overriding concern - ie we'd need to
> make the corresponding change in Classpath's JNI implementation of the
> native parts of Double. That should be a fairly minor change, but I'm ok
> with Tom's approach too if you don't want to do that.
>
> Bryce

OK, here is the final patch. I have went Tom's way to avoid having to make any other changes.

Will this be committed to 4.0 as well?

-- 
Regards,
Mark

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

        * java/lang/natDouble.cc (parseDouble): Handle NaN, Infinity and -Infinity as
        parameters
*** java/lang/natDouble.cc.orig	Fri Mar  4 12:35:22 2005
--- java/lang/natDouble.cc	Fri Apr  1 14:26:32 2005
*************** java::lang::Double::parseDouble(jstring 
*** 193,198 ****
--- 193,208 ----
        double val = _strtod_r (&reent, data, &endptr);
        if (endptr == data + blength)
  	return val;
+       else
+       {
+ 	// check for NaN, Infinity & -Infinity
+ 	if (str->equals(JvNewStringLatin1("NaN", strlen("NaN"))))
+ 	  return NaN;
+ 	else if (str->equals(JvNewStringLatin1("Infinity", strlen("Infinity"))))
+ 	  return POSITIVE_INFINITY;
+ 	else if (str->equals(JvNewStringLatin1("-Infinity", strlen("-Infinity"))))
+ 	  return NEGATIVE_INFINITY;	
+       }
      }
    throw new NumberFormatException(str);
  }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]