diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-08-04 21:21:01 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-08-04 21:21:01 +0000 |
commit | 404dae7e516264733db802ba5993206de7bb9fc5 (patch) | |
tree | 265cf8f833b4908c7408c5f264688cc72c99ccee /libjava/java/text/DecimalFormat.java | |
parent | 101cc4300cdeb0f4c652a0c91f7f0450f2d64175 (diff) | |
download | gcc-404dae7e516264733db802ba5993206de7bb9fc5.tar.gz |
2003-08-04 David P Grove <groved@us.ibm.com>
* java/text/DecimalFormat.java (format): avoid ArithmeticException
when groupingSize is 0.
(parse): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70156 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/text/DecimalFormat.java')
-rw-r--r-- | libjava/java/text/DecimalFormat.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libjava/java/text/DecimalFormat.java b/libjava/java/text/DecimalFormat.java index 7f946173fee..0cf2d8fff3b 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); |