I'm checking this in.
While merging more of java.util.zip in libgcj (we now only have 2
classes that differ) I found one method where I preferred libgcj's
implementation. The replacement removes an InternalError, which I
think is a definite improvement, the rest seems more cosmetic (but
nevertheless it mattered enough to me to check this in :-)
I also made a little change to move from a hard-coded '8' to use a
named constant.
Tom
2006-03-10 Tom Tromey <[EMAIL PROTECTED]>
* java/util/zip/InflaterInputStream.java (read): Replace with libgcj
implementation.
* java/util/zip/GZIPInputStream.java (readHeader): Use DEFLATED,
not '8'.
Index: java/util/zip/GZIPInputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/zip/GZIPInputStream.java,v
retrieving revision 1.13
diff -u -r1.13 GZIPInputStream.java
--- java/util/zip/GZIPInputStream.java 2 Jul 2005 20:32:44 -0000 1.13
+++ java/util/zip/GZIPInputStream.java 10 Mar 2006 21:07:13 -0000
@@ -207,7 +207,7 @@
/* 2. Check the compression type (must be 8) */
int CM = in.read();
- if (CM != 8)
+ if (CM != Deflater.DEFLATED)
throw new IOException("Error in GZIP header, data not in deflate
format");
headCRC.update(CM);
Index: java/util/zip/InflaterInputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/zip/InflaterInputStream.java,v
retrieving revision 1.17
diff -u -r1.17 InflaterInputStream.java
--- java/util/zip/InflaterInputStream.java 2 Jul 2005 20:32:44 -0000
1.17
+++ java/util/zip/InflaterInputStream.java 10 Mar 2006 21:07:13 -0000
@@ -186,31 +186,35 @@
throw new IOException("stream closed");
if (len == 0)
return 0;
+ if (inf.finished())
+ return - 1;
int count = 0;
- for (;;)
+ while (count == 0)
{
-
- try
- {
- count = inf.inflate(b, off, len);
- }
- catch (DataFormatException dfe)
- {
- throw new ZipException(dfe.getMessage());
- }
-
- if (count > 0)
- return count;
-
- if (inf.needsDictionary()
- | inf.finished())
- return -1;
- else if (inf.needsInput())
- fill();
- else
- throw new InternalError("Don't know what to do");
+ if (inf.needsInput())
+ fill();
+
+ try
+ {
+ count = inf.inflate(b, off, len);
+ }
+ catch (DataFormatException dfe)
+ {
+ throw new ZipException(dfe.getMessage());
+ }
+ if (count == 0)
+ {
+ if (this.len == - 1)
+ {
+ // Couldn't get any more data to feed to the Inflater
+ return - 1;
+ }
+ if (inf.needsDictionary())
+ throw new ZipException("Inflater needs Dictionary");
+ }
}
+ return count;
}
/**