[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] java/text/DecimalFormat.java: ParseException overlooked
From: |
Ito Kazumitsu |
Subject: |
[cp-patches] java/text/DecimalFormat.java: ParseException overlooked |
Date: |
1 Mar 2005 15:05:09 -0000 |
User-agent: |
SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/21.3.50 (i386-unknown-freebsd5.3) MULE/5.0 (SAKAKI) |
Hi,
I think this is a bug of java/text/DecimalFormat.java:
When the following program is run,
import java.text.DecimalFormat;
public class N {
public static void main(String[] args) throws Exception {
DecimalFormat nf = new DecimalFormat("#,##0X");
System.out.println(nf.parse("1"));
System.out.println(nf.parse("1Y"));
}
}
Sun's JDK throws java.text.ParseException, but GNU Classpath's
java.text.DecimalFormat gives wrong results:
$ kaffe N
1
1
Here is my patch. In order to test this, I have updated the mauve test
of gnu/testlet/java/text/DecimalFormat/parse.java.
ChangeLog:
2005-03-01 Ito Kazumitsu <address@hidden>
* java/text/DecimalFormat.java (parse):
Check whether the positive suffix matches the pattern.
Patch:
######
--- java/text/DecimalFormat.java.orig Thu Jan 6 08:43:11 2005
+++ java/text/DecimalFormat.java Tue Mar 1 18:08:36 2005
@@ -989,6 +989,11 @@
pos.setErrorIndex(index);
return null;
}
+ else if (! got_pos_suf)
+ {
+ pos.setErrorIndex(index);
+ return null;
+ }
String suffix = is_neg ? ns : positiveSuffix;
long parsedMultiplier = 1;
######
- [cp-patches] java/text/DecimalFormat.java: ParseException overlooked,
Ito Kazumitsu <=