Hans Huebner <hhuebner@...> writes:
> on the Gray streams example page, there is this nice input stream class
> that counts lines and characters
> (http://www.sbcl.org/manual/Character-counting-input-stream.html). I
> tried using it, but the read-line methods seemed to be missing
(Speaking as the person who wrote that bit of the manual) Leaving out
the stream-read-line method was intentional: I wanted to minimal
examples of the Gray Streams protocols. But there is a bug:
wrapped-character-input-stream is supposed to be a subclass of
fundamental-character-input-stream, for which there's an adequate
default method on stream-read-line.
> ... and read-char of the real stream was called with eof-error-p
> defaulted to t, which is not good, I think.
This is also a bug.
SBCL developers: the patch below corrects the errors in the example
code.
--
RmK
Index: doc/manual/gray-streams-examples.texinfo
===================================================================
RCS file: /cvsroot/sbcl/sbcl/doc/manual/gray-streams-examples.texinfo,v
retrieving revision 1.1
diff -u -r1.1 gray-streams-examples.texinfo
--- doc/manual/gray-streams-examples.texinfo 20 Dec 2006 15:50:51 -0000 1.1
+++ doc/manual/gray-streams-examples.texinfo 13 Apr 2007 15:18:05 -0000
@@ -47,13 +47,14 @@
@end group
@group
-(defclass wrapped-character-input-stream (wrapped-stream)
+(defclass wrapped-character-input-stream
+ (wrapped-stream fundamental-character-output-stream)
())
@end group
@group
(defmethod stream-read-char ((stream wrapped-character-input-stream))
- (read-char (stream-of stream)))
+ (read-char (stream-of stream) nil :eof))
@end group
@group
|