Skip to content

Commit

Permalink
Add allow_stdin support
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Oct 16, 2024
1 parent f59c845 commit 945c4e0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/iopub.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@
(write-string (subseq value
(+ start (length prompt-prefix))
(- (length value) (length prompt-suffix)))
*query-io*)
(finish-output *query-io*)
*stdin*)
(adjust-array value (array-total-size value)
:fill-pointer 0))))))

Expand Down
3 changes: 3 additions & 0 deletions src/kernel.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,9 @@
(*page-output* (make-string-output-stream))
(*enable-debugger* (and (gethash "stop_on_error" (message-content *message*))
*enable-debugger*))
(*stdin* (if allow-stdin
*stdin*
(make-instance 'closed-input-stream)))
(*stderr* (if silent
(make-broadcast-stream)
*stderr*))
Expand Down
19 changes: 19 additions & 0 deletions src/utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,22 @@
#+ccl
(defmethod (setf ccl::input-stream-shared-resource) (new (s synonym-stream))
(setf (ccl::input-stream-shared-resource (symbol-value (synonym-stream-symbol s))) new))

(define-condition closed-stream (stream-error)
())

(defclass closed-input-stream (ngray:fundamental-character-input-stream)
())

(defmethod ngray:stream-clear-input ((stream closed-input-stream))
(error 'closed-stream :stream stream))

(defmethod ngray:stream-read-char ((stream closed-input-stream))
(error 'closed-stream :stream stream))

(defmethod ngray:open-stream-p ((stream closed-input-stream))
nil)

(defmethod close ((stream closed-input-stream) &key abort)
(declare (ignore abort))
nil)
2 changes: 1 addition & 1 deletion tests/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def sanitize_path(p):
@pytest.fixture(
params=[
"common-lisp",
"common-lisp_abcl",
#"common-lisp_abcl",
"common-lisp_ccl",
"common-lisp_clasp",
"common-lisp_clisp",
Expand Down

0 comments on commit 945c4e0

Please sign in to comment.