Adler32.java: Make private variables really private
authorMark Wielaard <mark@klomp.org>
Sun, 20 Aug 2000 21:51:19 +0000 (21:51 +0000)
committerMark Wielaard <mark@gcc.gnu.org>
Sun, 20 Aug 2000 21:51:19 +0000 (21:51 +0000)
2000-08-20  Mark Wielaard  <mark@klomp.org>

    * java/util/zip/Adler32.java: Make private variables really private
    * java/util/zip/CRC32.java: Make private variables really private
    * java/util/zip/CheckedInputStream.java: skip() could skip to much bytes
    * java/util/zip/InflaterInputStream.java: skip() could skip to much bytes
    * java/util/zip/ZipEntry.java: setCompressedSize() didn't check input
    * java/util/zip/ZipFile.java: size() new 1.2 method
    * java/util/zip/ZipInputStream.java: Use createZipEntry not new ZipEntry.
    since 1.2 available() always returns just 1 or 0 when closed

From-SVN: r35826

libjava/ChangeLog
libjava/java/util/zip/Adler32.java
libjava/java/util/zip/CRC32.java
libjava/java/util/zip/CheckedInputStream.java
libjava/java/util/zip/InflaterInputStream.java
libjava/java/util/zip/ZipEntry.java
libjava/java/util/zip/ZipFile.java
libjava/java/util/zip/ZipInputStream.java

index 522fdeebe17dfb9a5b43875616b6eb37c0825d4a..f6fede309c04b055f4de5fbe14db7e3c2633b38a 100644 (file)
@@ -1,3 +1,14 @@
+2000-08-20  Mark Wielaard  <mark@klomp.org>
+
+       * java/util/zip/Adler32.java: Make private variables really private
+       * java/util/zip/CRC32.java: Make private variables really private
+       * java/util/zip/CheckedInputStream.java: skip() could skip to much bytes
+       * java/util/zip/InflaterInputStream.java: skip() could skip to much bytes
+       * java/util/zip/ZipEntry.java: setCompressedSize() didn't check input
+       * java/util/zip/ZipFile.java: size() new 1.2 method
+       * java/util/zip/ZipInputStream.java: Use createZipEntry not new ZipEntry.
+    since 1.2 available() always returns just 1 or 0 when closed
+
 Sun Aug 20 12:33:43 2000  Anthony Green  <green@redhat.com>
 
        * java/util/jar/JarFile.java: Don't call
index fc9596cdf122dece68723eb60df72d79325831d0..e7afeabde164ce2487292e3b5e981ecd45b8fc1a 100644 (file)
@@ -24,8 +24,8 @@ public class Adler32 implements Checksum
 {
   private static int BASE = 65521; /* largest prime smaller than 65536 */
 
-  int s1;
-  int s2;
+  private int s1;
+  private int s2;
 
   public Adler32 ()
   {
index 535cf184c72b8a43f657e186ca8bf8aa3e8fa987..1abbcad1d9779c6cb76ed451c42de890cb9ed981 100644 (file)
@@ -22,9 +22,9 @@ package java.util.zip;
 
 public class CRC32 implements Checksum
 {
-  int crc = 0;
+  private int crc = 0;
 
-  static int[] crc_table = make_crc_table();
+  private static int[] crc_table = make_crc_table();
 
   /* Make the table for a fast CRC. */
   static int[] make_crc_table ()
index fce050d2a73ba6b8f8930771161c4d686e05f63e..0901743e6a7ece70aca667d6af036beeb6d0bdd5 100644 (file)
@@ -69,6 +69,7 @@ public class CheckedInputStream extends FilterInputStream
          break;
        n -= r;
        s += r;
+       min = (int) Math.min(n, 1024);
        sum.update(buf, 0, r);
       }
 
index c5840e7a5fae073f722629265e6e886ba6d65caf..92b897a32e452609b84996886b8ec6f8dfd961fc 100644 (file)
@@ -93,6 +93,7 @@ public class InflaterInputStream extends FilterInputStream
          break;
        n -= r;
        s += r;
+       min = (int) Math.min(n, 1024);
       }
 
     return s;
index cf8d98b444567cf70c6409d0a874aae9cf5f8012..99cb3aacb2212f6cc85c7083c5bf66c18a9e3e1f 100644 (file)
@@ -102,7 +102,7 @@ public class ZipEntry implements ZipConstants, Cloneable
   
   public void setCompressedSize (long compressedSize)
   {
-    if (size < 0 || size > 0xffffffffL)
+    if (compressedSize < 0 || compressedSize > 0xffffffffL)
       throw new IllegalArgumentException ();
     this.compressedSize = compressedSize;
   }
index 22ed74b6e78f7e3cb92118e2ba5213bde1823fc3..43d72267aea46eb019f70798af5296cab2b2abdd 100644 (file)
@@ -141,6 +141,13 @@ public class ZipFile implements ZipConstants
 
   public String getName () { return name; }
 
+  public int size () {
+    if (entries == null)
+      throw new IllegalStateException("ZipFile already closed");
+    else
+      return numEntries;
+  }
+
   private int readu2 () throws IOException
   {
     int byte0 = file.read();
index a147b228a69aa0e2d06c8878e90b0088656e8371..79efb59f06c5b89081d3c4f7b1780d6f8781c0ae 100644 (file)
@@ -89,7 +89,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
     int extraLength = readu2();
     byte[] bname = new byte[filenameLength];
     readFully(bname);
-    ZipEntry entry = new ZipEntry(new String(bname, "8859_1"));
+    ZipEntry entry = createZipEntry(new String(bname, "8859_1"));
     if (extraLength > 0)
       {
        byte[] bextra = new byte[extraLength];
@@ -160,6 +160,13 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
     return count;
   }
 
+  public int available() {
+    if (closed)
+      return 0;
+    else
+      return 1;
+  }
+
   private void readFully (byte[] b)  throws IOException
   {
     int off = 0;
@@ -222,6 +229,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
   public void close ()  throws IOException
   {
     current = null;
+    closed = true;
     super.close();
   }
 
@@ -231,4 +239,6 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
   private int avail;
   // Number of bytes we can read from underlying stream.
   private int compressed_bytes;
+  // Is this ZipInputStream closed? Set by the close() method.
+  private boolean closed = false;
 }