This is the mail archive of the java-patches@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] java.util.zip code updates


Hi,

Here are two small code updates to java.util.zip.

	* java/util/zip/CRC32.java: update(int) ignore the high byte of the int.
	* java/util/zip/InflaterInputStream.java: Add new 1.2 methods available()
	  and close().

OK to commit?

Cheers,

Mark

Index: CRC32.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/zip/CRC32.java,v
retrieving revision 1.4
diff -u -u -r1.4 CRC32.java
--- CRC32.java	2000/08/20 21:51:19	1.4
+++ CRC32.java	2000/11/16 00:35:40
@@ -52,10 +52,15 @@
 
   public void reset () { crc = 0; }
 
+  /**
+   * Adds one byte to the data checksum.
+   *
+   * @param bval the data value to add. The high byte of the int is ignored.
+   */
   public void update (int bval)
   {
     int c = ~crc;
-    c = crc_table[(c ^ bval) & 0xff] ^ (c >>> 8);
+    c = crc_table[(c ^ (bval & 0xff)) & 0xff] ^ (c >>> 8);
     crc = ~c;
   }
 
Index: InflaterInputStream.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/zip/InflaterInputStream.java,v
retrieving revision 1.8
diff -u -u -r1.8 InflaterInputStream.java
--- InflaterInputStream.java	2000/08/24 22:48:12	1.8
+++ InflaterInputStream.java	2000/11/16 00:35:40
@@ -101,6 +101,29 @@
     return s;
   }
 
+  /**
+   * Returns 0 if the InflaterInputStream is closed and 1 otherwise.
+   *
+   * @since 1.2
+   */
+  public int available() {
+    if (closed)
+      return 0;
+    else
+      return 1;
+  }
+
+  /**
+   * Closes this ZipInputStream.
+   *
+   * @since 1.2
+   */
+  public void close ()  throws IOException
+  {
+    closed = true;
+    super.close();
+  }
+
   // Buffer for delivering uncompressed data to inflater.
   protected byte[] buf;
 
@@ -109,4 +132,7 @@
 
   // Number of read bytes in buf.
   protected int len;
+
+  // Is this InflaterInputStream closed? Set by the close() method.
+  private boolean closed = false;
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]