aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorDavid P Grove <groved@us.ibm.com>2003-08-04 21:21:01 +0000
committerTom Tromey <tromey@gcc.gnu.org>2003-08-04 21:21:01 +0000
commit66fe55d120b36a2fc0753d26acb903667edecdd6 (patch)
tree265cf8f833b4908c7408c5f264688cc72c99ccee /libjava
parent03aa99d49fc01b8416a5bec9cbf839da9b7962c8 (diff)
downloadgcc-66fe55d120b36a2fc0753d26acb903667edecdd6.zip
gcc-66fe55d120b36a2fc0753d26acb903667edecdd6.tar.gz
gcc-66fe55d120b36a2fc0753d26acb903667edecdd6.tar.bz2
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
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog6
-rw-r--r--libjava/java/text/DecimalFormat.java10
2 files changed, 12 insertions, 4 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index f4861c0..04f3437 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -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
diff --git a/libjava/java/text/DecimalFormat.java b/libjava/java/text/DecimalFormat.java
index 7f94617..0cf2d8f 100644
--- a/libjava/java/text/DecimalFormat.java
+++ b/libjava/java/text/DecimalFormat.java
@@ -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));
@@ -748,7 +748,8 @@ public class DecimalFormat extends NumberFormat
// 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 @@ public class DecimalFormat extends NumberFormat
break;
else if (c == symbols.getDecimalSeparator())
{
- if (last_group != -1
+ if (last_group != -1
+ && groupingSize != 0
&& (index - last_group) % groupingSize != 0)
{
pos.setErrorIndex(index);