branch: elpa/macrostep
commit 0b1c0fe4ca61cb44ed5a8d942ecd9b77331afc45
Author: Luís Borges de Oliveira <[email protected]>
Commit: Luís Borges de Oliveira <[email protected]>
Add swank/gray:stream-read-char-no-hang implementation
---
swank-macrostep.lisp | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/swank-macrostep.lisp b/swank-macrostep.lisp
index c94750b..c5f835a 100644
--- a/swank-macrostep.lisp
+++ b/swank-macrostep.lisp
@@ -136,19 +136,26 @@
:accessor newlines-of)
(forms :initform nil :accessor forms-of)))
-(defmethod swank/gray:stream-read-char ((stream form-tracking-stream))
+(defun %read-char (reader stream)
(handler-case
(let ((pos (position-of stream))
- (result (read-char (source-of stream))))
- (incf (position-of stream))
- (when (eql result #\Newline)
- (let* ((newlines (newlines-of stream))
- (n (length newlines)))
- (when (or (zerop n) (> pos (aref newlines (1- n))))
- (vector-push-extend pos newlines))))
- result)
+ (result (funcall reader (source-of stream))))
+ (when result
+ (incf (position-of stream))
+ (when (eql result #\Newline)
+ (let* ((newlines (newlines-of stream))
+ (n (length newlines)))
+ (when (or (zerop n) (> pos (aref newlines (1- n))))
+ (vector-push-extend pos newlines))))
+ result))
(end-of-file () :eof)))
+(defmethod swank/gray:stream-read-char ((stream form-tracking-stream))
+ (%read-char #'read-char stream))
+
+(defmethod swank/gray:stream-read-char-no-hang ((stream form-tracking-stream))
+ (%read-char #'read-char-no-hang stream))
+
(defmethod swank/gray:stream-unread-char ((stream form-tracking-stream)
character)
(prog1 (unread-char character (source-of stream))
(decf (position-of stream))))