aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2000-08-20 21:51:19 +0000
committerMark Wielaard <mark@gcc.gnu.org>2000-08-20 21:51:19 +0000
commit8559f9bb2f3d3bb300d21df3ad41901dc6619121 (patch)
treef8b19485e6bf07c2c6401e9250d3f27bdbc43fd8 /libjava/java
parent3cb553b4684a17ca436be66895be0aeaee83644f (diff)
downloadgcc-8559f9bb2f3d3bb300d21df3ad41901dc6619121.zip
gcc-8559f9bb2f3d3bb300d21df3ad41901dc6619121.tar.gz
gcc-8559f9bb2f3d3bb300d21df3ad41901dc6619121.tar.bz2
Adler32.java: Make private variables really private
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
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/util/zip/Adler32.java4
-rw-r--r--libjava/java/util/zip/CRC32.java4
-rw-r--r--libjava/java/util/zip/CheckedInputStream.java1
-rw-r--r--libjava/java/util/zip/InflaterInputStream.java1
-rw-r--r--libjava/java/util/zip/ZipEntry.java2
-rw-r--r--libjava/java/util/zip/ZipFile.java7
-rw-r--r--libjava/java/util/zip/ZipInputStream.java12
7 files changed, 25 insertions, 6 deletions
diff --git a/libjava/java/util/zip/Adler32.java b/libjava/java/util/zip/Adler32.java
index fc9596c..e7afeab 100644
--- a/libjava/java/util/zip/Adler32.java
+++ b/libjava/java/util/zip/Adler32.java
@@ -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 ()
{
diff --git a/libjava/java/util/zip/CRC32.java b/libjava/java/util/zip/CRC32.java
index 535cf18..1abbcad 100644
--- a/libjava/java/util/zip/CRC32.java
+++ b/libjava/java/util/zip/CRC32.java
@@ -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 ()
diff --git a/libjava/java/util/zip/CheckedInputStream.java b/libjava/java/util/zip/CheckedInputStream.java
index fce050d..0901743 100644
--- a/libjava/java/util/zip/CheckedInputStream.java
+++ b/libjava/java/util/zip/CheckedInputStream.java
@@ -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);
}
diff --git a/libjava/java/util/zip/InflaterInputStream.java b/libjava/java/util/zip/InflaterInputStream.java
index c5840e7..92b897a 100644
--- a/libjava/java/util/zip/InflaterInputStream.java
+++ b/libjava/java/util/zip/InflaterInputStream.java
@@ -93,6 +93,7 @@ public class InflaterInputStream extends FilterInputStream
break;
n -= r;
s += r;
+ min = (int) Math.min(n, 1024);
}
return s;
diff --git a/libjava/java/util/zip/ZipEntry.java b/libjava/java/util/zip/ZipEntry.java
index cf8d98b..99cb3aa 100644
--- a/libjava/java/util/zip/ZipEntry.java
+++ b/libjava/java/util/zip/ZipEntry.java
@@ -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;
}
diff --git a/libjava/java/util/zip/ZipFile.java b/libjava/java/util/zip/ZipFile.java
index 22ed74b..43d7226 100644
--- a/libjava/java/util/zip/ZipFile.java
+++ b/libjava/java/util/zip/ZipFile.java
@@ -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();
diff --git a/libjava/java/util/zip/ZipInputStream.java b/libjava/java/util/zip/ZipInputStream.java
index a147b22..79efb59 100644
--- a/libjava/java/util/zip/ZipInputStream.java
+++ b/libjava/java/util/zip/ZipInputStream.java
@@ -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;
}