Skip to content
Snippets Groups Projects
Commit 4b57a2e8 authored by dtc's avatar dtc
Browse files

Concatenated-stream-streams should be returning the remaining streams

to read rather than all the streams; noted by Sam Steingold. The
streams are now simply popped when the EOF is reached. The full list
of streams is not maintained as presumably the closing of the streams
will be handled separately from the concatenated-stream functionality.
parent c6a7bd9c
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain. ;;; Carnegie Mellon University, and has been placed in the public domain.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/stream.lisp,v 1.39 1999/02/11 12:17:58 dtc Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/stream.lisp,v 1.40 2000/04/05 04:26:53 dtc Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -897,13 +897,10 @@ ...@@ -897,13 +897,10 @@
(bin #'concatenated-bin) (bin #'concatenated-bin)
(misc #'concatenated-misc)) (misc #'concatenated-misc))
(:print-function %print-concatenated-stream) (:print-function %print-concatenated-stream)
(:constructor (:constructor make-concatenated-stream (&rest streams)))
make-concatenated-stream (&rest streams &aux (current streams)))) ;; This is a list of all the streams. The car of this is the stream
;; The car of this is the stream we are reading from now. ;; we are reading from now.
current (streams nil :type list))
;; This is a list of all the streams. We need to remember them so that
;; we can close them.
(streams nil :type list :read-only t))
(defun %print-concatenated-stream (s stream d) (defun %print-concatenated-stream (s stream d)
(declare (ignore d)) (declare (ignore d))
...@@ -916,18 +913,19 @@ ...@@ -916,18 +913,19 @@
(macrolet ((in-fun (name fun) (macrolet ((in-fun (name fun)
`(defun ,name (stream eof-errorp eof-value) `(defun ,name (stream eof-errorp eof-value)
(do ((current (concatenated-stream-current stream) (cdr current))) (do ((current (concatenated-stream-streams stream)
(cdr current)))
((null current) ((null current)
(eof-or-lose stream eof-errorp eof-value)) (eof-or-lose stream eof-errorp eof-value))
(let* ((stream (car current)) (let* ((stream (car current))
(result (,fun stream nil nil))) (result (,fun stream nil nil)))
(when result (return result))) (when result (return result)))
(setf (concatenated-stream-current stream) current))))) (setf (concatenated-stream-streams stream) (cdr current))))))
(in-fun concatenated-in read-char) (in-fun concatenated-in read-char)
(in-fun concatenated-bin read-byte)) (in-fun concatenated-bin read-byte))
(defun concatenated-misc (stream operation &optional arg1 arg2) (defun concatenated-misc (stream operation &optional arg1 arg2)
(let ((left (concatenated-stream-current stream))) (let ((left (concatenated-stream-streams stream)))
(when left (when left
(let* ((current (car left))) (let* ((current (car left)))
(case operation (case operation
...@@ -939,9 +937,9 @@ ...@@ -939,9 +937,9 @@
(stream-misc-dispatch current :listen)))) (stream-misc-dispatch current :listen))))
(cond ((eq stuff :eof) (cond ((eq stuff :eof)
;; Advance current, and try again. ;; Advance current, and try again.
(pop (concatenated-stream-current stream)) (pop (concatenated-stream-streams stream))
(setf current (setf current
(car (concatenated-stream-current stream))) (car (concatenated-stream-streams stream)))
(unless current (unless current
;; No further streams. EOF. ;; No further streams. EOF.
(return :eof))) (return :eof)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment