aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/io/LineNumberReader.java
diff options
context:
space:
mode:
authorGuilhem Lavaux <guilhem@kaffe.org>2003-12-28 11:54:17 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2003-12-28 11:54:17 +0000
commit920be544c9470f7606623a82b1ca8b5ace4d58cd (patch)
tree41837312c288c51281dc7c93eade8553e241f38a /libjava/java/io/LineNumberReader.java
parent07dc48e01452222a461e6660d242cf497b3f584d (diff)
downloadgcc-920be544c9470f7606623a82b1ca8b5ace4d58cd.zip
gcc-920be544c9470f7606623a82b1ca8b5ace4d58cd.tar.gz
gcc-920be544c9470f7606623a82b1ca8b5ace4d58cd.tar.bz2
2003-12-28 Guilhem Lavaux <guilhem@kaffe.org>
* java/io/LineNumberReader.java (mark): Improved error checking. (read): Likewise. (skip): Likewise. Skip is now really eating the specified number of characters. * java/io/CharArrayReader.java (read): It should throw IndexOutOfBoundsException and not ArrayIndexOutOfBoundsException (see mauve). * java/io/BufferedReader.java (readLine): Make readLine() really block until either EOF is reached or a true error happens. From-SVN: r75180
Diffstat (limited to 'libjava/java/io/LineNumberReader.java')
-rw-r--r--libjava/java/io/LineNumberReader.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/libjava/java/io/LineNumberReader.java b/libjava/java/io/LineNumberReader.java
index 9c4796d..439a760 100644
--- a/libjava/java/io/LineNumberReader.java
+++ b/libjava/java/io/LineNumberReader.java
@@ -155,6 +155,9 @@ public class LineNumberReader extends BufferedReader
*/
public void mark(int readLimit) throws IOException
{
+ if (readLimit < 0)
+ throw new IllegalArgumentException("Read-ahead limit is negative");
+
synchronized (lock)
{
// This is basically the same as BufferedReader.mark.
@@ -265,9 +268,17 @@ public class LineNumberReader extends BufferedReader
* @return The actual number of chars read, or -1 if end of stream
*
* @exception IOException If an error occurs.
+ * @exception NullPointerException If buf is null (in any case).
+ * @exception IndexOutOfBoundsException If buffer parameters (offset and
+ * count) lies outside of the buffer capacity.
*/
public int read(char[] buf, int offset, int count) throws IOException
{
+ if (buf == null)
+ throw new NullPointerException();
+ if (offset + count > buf.length || offset < 0)
+ throw new IndexOutOfBoundsException();
+
if (count <= 0)
{
if (count < 0)
@@ -376,14 +387,17 @@ public class LineNumberReader extends BufferedReader
*/
public long skip (long count) throws IOException
{
- if (count <= 0)
+ if (count < 0)
+ throw new IllegalArgumentException("skip() value is negative");
+ if (count == 0)
return 0;
int skipped;
-
+ char[] buf = new char[1];
+
for (skipped = 0; skipped < count; skipped++)
{
- int ch = read();
+ int ch = read(buf, 0, 1);
if (ch < 0)
break;