aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2000-09-01 15:00:59 +0000
committerAndrew Haley <aph@gcc.gnu.org>2000-09-01 15:00:59 +0000
commitad17a40dcec76fcb2746f6c6d9e3b5071e04e004 (patch)
tree8dd2c656446ae0cb7a7680e3be230dd18cb68fc6 /libjava/java
parent6324d2bbb6e6dd180de74234c762523c2a946838 (diff)
downloadgcc-ad17a40dcec76fcb2746f6c6d9e3b5071e04e004.zip
gcc-ad17a40dcec76fcb2746f6c6d9e3b5071e04e004.tar.gz
gcc-ad17a40dcec76fcb2746f6c6d9e3b5071e04e004.tar.bz2
StreamTokenizer.java: Don't throw a NumberFormatException if a field is numeric as far as the...
2000-09-01 Andrew Haley <aph@redhat.com> * java/io/StreamTokenizer.java: Don't throw a NumberFormatException if a field is numeric as far as the StreamTokenizer is concerned but not as far as Double.valueOf() is concerned: return a zero instead. For gcj/141. From-SVN: r36100
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/io/StreamTokenizer.java24
1 files changed, 19 insertions, 5 deletions
diff --git a/libjava/java/io/StreamTokenizer.java b/libjava/java/io/StreamTokenizer.java
index 3c4d8c6..b3c8003 100644
--- a/libjava/java/io/StreamTokenizer.java
+++ b/libjava/java/io/StreamTokenizer.java
@@ -293,16 +293,21 @@ public class StreamTokenizer
ttype = TT_EOF;
else if (isNumeric(ch))
{
+ boolean isNegative = false;
if (ch == '-')
{
// Read ahead to see if this is an ordinary '-' rather than numeric.
ch = in.read();
- if (ch != TT_EOF)
- in.unread(ch);
if (isNumeric(ch) && ch != '-')
- ch = '-';
+ {
+ isNegative = true;
+ }
else
- return (ttype = '-');
+ {
+ if (ch != TT_EOF)
+ in.unread(ch);
+ return (ttype = '-');
+ }
}
StringBuffer tokbuf = new StringBuffer();
@@ -318,7 +323,16 @@ public class StreamTokenizer
if (ch != TT_EOF)
in.unread(ch);
ttype = TT_NUMBER;
- nval = Double.valueOf(tokbuf.toString()).doubleValue();
+ try
+ {
+ nval = Double.valueOf(tokbuf.toString()).doubleValue();
+ }
+ catch (NumberFormatException _)
+ {
+ nval = 0.0;
+ }
+ if (isNegative)
+ nval = -nval;
}
else if (isAlphabetic(ch))
{