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]

Re: PATCH: PR 7766


>>>>> "Jesse" == Jesse Rosenstock <jmr@ugcs.caltech.edu> writes:

Jesse> Here's a possible patch and test case for PR 7766:

Thanks.

I'm checking in a slightly modified version, which sets entryAtEOF in
close().  Otherwise available() will return `1' after close().  New
patch appended.

BTW, it is easier for me if you write and send a ChangeLog entry with
patches.  It is also marginally easier, for patches I'm going to
commit, if the `cvs diff' is run from either the top (gcc) directory
or the libjava directory.  (I have my mailer set up to let me apply
patches directly from email, but it isn't smart about choosing the
base directory, and I've only set it up with the most common ones.)

Thanks for sending the test case.  It would be preferable to have a
self-contained test case.  For library bugs, a test case in the Mauve
style is easier to work with.  (Your test is close, though.  The
self-contain-edness is really the problem...)

Also: now that your paperwork has gone through we can get you an
account if you're interested.  This will ease the checkin process a
bit.  Send me email if you want to pursue this.

Tom

Index: ChangeLog
from  Jesse Rosenstock  <jmr@ugcs.caltech.edu>

	Fix for PR libgcj/7766:
	* java/util/zip/ZipInputStream.java (entryAtEOF): New field.
	(getNextEntry): Set it.
	(closeEntry): Likewise.
	(read): Likewise.
	(close): Likewise.
	(available): Use it.

Index: java/util/zip/ZipInputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/zip/ZipInputStream.java,v
retrieving revision 1.14
diff -u -r1.14 ZipInputStream.java
--- java/util/zip/ZipInputStream.java 15 Jun 2002 18:31:13 -0000 1.14
+++ java/util/zip/ZipInputStream.java 25 Sep 2002 20:02:02 -0000
@@ -61,6 +61,7 @@
   private int method;
   private int flags;
   private int avail;
+  private boolean entryAtEOF;
 
   /**
    * Creates a new Zip input stream, reading a zip archive.
@@ -150,7 +151,8 @@
 	return null;
       }
     if (header != LOCSIG)
-      throw new ZipException("Wrong Local header signature" + Integer.toHexString(header));
+      throw new ZipException("Wrong Local header signature"
+			     + Integer.toHexString(header));
     /* skip version */
     readLeShort();
     flags = readLeShort();
@@ -171,6 +173,7 @@
     String name = new String(buffer);
     
     entry = createZipEntry(name);
+    entryAtEOF = false;
     entry.setMethod(method);
     if ((flags & 8) == 0)
       {
@@ -252,11 +255,12 @@
     if (method == ZipOutputStream.DEFLATED)
       inf.reset();
     entry = null;
+    entryAtEOF = true;
   }
 
   public int available() throws IOException
   {
-    return entry != null ? 1 : 0;
+    return entryAtEOF ? 0 : 1;
   }
 
   /**
@@ -335,6 +339,7 @@
 	  throw new ZipException("CRC mismatch");
 	crc.reset();
 	entry = null;
+	entryAtEOF = true;
       }
     return len;
   }
@@ -348,6 +353,7 @@
     super.close();
     crc = null;
     entry = null;
+    entryAtEOF = true;
   }
 
   /**


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