Skip to content

Commit 945c4e0

Browse files
committed
Add allow_stdin support
1 parent f59c845 commit 945c4e0

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

src/iopub.lisp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@
142142
(write-string (subseq value
143143
(+ start (length prompt-prefix))
144144
(- (length value) (length prompt-suffix)))
145-
*query-io*)
146-
(finish-output *query-io*)
145+
*stdin*)
147146
(adjust-array value (array-total-size value)
148147
:fill-pointer 0))))))
149148

src/kernel.lisp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,9 @@
15191519
(*page-output* (make-string-output-stream))
15201520
(*enable-debugger* (and (gethash "stop_on_error" (message-content *message*))
15211521
*enable-debugger*))
1522+
(*stdin* (if allow-stdin
1523+
*stdin*
1524+
(make-instance 'closed-input-stream)))
15221525
(*stderr* (if silent
15231526
(make-broadcast-stream)
15241527
*stderr*))

src/utils.lisp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,22 @@
170170
#+ccl
171171
(defmethod (setf ccl::input-stream-shared-resource) (new (s synonym-stream))
172172
(setf (ccl::input-stream-shared-resource (symbol-value (synonym-stream-symbol s))) new))
173+
174+
(define-condition closed-stream (stream-error)
175+
())
176+
177+
(defclass closed-input-stream (ngray:fundamental-character-input-stream)
178+
())
179+
180+
(defmethod ngray:stream-clear-input ((stream closed-input-stream))
181+
(error 'closed-stream :stream stream))
182+
183+
(defmethod ngray:stream-read-char ((stream closed-input-stream))
184+
(error 'closed-stream :stream stream))
185+
186+
(defmethod ngray:open-stream-p ((stream closed-input-stream))
187+
nil)
188+
189+
(defmethod close ((stream closed-input-stream) &key abort)
190+
(declare (ignore abort))
191+
nil)

tests/test_kernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def sanitize_path(p):
1717
@pytest.fixture(
1818
params=[
1919
"common-lisp",
20-
"common-lisp_abcl",
20+
#"common-lisp_abcl",
2121
"common-lisp_ccl",
2222
"common-lisp_clasp",
2323
"common-lisp_clisp",

0 commit comments

Comments
 (0)