--- /home/cpdev/src/classpath/java/io/BufferedInputStream.java	2005-07-02 21:03:29.000000000 +0000
+++ java/io/BufferedInputStream.java	2005-06-30 05:34:34.000000000 +0000
@@ -1,5 +1,5 @@
 /* BufferedInputStream.java -- An input stream that implements buffering
-   Copyright (C) 1998, 1999, 2001, 2005  Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2001, 2004, 2005  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -158,7 +158,7 @@
    */
   public synchronized int available() throws IOException
   {
-    return count - pos + super.available();
+    return count - pos + in.available();
   }
 
   /**
@@ -173,7 +173,7 @@
     buf = null;
     pos = count = 0;
     markpos = -1;
-    super.close();
+    in.close();
   }
 
   /**
@@ -273,7 +273,7 @@
     off += totalBytesRead;
     len -= totalBytesRead;
 
-    while (len > 0 && super.available() > 0 && refill())
+    while (len > 0 && in.available() > 0 && refill())
       {
 	int remain = Math.min(count - pos, len);
 	System.arraycopy(buf, pos, b, off, remain);
@@ -327,8 +327,18 @@
 
     while (n > 0L)
       {
-	if (pos >= count && !refill())
-          break;
+	if (pos >= count)
+          {
+            if (markpos == -1)
+              {
+                // Buffer is empty and no mark is set, skip on the
+                // underlying stream.
+                n -= in.skip(n);
+                break;
+              }
+            else if (!refill())
+              break;
+          }
 
 	int numread = (int) Math.min((long) (count - pos), n);
 	pos += numread;
@@ -338,13 +348,14 @@
     return origN - n;
   }
 
+  // GCJ LOCAL: package-private for use by InputStreamReader
   /**
    * Called to refill the buffer (when count is equal to pos).
    *
    * @return <code>true</code> when at least one additional byte was read
    *         into <code>buf</code>, <code>false</code> otherwise (at EOF).
    */
-  private boolean refill() throws IOException
+  boolean refill() throws IOException
   {
     if (buf == null)
       throw new IOException("Stream closed.");
@@ -368,7 +379,7 @@
 	markpos = 0;
       }
 
-    int numread = super.read(buf, count, bufferSize);
+    int numread = in.read(buf, count, bufferSize);
 
     if (numread <= 0)	// EOF
       return false;
