Raymond Toy pushed to branch issue-140-stream-element-type-two-way-stream at cmucl / cmucl
Commits:
-
08f76fc3
by Raymond Toy at 2022-10-17T09:46:45-07:00
2 changed files:
Changes:
| ... | ... | @@ -291,23 +291,12 @@ |
| 291 | 291 | ;; simple-stream
|
| 292 | 292 | (stream::%stream-external-format stream)
|
| 293 | 293 | ;; lisp-stream
|
| 294 | - (typecase stream
|
|
| 294 | + ;; The stream is a file stream; signal an error if it's not.
|
|
| 295 | + (etypecase stream
|
|
| 295 | 296 | #+unicode
|
| 296 | 297 | (fd-stream (fd-stream-external-format stream))
|
| 297 | 298 | (synonym-stream (stream-external-format
|
| 298 | - (symbol-value (synonym-stream-symbol stream))))
|
|
| 299 | - (two-way-stream
|
|
| 300 | - (let ((input-format
|
|
| 301 | - (stream-external-format (two-way-stream-input-stream stream)))
|
|
| 302 | - (output-format
|
|
| 303 | - (stream-external-format (two-way-stream-output-stream stream))))
|
|
| 304 | - ;; If the input and output streams have the same format, we
|
|
| 305 | - ;; can return the format. If they differ, it's not clear
|
|
| 306 | - ;; what to do, so just return :default.
|
|
| 307 | - (if (eql input-format output-format)
|
|
| 308 | - input-format
|
|
| 309 | - :default)))
|
|
| 310 | - (t :default))
|
|
| 299 | + (symbol-value (synonym-stream-symbol stream)))))
|
|
| 311 | 300 | ;; fundamental-stream
|
| 312 | 301 | :default))
|
| 313 | 302 |
| ... | ... | @@ -672,12 +672,7 @@ |
| 672 | 672 | |
| 673 | 673 | (define-test issue.140
|
| 674 | 674 | (:tag :issues)
|
| 675 | - ;; Make sure *standard-input* is a two-way-stream
|
|
| 676 | - (assert-true (typep *standard-input* 'two-way-stream))
|
|
| 677 | - (let ((input-format (stream-external-format
|
|
| 678 | - (two-way-stream-input-stream *standard-input*)))
|
|
| 679 | - (output-format (stream-external-format
|
|
| 680 | - (two-way-stream-output-stream *standard-input*))))
|
|
| 681 | - ;; By default, the input and output formats should be the same.
|
|
| 682 | - (assert-eql input-format output-format)
|
|
| 683 | - (assert-eql input-format (stream-external-format *standard-input*)))) |
|
| 675 | + (with-output-to-string (out)
|
|
| 676 | + (with-input-from-string (in "abc")
|
|
| 677 | + (let ((two-way-stream (make-two-way-stream in out)))
|
|
| 678 | + (assert-error 'type-error (stream-external-format two-way-stream)))))) |