[kaffe] CVS kaffe (dalibor): Resynced java/util/zip/ with GNU Classpath

Kaffe CVS cvs-commits at kaffe.org
Wed Apr 21 09:56:02 PDT 2004


PatchSet 4671 
Date: 2004/04/21 14:59:05
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Resynced java/util/zip/ with GNU Classpath

2004-04-21  Dalibor Topic <robilad at kaffe.org>

        * libraries/javalib/java/util/zip/CheckedInputStream.java,
        libraries/javalib/java/util/zip/CheckedOutputStream.java:
        Reverted to versions from Classpath, since the differences
        were just in sorting of imports.

        * libraries/javalib/java/util/zip/GZIPInputStream.java,
        libraries/javalib/java/util/zip/GZIPOutputStream.java,
        libraries/javalib/java/util/zip/InflaterInputStream.java:
        Resynced with GNU Classpath.

        2004-04-12  Michael Koch  <konqueror at gmx.de>

        * java/util/zip/DeflaterOutputStream.java
        (write): Removed debug code.
        * java/util/zip/GZIPInputStream.java: Jalopied.
        * java/util/zip/GZIPOutputStream.java: Jalopied
        (write): Update CRC sum after actually writing data.
        * java/util/zip/InflaterInputStream.java: Jalopied.
        (InflaterInputStream): Check arguments before setting fields.
        (markSupported): Removed.

Members: 
	ChangeLog:1.2247->1.2248 
	libraries/javalib/java/util/zip/CheckedInputStream.java:1.3->1.4 
	libraries/javalib/java/util/zip/CheckedOutputStream.java:1.3->1.4 
	libraries/javalib/java/util/zip/GZIPInputStream.java:1.11->1.12 
	libraries/javalib/java/util/zip/GZIPOutputStream.java:1.5->1.6 
	libraries/javalib/java/util/zip/InflaterInputStream.java:1.8->1.9 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2247 kaffe/ChangeLog:1.2248
--- kaffe/ChangeLog:1.2247	Wed Apr 21 12:20:19 2004
+++ kaffe/ChangeLog	Wed Apr 21 14:59:05 2004
@@ -1,5 +1,28 @@
 2004-04-21  Dalibor Topic <robilad at kaffe.org>
 
+        * libraries/javalib/java/util/zip/CheckedInputStream.java,
+        libraries/javalib/java/util/zip/CheckedOutputStream.java:
+	Reverted to versions from Classpath, since the differences
+	were just in sorting of imports.
+
+        * libraries/javalib/java/util/zip/GZIPInputStream.java,
+        libraries/javalib/java/util/zip/GZIPOutputStream.java,
+        libraries/javalib/java/util/zip/InflaterInputStream.java:
+	Resynced with GNU Classpath.
+
+	2004-04-12  Michael Koch  <konqueror at gmx.de>
+
+        * java/util/zip/DeflaterOutputStream.java
+        (write): Removed debug code.
+        * java/util/zip/GZIPInputStream.java: Jalopied.
+        * java/util/zip/GZIPOutputStream.java: Jalopied
+        (write): Update CRC sum after actually writing data.
+        * java/util/zip/InflaterInputStream.java: Jalopied.
+        (InflaterInputStream): Check arguments before setting fields.
+        (markSupported): Removed.
+
+2004-04-21  Dalibor Topic <robilad at kaffe.org>
+
 	* libraries/javalib/javax/naming/spi/DirStateFactory.java:
 	Resynced with GNU Classpath.
 
Index: kaffe/libraries/javalib/java/util/zip/CheckedInputStream.java
diff -u kaffe/libraries/javalib/java/util/zip/CheckedInputStream.java:1.3 kaffe/libraries/javalib/java/util/zip/CheckedInputStream.java:1.4
--- kaffe/libraries/javalib/java/util/zip/CheckedInputStream.java:1.3	Mon Mar 22 11:25:12 2004
+++ kaffe/libraries/javalib/java/util/zip/CheckedInputStream.java	Wed Apr 21 14:59:06 2004
@@ -38,8 +38,8 @@
 package java.util.zip;
 
 import java.io.FilterInputStream;
-import java.io.IOException;
 import java.io.InputStream;
+import java.io.IOException;
 
 /* Written using on-line Java Platform 1.2 API Specification
  * and JCL book.
Index: kaffe/libraries/javalib/java/util/zip/CheckedOutputStream.java
diff -u kaffe/libraries/javalib/java/util/zip/CheckedOutputStream.java:1.3 kaffe/libraries/javalib/java/util/zip/CheckedOutputStream.java:1.4
--- kaffe/libraries/javalib/java/util/zip/CheckedOutputStream.java:1.3	Mon Mar 22 11:25:13 2004
+++ kaffe/libraries/javalib/java/util/zip/CheckedOutputStream.java	Wed Apr 21 14:59:06 2004
@@ -38,8 +38,8 @@
 package java.util.zip;
 
 import java.io.FilterOutputStream;
-import java.io.IOException;
 import java.io.OutputStream;
+import java.io.IOException;
 
 /* Written using on-line Java Platform 1.2 API Specification
  * and JCL book.
Index: kaffe/libraries/javalib/java/util/zip/GZIPInputStream.java
diff -u kaffe/libraries/javalib/java/util/zip/GZIPInputStream.java:1.11 kaffe/libraries/javalib/java/util/zip/GZIPInputStream.java:1.12
--- kaffe/libraries/javalib/java/util/zip/GZIPInputStream.java:1.11	Mon Mar 22 11:25:13 2004
+++ kaffe/libraries/javalib/java/util/zip/GZIPInputStream.java	Wed Apr 21 14:59:06 2004
@@ -37,9 +37,9 @@
 
 package java.util.zip;
 
-import java.io.EOFException;
-import java.io.IOException;
 import java.io.InputStream;
+import java.io.IOException;
+import java.io.EOFException;
 
 /**
  * This filter stream is used to decompress a "GZIP" format stream. 
@@ -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: kaffe/libraries/javalib/java/util/zip/GZIPOutputStream.java
diff -u kaffe/libraries/javalib/java/util/zip/GZIPOutputStream.java:1.5 kaffe/libraries/javalib/java/util/zip/GZIPOutputStream.java:1.6
--- kaffe/libraries/javalib/java/util/zip/GZIPOutputStream.java:1.5	Wed Feb  4 19:07:15 2004
+++ kaffe/libraries/javalib/java/util/zip/GZIPOutputStream.java	Wed Apr 21 14:59:06 2004
@@ -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: kaffe/libraries/javalib/java/util/zip/InflaterInputStream.java
diff -u kaffe/libraries/javalib/java/util/zip/InflaterInputStream.java:1.8 kaffe/libraries/javalib/java/util/zip/InflaterInputStream.java:1.9
--- kaffe/libraries/javalib/java/util/zip/InflaterInputStream.java:1.8	Mon Mar 22 11:25:13 2004
+++ kaffe/libraries/javalib/java/util/zip/InflaterInputStream.java	Wed Apr 21 14:59:06 2004
@@ -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.
 
@@ -38,8 +39,8 @@
 package java.util.zip;
 
 import java.io.FilterInputStream;
-import java.io.IOException;
 import java.io.InputStream;
+import java.io.IOException;
 
 /**
  * This filter stream is used to decompress data compressed in the "deflate"
@@ -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);
   }
 }




More information about the kaffe mailing list