diff options
author | Bryce McKinlay <bryce@albatross.co.nz> | 2000-11-29 10:06:03 +0000 |
---|---|---|
committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2000-11-29 10:06:03 +0000 |
commit | d02bc1fb258dcb43215c0d671237c0dbbb74c4b9 (patch) | |
tree | 2faa9e8f99525720284bd59f9288fb1d62c941dc /libjava/java | |
parent | 172c38bb69afc32eae4f6f009d1c5edb506b6476 (diff) | |
download | gcc-d02bc1fb258dcb43215c0d671237c0dbbb74c4b9.zip gcc-d02bc1fb258dcb43215c0d671237c0dbbb74c4b9.tar.gz gcc-d02bc1fb258dcb43215c0d671237c0dbbb74c4b9.tar.bz2 |
InflaterInputStream (read): Don't return -1 unless the infate() call didn't deliver any output.
* java/util/zip/InflaterInputStream (read): Don't return -1 unless
the infate() call didn't deliver any output. Throw a ZipException if
the needsDictionary() call returns true.
* java/io/ByteArrayInputStream (read): Remove redundant bounds checks.
* java/io/InputStreamReader: Use the default buffer size for the
contained BufferedInputStream.
From-SVN: r37846
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/io/ByteArrayInputStream.java | 7 | ||||
-rw-r--r-- | libjava/java/io/InputStreamReader.java | 2 | ||||
-rw-r--r-- | libjava/java/util/zip/InflaterInputStream.java | 17 |
3 files changed, 11 insertions, 15 deletions
diff --git a/libjava/java/io/ByteArrayInputStream.java b/libjava/java/io/ByteArrayInputStream.java index 97ec6e7..30ba8d7 100644 --- a/libjava/java/io/ByteArrayInputStream.java +++ b/libjava/java/io/ByteArrayInputStream.java @@ -72,9 +72,6 @@ public class ByteArrayInputStream extends InputStream public synchronized int read() { - if (pos < 0) - throw new ArrayIndexOutOfBoundsException(pos); - if (pos < count) return ((int) buf[pos++]) & 0xFF; return -1; @@ -82,10 +79,6 @@ public class ByteArrayInputStream extends InputStream public synchronized int read(byte[] b, int off, int len) { - /* Don't need to check pos value, arraycopy will check it. */ - if (off < 0 || len < 0 || off + len > b.length) - throw new ArrayIndexOutOfBoundsException(); - if (pos >= count) return -1; diff --git a/libjava/java/io/InputStreamReader.java b/libjava/java/io/InputStreamReader.java index 478d8ef..73876fb 100644 --- a/libjava/java/io/InputStreamReader.java +++ b/libjava/java/io/InputStreamReader.java @@ -46,7 +46,7 @@ public class InputStreamReader extends Reader { this.in = in instanceof BufferedInputStream ? (BufferedInputStream) in - : new BufferedInputStream(in, 250); + : new BufferedInputStream(in); /* Don't need to call super(in) here as long as the lock gets set. */ this.lock = in; converter = decoder; diff --git a/libjava/java/util/zip/InflaterInputStream.java b/libjava/java/util/zip/InflaterInputStream.java index 005c821..d7459eb 100644 --- a/libjava/java/util/zip/InflaterInputStream.java +++ b/libjava/java/util/zip/InflaterInputStream.java @@ -44,8 +44,6 @@ public class InflaterInputStream extends FilterInputStream { protected void fill () throws IOException { - if (inf == null) - throw new IOException ("stream closed"); len = in.read(buf, 0, buf.length); if (len != -1) inf.setInput(buf, 0, len); @@ -85,18 +83,23 @@ public class InflaterInputStream extends FilterInputStream return -1; if (inf.needsInput()) fill (); - if (this.len == -1) - return -1; // Couldn't get any more data to feed to the Inflater - if (inf.needsDictionary()) - return -1; + int count; try { - return inf.inflate(buf, off, len); + count = inf.inflate(buf, off, len); + if (count == 0) + { + if (len == -1) + return -1; // Couldn't get any more data to feed to the Inflater + if (inf.needsDictionary()) + throw new ZipException ("Inflater needs Dictionary"); + } } catch (DataFormatException dfe) { throw new ZipException (dfe.getMessage()); } + return count; } public void close () throws IOException |