aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2006-07-12 17:00:49 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2006-07-12 17:00:49 +0000
commitd42ffc1e7b9b65148dc92611c07780bba2921071 (patch)
tree52cea91df9c54af730703326dbdbdab4947f5b41 /libjava/classpath
parent2be9ef447cf2b282645c7cf33abc03520cd44b0c (diff)
PR libgcj/27271:
* java/util/zip/ZipFile.java (getInputStream): Call addDummyByte on PartialInputStream. (PartialInputStream.dummyByteCount): New field. (PartialInputStream.fillBuffer): Handle dummy byte. (PartialInputStream.read): Likewise. (PartialInputStream.addDummyByte): New method. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@115378 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath')
-rw-r--r--libjava/classpath/ChangeLog.gcj10
-rw-r--r--libjava/classpath/java/util/zip/ZipFile.java30
2 files changed, 35 insertions, 5 deletions
diff --git a/libjava/classpath/ChangeLog.gcj b/libjava/classpath/ChangeLog.gcj
index 7304d663d72..55eab669cb9 100644
--- a/libjava/classpath/ChangeLog.gcj
+++ b/libjava/classpath/ChangeLog.gcj
@@ -1,3 +1,13 @@
+2006-07-12 Tom Tromey <tromey@redhat.com>
+
+ PR libgcj/27271:
+ * java/util/zip/ZipFile.java (getInputStream): Call addDummyByte
+ on PartialInputStream.
+ (PartialInputStream.dummyByteCount): New field.
+ (PartialInputStream.fillBuffer): Handle dummy byte.
+ (PartialInputStream.read): Likewise.
+ (PartialInputStream.addDummyByte): New method.
+
2006-06-14 Tom Tromey <tromey@redhat.com>
PR java/28024:
diff --git a/libjava/classpath/java/util/zip/ZipFile.java b/libjava/classpath/java/util/zip/ZipFile.java
index b8495516f16..10c8365b833 100644
--- a/libjava/classpath/java/util/zip/ZipFile.java
+++ b/libjava/classpath/java/util/zip/ZipFile.java
@@ -445,6 +445,7 @@ public class ZipFile implements ZipConstants
case ZipOutputStream.STORED:
return inp;
case ZipOutputStream.DEFLATED:
+ inp.addDummyByte();
final Inflater inf = new Inflater(true);
final int sz = (int) entry.getSize();
return new InflaterInputStream(inp, inf)
@@ -520,6 +521,11 @@ public class ZipFile implements ZipConstants
private long bufferOffset;
private int pos;
private long end;
+ // We may need to supply an extra dummy byte to our reader.
+ // See Inflater. We use a count here to simplify the logic
+ // elsewhere in this class. Note that we ignore the dummy
+ // byte in methods where we know it is not needed.
+ private int dummyByteCount;
public PartialInputStream(RandomAccessFile raf, int bufferSize)
throws IOException
@@ -540,8 +546,17 @@ public class ZipFile implements ZipConstants
{
synchronized (raf)
{
- raf.seek(bufferOffset);
- raf.readFully(buffer, 0, (int) Math.min(buffer.length, end - bufferOffset));
+ long len = end - bufferOffset;
+ if (len == 0 && dummyByteCount > 0)
+ {
+ buffer[0] = 0;
+ dummyByteCount = 0;
+ }
+ else
+ {
+ raf.seek(bufferOffset);
+ raf.readFully(buffer, 0, (int) Math.min(buffer.length, len));
+ }
}
}
@@ -555,7 +570,7 @@ public class ZipFile implements ZipConstants
public int read() throws IOException
{
- if (bufferOffset + pos >= end)
+ if (bufferOffset + pos >= end + dummyByteCount)
return -1;
if (pos == buffer.length)
{
@@ -569,9 +584,9 @@ public class ZipFile implements ZipConstants
public int read(byte[] b, int off, int len) throws IOException
{
- if (len > end - (bufferOffset + pos))
+ if (len > end + dummyByteCount - (bufferOffset + pos))
{
- len = (int) (end - (bufferOffset + pos));
+ len = (int) (end + dummyByteCount - (bufferOffset + pos));
if (len == 0)
return -1;
}
@@ -681,5 +696,10 @@ public class ZipFile implements ZipConstants
throw new AssertionError(uee);
}
}
+
+ public void addDummyByte()
+ {
+ dummyByteCount = 1;
+ }
}
}