--- /home/cpdev/src/classpath/java/util/zip/InflaterInputStream.java	2005-07-02 21:03:49.000000000 +0000
+++ java/util/zip/InflaterInputStream.java	2005-06-30 05:34:52.000000000 +0000
@@ -1,5 +1,5 @@
 /* InflaterInputStream.java - Input stream filter for decompressing
-   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
@@ -139,9 +139,8 @@
    */
   public synchronized void close() throws IOException
   {
-    if (in != null)
-      in.close();
-    in = null;
+    inf = null;
+    super.close();
   }
 
   /**
@@ -154,10 +153,8 @@
     
     len = in.read(buf, 0, buf.length);
 
-    if (len < 0)
-      throw new ZipException("Deflated stream ends early.");
-    
-    inf.setInput(buf, 0, len);
+    if (len >= 0)
+      inf.setInput(buf, 0, len);
   }
 
   /**
@@ -186,31 +183,35 @@
       throw new IOException("stream closed");
     if (len == 0)
       return 0;
+    if (inf.finished())
+      return -1;
 
     int count = 0;
-    for (;;)
+    while (count == 0)
       {
+	if (inf.needsInput())
+	  fill();
 	
 	try
 	  {
 	    count = inf.inflate(b, off, len);
+	    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");
+	      }
 	  } 
 	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");
       }
+    return count;
   }
 
   /**
