Index: java/util/zip/DeflaterOutputStream.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/util/zip/DeflaterOutputStream.java,v retrieving revision 1.5 diff -u -r1.5 DeflaterOutputStream.java --- java/util/zip/DeflaterOutputStream.java 4 Feb 2004 07:53:45 -0000 1.5 +++ java/util/zip/DeflaterOutputStream.java 12 Apr 2004 12:30:05 -0000 @@ -191,7 +191,6 @@ */ public void write(byte[] buf, int off, int len) throws IOException { - // System.err.println("DOS with off " + off + " and len " + len); def.setInput(buf, off, len); deflate(); } Index: java/util/zip/GZIPInputStream.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/util/zip/GZIPInputStream.java,v retrieving revision 1.7 diff -u -r1.7 GZIPInputStream.java --- java/util/zip/GZIPInputStream.java 4 Feb 2004 07:53:45 -0000 1.7 +++ java/util/zip/GZIPInputStream.java 12 Apr 2004 12:30:05 -0000 @@ -87,7 +87,6 @@ */ protected CRC32 crc; - /** * Indicates whether or not the end of the stream has been reached. */ @@ -319,7 +318,6 @@ readGZIPHeader = true; //System.err.println("Read GZIP header"); } - private void readFooter() throws IOException { Index: java/util/zip/GZIPOutputStream.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/util/zip/GZIPOutputStream.java,v retrieving revision 1.6 diff -u -r1.6 GZIPOutputStream.java --- java/util/zip/GZIPOutputStream.java 4 Feb 2004 07:53:45 -0000 1.6 +++ java/util/zip/GZIPOutputStream.java 12 Apr 2004 12:30:05 -0000 @@ -1,5 +1,5 @@ /* GZIPOutputStream.java - Create a file in gzip format - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,20 +45,21 @@ * The "GZIP" format is described in RFC 1952. * * @author John Leuner + * @author Tom Tromey * @since JDK 1.1 */ +/* Written using on-line Java Platform 1.2 API Specification + * and JCL book. + * Believed complete and correct. + */ public class GZIPOutputStream extends DeflaterOutputStream { - //Variables - - /* CRC-32 value for uncompressed data + /** + * CRC-32 value for uncompressed data */ - - protected CRC32 crc = new CRC32(); - - // Constructors + protected CRC32 crc; /* Creates a GZIPOutputStream with the default buffer size * @@ -66,21 +67,18 @@ * @param out The stream to read data (to be compressed) from * */ - - public GZIPOutputStream(OutputStream out) throws IOException + public GZIPOutputStream(OutputStream out) throws IOException { this(out, 4096); } - /* Creates a GZIPOutputStream with the specified buffer size - * + /** + * Creates a GZIPOutputStream with the specified buffer size * * @param out The stream to read compressed data from - * * @param size Size of the buffer to use */ - - public GZIPOutputStream(OutputStream out, int size) throws IOException + public GZIPOutputStream(OutputStream out, int size) throws IOException { super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size); @@ -112,10 +110,11 @@ // System.err.println("wrote GZIP header (" + gzipHeader.length + " bytes )"); } - public void write(byte[] buf, int off, int len) throws IOException + public synchronized void write(byte[] buf, int off, int len) + throws IOException { - crc.update(buf, off, len); super.write(buf, off, len); + crc.update(buf, off, len); } /** Writes remaining compressed output data to the output stream @@ -129,7 +128,6 @@ public void finish() throws IOException { - super.finish(); int totalin = def.getTotalIn(); Index: java/util/zip/InflaterInputStream.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/util/zip/InflaterInputStream.java,v retrieving revision 1.10 diff -u -r1.10 InflaterInputStream.java --- java/util/zip/InflaterInputStream.java 4 Nov 2003 10:04:16 -0000 1.10 +++ java/util/zip/InflaterInputStream.java 12 Apr 2004 12:30:05 -0000 @@ -1,5 +1,6 @@ /* InflaterInputStream.java - Input stream filter for decompressing - Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 + Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -69,7 +70,6 @@ */ protected int len; - /* * We just use this if we are decoding one byte at a time with the read() call */ @@ -109,17 +109,17 @@ public InflaterInputStream(InputStream in, Inflater inf, int size) { super(in); - this.inf = inf; this.len = 0; - - if (size <= 0) - throw new IllegalArgumentException("size <= 0"); - buf = new byte[size]; //Create the buffer if (in == null) - throw new NullPointerException("InputStream null"); + throw new NullPointerException ("in may not be null"); if (inf == null) - throw new NullPointerException("Inflater null"); + throw new NullPointerException ("inf may not be null"); + if (size < 0) + throw new IllegalArgumentException ("size may not be negative"); + + this.inf = inf; + this.buf = new byte [size]; } /** @@ -128,6 +128,8 @@ */ public int available() throws IOException { + // According to the JDK 1.2 docs, this should only ever return 0 + // or 1 and should not be relied upon by Java programs. return inf.finished() ? 0 : 1; } @@ -181,11 +183,13 @@ */ public int read(byte[] b, int off, int len) throws IOException { - if (len == 0) return 0; + if (len == 0) + return 0; for (;;) { int count; + try { count = inf.inflate(b, off, len); @@ -217,22 +221,12 @@ { if (n < 0) throw new IllegalArgumentException(); - int len = 2048; - if (n < len) - len = (int) n; - byte[] tmp = new byte[len]; - return (long) read(tmp); - } - /** - * Since this stream tends to buffer large (unpredictable?) amounts - * of stuff, it causes problems to the mark/reset mechanism. Hence, - * it claims not to support mark. - * - * @return false - */ - public boolean markSupported() - { - return false; + if (n == 0) + return 0; + + int len = (int) Math.min(n, 2048); + byte[] buf = new byte[len]; + return (long) read(buf); } }