Skip to content

Commit e8b3a23

Browse files
committed
Fix y-or-n-p on sbcl
1 parent 601d50b commit e8b3a23

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/stdin.lisp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,20 @@ most cases of *query-io* usage. Makes overloading y-or-no-p unnecessary.
7676
(let ((trimmed-output (copy-seq (string-trim '(#\Bel) output))))
7777
(when (or need-input
7878
(not (zerop (length (string-trim '(#\Newline) trimmed-output)))))
79+
(setf (fill-pointer (stdin-stream-input stream)) 0)
7980
(setf (fill-pointer output) 0)
8081
(finish-output)
8182
(send-input-request channel trimmed-output)
82-
(do ()
83-
((message-available-p channel))
84-
(sleep 0.1))
85-
(let ((value (concatenate 'string
86-
(gethash "value" (message-content (message-recv channel)))
87-
'(#\Newline))))
88-
(adjust-array input (length value)
89-
:fill-pointer (length value)
90-
:initial-contents (reverse value)))))
83+
(loop until (message-available-p channel)
84+
do (sleep 0.1))
85+
(loop for ch across (gethash "value" (message-content (message-recv channel)))
86+
initially (vector-push-extend #\Newline input)
87+
do (vector-push-extend ch input))))
9188
(bordeaux-threads:release-lock lock)))))
9289

93-
(defmethod trivial-gray-streams:stream-finish-output ((stream stdin-stream))
94-
(prompt-and-read stream nil))
90+
(defmethod trivial-gray-streams:stream-clear-input ((stream stdin-stream))
91+
(setf (fill-pointer (stdin-stream-input stream)) 0)
92+
nil)
9593

9694
(defmethod trivial-gray-streams:stream-listen ((stream stdin-stream))
9795
(not (zerop (length (stdin-stream-input stream)))))

0 commit comments

Comments
 (0)