emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/macrostep 0b1c0fe 069/110: Add swank/gray:stream-read-char


From: ELPA Syncer
Subject: [nongnu] elpa/macrostep 0b1c0fe 069/110: Add swank/gray:stream-read-char-no-hang implementation
Date: Sat, 7 Aug 2021 09:18:04 -0400 (EDT)

branch: elpa/macrostep
commit 0b1c0fe4ca61cb44ed5a8d942ecd9b77331afc45
Author: Luís Borges de Oliveira <lbo@siscog.pt>
Commit: Luís Borges de Oliveira <lbo@siscog.pt>

    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))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]