]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
DecimalFormat.java (format): avoid ArithmeticException when groupingSize is 0.
authorDavid P Grove <groved@us.ibm.com>
Mon, 4 Aug 2003 21:21:01 +0000 (21:21 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Mon, 4 Aug 2003 21:21:01 +0000 (21:21 +0000)
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

libjava/ChangeLog
libjava/java/text/DecimalFormat.java

index f4861c0366fd12eb2c5faf93eb716c0356474cd5..04f343782c24870dccf35bf995bac79d76d9f8a1 100644 (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
index 7f946173fee9f16f1e6cdd560e96f94330ed431c..0cf2d8fff3bae256da9555d3a2431fce6c985195 100644 (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));
@@ -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);