This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: DecimalFormat fixlet
- From: Tom Tromey <tromey at redhat dot com>
- To: GCC libjava patches <java-patches at gcc dot gnu dot org>
- Date: 04 Aug 2003 15:11:22 -0600
- Subject: Patch: FYI: DecimalFormat fixlet
- Reply-to: tromey at redhat dot com
I'm checking this in on the trunk.
This fixes a DecimalFormat bug noticed by a Classpath developer.
There's a new Mauve test for this.
Tom
Index: ChangeLog
from David P Grove <groved@us.ibm.com>
* java/text/DecimalFormat.java (format): avoid ArithmeticException
when groupingSize is 0.
(parse): Likewise.
Index: java/text/DecimalFormat.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/DecimalFormat.java,v
retrieving revision 1.7
diff -u -r1.7 DecimalFormat.java
--- java/text/DecimalFormat.java 9 Jun 2003 16:20:14 -0000 1.7
+++ java/text/DecimalFormat.java 4 Aug 2003 20:31:23 -0000
@@ -474,7 +474,7 @@
intPart = Math.floor(intPart / 10);
// Append group separator if required.
- if (groupingUsed && count > 0 && count % groupingSize == 0)
+ if (groupingUsed && count > 0 && groupingSize != 0 && count % groupingSize == 0)
dest.insert(index, symbols.getGroupingSeparator());
dest.insert(index, (char) (symbols.getZeroDigit() + dig));
@@ -602,7 +602,7 @@
}
// Append group separator if required.
- if (groupingUsed && count > 0 && count % groupingSize == 0)
+ if (groupingUsed && count > 0 && groupingSize != 0 && count % groupingSize == 0)
dest.insert(index, symbols.getGroupingSeparator());
dest.insert(index, (char) (symbols.getZeroDigit() + dig));
@@ -748,7 +748,8 @@
// FIXME: what about grouping size?
if (groupingUsed && c == symbols.getGroupingSeparator())
{
- if (last_group != -1
+ if (last_group != -1
+ && groupingSize != 0
&& (index - last_group) % groupingSize != 0)
{
pos.setErrorIndex(index);
@@ -765,7 +766,8 @@
break;
else if (c == symbols.getDecimalSeparator())
{
- if (last_group != -1
+ if (last_group != -1
+ && groupingSize != 0
&& (index - last_group) % groupingSize != 0)
{
pos.setErrorIndex(index);