OSDN Git Service

* java/io/PushbackInputStream.java (read): If there are characters
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Jun 2000 21:27:50 +0000 (21:27 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Jun 2000 21:27:50 +0000 (21:27 +0000)
in the buffer, don't also call super.read().
* java/io/PushbackReader.java (read): If there are characters in
the buffer, don't also call super.read().

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34745 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/java/io/PushbackInputStream.java
libjava/java/io/PushbackReader.java

index ba0d858..cb6fc86 100644 (file)
@@ -1,5 +1,10 @@
 2000-06-27  Tom Tromey  <tromey@cygnus.com>
 
+       * java/io/PushbackInputStream.java (read): If there are characters
+       in the buffer, don't also call super.read().
+       * java/io/PushbackReader.java (read): If there are characters in
+       the buffer, don't also call super.read().
+
        * java/lang/Double.java (valueOf): Call parseDouble().
 
 2000-06-26  Warren Levy  <warrenl@cygnus.com>
index c104cf2..537e1db 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -70,12 +70,14 @@ public class PushbackInputStream extends FilterInputStream
       throw new ArrayIndexOutOfBoundsException();
 
     int numBytes = Math.min(buf.length - pos, len);
-    for (int i = 0; i < numBytes; i++)
-      b[off++] = buf[pos++];
+    if (numBytes > 0)
+      {
+       System.arraycopy (buf, pos, b, off, numBytes);
+       pos += numBytes;
+       return numBytes;
+      }
 
-    // `off' was just incremented to include `numBytes', so we can
-    // just pass ithere.
-    return numBytes + super.read(b, off, len - numBytes);
+    return super.read(b, off, len);
   }
 
   public void unread(int b) throws IOException
index d5d8d44..1a7523d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -79,10 +79,14 @@ public class PushbackReader extends FilterReader
         throw new ArrayIndexOutOfBoundsException();
 
       int numBytes = Math.min(buf.length - pos, len);
-      for (int i = 0; i < numBytes; i++)
-        b[off++] = buf[pos++];
-
-      return numBytes + super.read(b, off, len - numBytes);
+      if (numBytes > 0)
+       {
+         System.arraycopy (buf, pos, b, off, numBytes);
+         pos += numBytes;
+         return numBytes;
+       }
+
+      return super.read(b, off, len);
     }
   }