DecimalFormat.java (format): avoid ArithmeticException when groupingSize is 0.

2003-08-04  David P Grove  <groved@us.ibm.com>

	* java/text/DecimalFormat.java (format): avoid ArithmeticException
	when groupingSize is 0.
	(parse): Likewise.

From-SVN: r70156
This commit is contained in:
David P Grove 2003-08-04 21:21:01 +00:00 committed by Tom Tromey
parent 03aa99d49f
commit 66fe55d120
2 changed files with 12 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2003-08-04 David P Grove <groved@us.ibm.com>
* java/text/DecimalFormat.java (format): avoid ArithmeticException
when groupingSize is 0.
(parse): Likewise.
2003-08-04 Matthias Klose <doko@debian.org>
* libart.m4: check for libart-config binary

View File

@ -474,7 +474,7 @@ public class DecimalFormat extends NumberFormat
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 @@ public class DecimalFormat extends NumberFormat
}
// 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));
@ -749,6 +749,7 @@ public class DecimalFormat extends NumberFormat
if (groupingUsed && c == symbols.getGroupingSeparator())
{
if (last_group != -1
&& groupingSize != 0
&& (index - last_group) % groupingSize != 0)
{
pos.setErrorIndex(index);
@ -766,6 +767,7 @@ public class DecimalFormat extends NumberFormat
else if (c == symbols.getDecimalSeparator())
{
if (last_group != -1
&& groupingSize != 0
&& (index - last_group) % groupingSize != 0)
{
pos.setErrorIndex(index);