Few bugs & patches

Tatu Saloranta tatu at hypermall.net
Tue Jan 18 06:22:45 PST 2000


Archie Cobbs wrote:
> 
> Tatu Saloranta writes:
> > I tried to report these bugs via Bug-tracking system at www.kaffe.org,
> > but report bounced back for some reason. So, as the bug reports &
> > patches
> > are rather small, I hope it's ok to send them to the list so someone
> > with access can use the patches (after checking they're ok).
> > So, here goes:
> 
> Sorry, but could you resend your patches in 'diff -u' format?

Ah, it's been a while since I used diff, so here are the unified diffs.

Btw; I noticed that GridBagLayout.java still has some problems with
gridy = GridBagConstraints.RELATIVE. According to Java1.1 docs, RELATIVE
means that the component should be added relative to the last inserted
component; kaffe uses the bottom/rightmost consequtively added component
(ie. loops from index 0 until first null entry). Should be easy to fix,
and will do that later on.

Another question regarding Java 1.2 (and/or Swing) - compatibility.
Java.awt.Component needs 'getSize(Dimension d)' (and getBounds(Rectangle
r)
as well) methods. These could be used internally for optimizations too,
so there would be less need to allocate intermediate Dimension/Rectangle
objects. Should those be added?

Ok, here are the actual patches:

--- libraries/javalib/java/awt/widgets/Choice.java.old  Sat Jan 15
19:45:10 2000
+++ libraries/javalib/java/awt/widgets/Choice.java      Sat Jan 15
19:45:53 2000
@@ -302,9 +302,21 @@
  * @deprecated
  */
 public Dimension preferredSize () {
-       Dimension d = entry.getPreferredSize();
-       d.width += BTN_WIDTH + 2*BORDER_WIDTH;
-       return d;
+    /* Instead of simply asking the current selection's size,
+     * we better find the maximum...
+     */
+    //Dimension d = entry.getPreferredSize();
+    Dimension d = new Dimension();
+    for (int i = items.size(); --i >= 0; ) {
+       Dimension d2 = entry.getPreferredSize(
+          ((String) items.elementAt(i)).length());
+       if (d2.width > d.width)
+           d.width = d2.width;
+       if (d2.height > d.height)
+           d.height = d2.height;
+    }
+    d.width += BTN_WIDTH + 2*BORDER_WIDTH;
+    return d;
 }

 void process ( ItemEvent e ) {

---
--- libraries/javalib/java/awt/GridBagLayout.java.old   Sat Jan 15
19:43:34 2000
+++ libraries/javalib/java/awt/GridBagLayout.java       Sat Jan 15
19:43:35 2000
@@ -356,6 +356,7 @@
                                else if ( lcc.gridwidth == cc.REMAINDER
) {
                                        y1 += Math.max( lcc.gridheight,
1);
                                }
+                               else y1 = -1;
                        }
                        else {
                                y1 = cc.gridy;
---
--- libraries/javalib/java/io/StreamTokenizer.java.old  Tue Jan 18
09:12:31 2000
+++ libraries/javalib/java/io/StreamTokenizer.java      Tue Jan 18
09:12:46 2000
@@ -133,11 +133,12 @@
                /* Parse string and return word */
                parseStringQuoteChars(chr);
        }
-       else if (chr=='/' && CPlusPlusComments) {
+       else if (chr=='/' && CPlusPlusComments
+                && parseCPlusPlusCommentChars()) {
                /* Check for C++ comments */
-               parseCPlusPlusCommentChars();
        }
-       else if (chr=='/' && CComments) {
+       else if (chr=='/' && CComments
+                && parseCCommentChars()) {
                /* Check for C comments */
        }
        else {
@@ -149,7 +150,6 @@
                else {
                        ttype = chr;
                }
-               parseCCommentChars();
        }
 }

@@ -341,33 +341,34 @@
        sval = buffer.toString();
 }

-private void parseCPlusPlusCommentChars() throws IOException {
+private boolean parseCPlusPlusCommentChars() throws IOException {
        int next = chrRead();
        if (next == '/') {
                /* C++ comment */
                skipLine();

                nextTokenType();
+               return true;
        }
        else {
                unRead(next);
-
-               ttype = '/';
+               return false;
        }
 }

-private void parseCCommentChars() throws IOException {
+private boolean parseCCommentChars() throws IOException {
        int next = chrRead();
        if (next == '*') {
                /* C comment */
                skipCComment();

                nextTokenType();
+               return true;
        }
        else {
                unRead(next);

-               ttype = '/';
+               return false;
        }
 }

---


More information about the kaffe mailing list