Commit 66fe55d1 by David P Grove Committed by Tom Tromey

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
parent 03aa99d4
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> 2003-08-04 Matthias Klose <doko@debian.org>
* libart.m4: check for libart-config binary * libart.m4: check for libart-config binary
......
...@@ -474,7 +474,7 @@ public class DecimalFormat extends NumberFormat ...@@ -474,7 +474,7 @@ public class DecimalFormat extends NumberFormat
intPart = Math.floor(intPart / 10); intPart = Math.floor(intPart / 10);
// Append group separator if required. // 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, symbols.getGroupingSeparator());
dest.insert(index, (char) (symbols.getZeroDigit() + dig)); dest.insert(index, (char) (symbols.getZeroDigit() + dig));
...@@ -602,7 +602,7 @@ public class DecimalFormat extends NumberFormat ...@@ -602,7 +602,7 @@ public class DecimalFormat extends NumberFormat
} }
// Append group separator if required. // 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, symbols.getGroupingSeparator());
dest.insert(index, (char) (symbols.getZeroDigit() + dig)); dest.insert(index, (char) (symbols.getZeroDigit() + dig));
...@@ -748,7 +748,8 @@ public class DecimalFormat extends NumberFormat ...@@ -748,7 +748,8 @@ public class DecimalFormat extends NumberFormat
// FIXME: what about grouping size? // FIXME: what about grouping size?
if (groupingUsed && c == symbols.getGroupingSeparator()) if (groupingUsed && c == symbols.getGroupingSeparator())
{ {
if (last_group != -1 if (last_group != -1
&& groupingSize != 0
&& (index - last_group) % groupingSize != 0) && (index - last_group) % groupingSize != 0)
{ {
pos.setErrorIndex(index); pos.setErrorIndex(index);
...@@ -765,7 +766,8 @@ public class DecimalFormat extends NumberFormat ...@@ -765,7 +766,8 @@ public class DecimalFormat extends NumberFormat
break; break;
else if (c == symbols.getDecimalSeparator()) else if (c == symbols.getDecimalSeparator())
{ {
if (last_group != -1 if (last_group != -1
&& groupingSize != 0
&& (index - last_group) % groupingSize != 0) && (index - last_group) % groupingSize != 0)
{ {
pos.setErrorIndex(index); pos.setErrorIndex(index);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment