[armedbear-cvs] r14091 - trunk/abcl/src/org/armedbear/lisp
ehuelsmann at common-lisp.net
ehuelsmann at common-lisp.net
Tue Aug 14 21:53:17 UTC 2012
Author: ehuelsmann
Date: Tue Aug 14 14:53:16 2012
New Revision: 14091
Log:
Make LISTEN work for non-character input streams.
Found by Stas Boukarev.
Patch by me.
Modified:
trunk/abcl/src/org/armedbear/lisp/Stream.java
Modified: trunk/abcl/src/org/armedbear/lisp/Stream.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Stream.java Tue Aug 14 14:44:43 2012 (r14090)
+++ trunk/abcl/src/org/armedbear/lisp/Stream.java Tue Aug 14 14:53:16 2012 (r14091)
@@ -1689,16 +1689,24 @@
if (pastEnd)
return NIL;
try {
- if (! _charReady())
- return NIL;
+ if (isCharacterInputStream()) {
+ if (! _charReady())
+ return NIL;
+
+ int n = _readChar();
+ if (n < 0)
+ return NIL;
- int n = _readChar();
- if (n < 0)
- return NIL;
-
- _unreadChar(n);
+ _unreadChar(n);
- return T;
+ return T;
+ } else if (isInputStream()) {
+ if (! _byteReady())
+ return NIL;
+
+ return T;
+ } else
+ return error(new StreamError(this, "Not an input stream"));
} catch (IOException e) {
return error(new StreamError(this, e));
}
@@ -1796,6 +1804,12 @@
streamNotCharacterInputStream();
return reader.ready();
}
+
+ protected boolean _byteReady() throws IOException {
+ if (in == null)
+ streamNotInputStream();
+ return (in.available() != 0);
+ }
/** Writes a character into the underlying stream,
* updating charPos while doing so
More information about the armedbear-cvs
mailing list