summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2000-06-27 21:27:50 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2000-06-27 21:27:50 +0000
commit5af4c5481e1cafef8dfa1d0f09a851be0d35b6bc (patch)
tree10aa3be4449480e01d731e82ba030309e5c473ba /libjava
parentd8a45ab54c8d8d29dbb9cb5d639a5f684043b1eb (diff)
downloadgcc-5af4c5481e1cafef8dfa1d0f09a851be0d35b6bc.tar.gz
* 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(). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34745 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog5
-rw-r--r--libjava/java/io/PushbackInputStream.java14
-rw-r--r--libjava/java/io/PushbackReader.java14
3 files changed, 22 insertions, 11 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index ba0d8586dd3..cb6fc869f9b 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -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>
diff --git a/libjava/java/io/PushbackInputStream.java b/libjava/java/io/PushbackInputStream.java
index c104cf2f407..537e1dbec57 100644
--- a/libjava/java/io/PushbackInputStream.java
+++ b/libjava/java/io/PushbackInputStream.java
@@ -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
diff --git a/libjava/java/io/PushbackReader.java b/libjava/java/io/PushbackReader.java
index d5d8d441258..1a7523d0d15 100644
--- a/libjava/java/io/PushbackReader.java
+++ b/libjava/java/io/PushbackReader.java
@@ -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);
}
}