This is the mail archive of the
java-patches@sources.redhat.com
mailing list for the Java project.
java.util.zip patches
- To: java-patches at sources dot redhat dot com
- Subject: java.util.zip patches
- From: Mark Wielaard <mark at klomp dot org>
- Date: Sun, 20 Aug 2000 23:10:01 +0200
Hi,
While writing documentation for the java.util.zip classes I made a couple
of non documentation changes. Is it ok to check these in?
Changelog entry:
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
Cheers,
Mark
Index: java/util/zip/Adler32.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/zip/Adler32.java,v
retrieving revision 1.3
diff -u -r1.3 Adler32.java
--- Adler32.java 2000/03/07 19:55:28 1.3
+++ Adler32.java 2000/08/20 21:01:28
@@ -24,8 +24,8 @@
{
private static int BASE = 65521; /* largest prime smaller than 65536 */
- int s1;
- int s2;
+ private int s1;
+ private int s2;
public Adler32 ()
{
Index: java/util/zip/CRC32.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/zip/CRC32.java,v
retrieving revision 1.3
diff -u -r1.3 CRC32.java
--- CRC32.java 2000/03/07 19:55:28 1.3
+++ CRC32.java 2000/08/20 21:01:28
@@ -22,9 +22,9 @@
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: java/util/zip/CheckedInputStream.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/zip/CheckedInputStream.java,v
retrieving revision 1.3
diff -u -r1.3 CheckedInputStream.java
--- CheckedInputStream.java 2000/03/07 19:55:28 1.3
+++ CheckedInputStream.java 2000/08/20 21:01:28
@@ -69,6 +69,7 @@
break;
n -= r;
s += r;
+ min = (int) Math.min(n, 1024);
sum.update(buf, 0, r);
}
Index: java/util/zip/InflaterInputStream.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/zip/InflaterInputStream.java,v
retrieving revision 1.6
diff -u -r1.6 InflaterInputStream.java
--- InflaterInputStream.java 2000/03/07 19:55:28 1.6
+++ InflaterInputStream.java 2000/08/20 21:01:28
@@ -93,6 +93,7 @@
break;
n -= r;
s += r;
+ min = (int) Math.min(n, 1024);
}
return s;
Index: java/util/zip/ZipEntry.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/zip/ZipEntry.java,v
retrieving revision 1.10
diff -u -r1.10 ZipEntry.java
--- ZipEntry.java 2000/05/20 05:46:20 1.10
+++ ZipEntry.java 2000/08/20 21:01:28
@@ -102,7 +102,7 @@
public void setCompressedSize (long compressedSize)
{
- if (size < 0 || size > 0xffffffffL)
+ if (compressedSize < 0 || compressedSize > 0xffffffffL)
throw new IllegalArgumentException ();
this.compressedSize = compressedSize;
}
Index: java/util/zip/ZipFile.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/zip/ZipFile.java,v
retrieving revision 1.10
diff -u -r1.10 ZipFile.java
--- ZipFile.java 2000/08/20 17:49:12 1.10
+++ ZipFile.java 2000/08/20 21:01:28
@@ -141,6 +141,13 @@
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: java/util/zip/ZipInputStream.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/zip/ZipInputStream.java,v
retrieving revision 1.9
diff -u -r1.9 ZipInputStream.java
--- ZipInputStream.java 2000/08/19 19:54:36 1.9
+++ ZipInputStream.java 2000/08/20 21:01:28
@@ -89,7 +89,7 @@
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 @@
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 void close () throws IOException
{
current = null;
+ closed = true;
super.close();
}
@@ -231,4 +239,6 @@
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;
}