This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Two more 4.1 branch patches (from 0.21-pre)


Hi,

Here are two more candidates for putting on the 4.1 branch. Again
small, unintrusive, have bug numbers associated with them and mauve
tests. OK?

2006-02-04  Mark Wielaard  <mark@klomp.org>

    Backports from 0.21.

    2006-01-26  Mark Wielaard  <mark@klomp.org>

    Fixes bug #25970 reported by Michael Kay <mike@saxonica.com>
    * java/math/BigDecimal.java (compareTo): Don't strip trailing zeros.
    Add trailing zeros to the fraction of the decimal with the smallest
    scale.

    2006-02-02  Mark Wielaard  <mark@klomp.org>

    Fixes bug #25769 reported by Artemus Harper <subanark@gmail.com>
    * java/util/AbstractCollection.java (toString): Only use Iterator,
    check whether collection contains itself.

These are probably the last "easy" patches. There is of course a lot
more on the trunk and in classpath. In my eyes we should at least think
about the beans and regex updates. It looks like xml would be nice to
update also, but that is not a really clean patch since there has been a
lot of new development combined with bug fixing. There are also lots of
security, crypto, awt and swing updates, but those are so huge that it
only makes sense to take them all, or none at all imho.

So what are the "rules" for the 4.1 branch?

Cheers,

Mark
2006-01-26  Mark Wielaard  <mark@klomp.org>

        Fixes bug #25970 reported by Michael Kay <mike@saxonica.com>
        * java/math/BigDecimal.java (compareTo): Don't strip trailing zeros.
        Add trailing zeros to the fraction of the decimal with the smallest
        scale.

Index: java/math/BigDecimal.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- java/math/BigDecimal.java	21 Sep 2005 17:00:33 -0000	1.20
+++ java/math/BigDecimal.java	26 Jan 2006 13:43:44 -0000	1.21
@@ -365,16 +365,13 @@
 
     // quotients are the same, so compare remainders
 
-    // remove trailing zeros
-    if (thisParts[1].equals (BigInteger.valueOf (0)) == false)
-      while (thisParts[1].mod (BigInteger.valueOf (10)).equals
-	     (BigInteger.valueOf (0)))
-      thisParts[1] = thisParts[1].divide (BigInteger.valueOf (10));
-    // again...
-    if (valParts[1].equals(BigInteger.valueOf (0)) == false)
-      while (valParts[1].mod (BigInteger.valueOf (10)).equals
-	     (BigInteger.valueOf (0)))
-	valParts[1] = valParts[1].divide (BigInteger.valueOf (10));
+    // Add some trailing zeros to the remainder with the smallest scale
+    if (scale < val.scale)
+      thisParts[1] = thisParts[1].multiply
+			(BigInteger.valueOf (10).pow (val.scale - scale));
+    else if (scale > val.scale)
+      valParts[1] = valParts[1].multiply
+			(BigInteger.valueOf (10).pow (scale - val.scale));
 
     // and compare them
     return thisParts[1].compareTo (valParts[1]);
2006-02-02  Mark Wielaard  <mark@klomp.org>

        Fixes bug #25769 reported by Artemus Harper <subanark@gmail.com>
        * java/util/AbstractCollection.java (toString): Only use Iterator,
        check whether collection contains itself.

Index: java/util/AbstractCollection.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/AbstractCollection.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- java/util/AbstractCollection.java	2 Jul 2005 20:32:41 -0000	1.17
+++ java/util/AbstractCollection.java	2 Feb 2006 13:29:01 -0000	1.18
@@ -423,7 +423,9 @@
    * of the form "[a, b, ...]" where a and b etc are the results of calling
    * toString on the elements of the collection. This implementation obtains an
    * Iterator over the Collection and adds each element to a StringBuffer as it
-   * is returned by the iterator.
+   * is returned by the iterator. "<this>" is inserted when the collection
+   * contains itself (only works for direct containment, not for collections
+   * inside collections).
    *
    * @return a String representation of the Collection
    */
@@ -431,10 +433,16 @@
   {
     Iterator itr = iterator();
     StringBuffer r = new StringBuffer("[");
-    for (int pos = size(); pos > 0; pos--)
+    boolean hasNext = itr.hasNext();
+    while (hasNext)
       {
-        r.append(itr.next());
-        if (pos > 1)
+        Object o = itr.next();
+	if (o == this)
+	  r.append("<this>");
+	else
+	  r.append(o);
+	hasNext = itr.hasNext();
+        if (hasNext)
           r.append(", ");
       }
     r.append("]");

Attachment: signature.asc
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]