<div dir="ltr">Which would violate the standard, as "The effect of close on a constructed stream is to close the argument stream only. There is no effect on the constituents of composite streams."</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 16, 2017 at 3:54 PM, Paul Meurer <span dir="ltr"><<a href="mailto:paul.meurer@uni.no" target="_blank">paul.meurer@uni.no</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
there seems to be a bug in the concatenated-stream class in connection with with-open-stream().<br>
<br>
When a concatenated-stream is read from in the body of the macro, (e.g. with read-sequence()), concatenated-stream-next-<wbr>input-stream() is called subsequently, which removes the first stream from the concatenated-stream-streams slot, eventually emptying this slot.<br>
<br>
In its unwind-protect cleanup-form, with-open-stream() should close the stream, but there is no close method for concatenated-stream. (The superclass method on composite-stream-mixin just sets open-p to NIL.) With the concatenated-stream-streams slot being empty after an exhaustive read with e.g. read-sequence(), there is no obvious way either how the stream could be closed. The best way to solve this problem would probably be to have a copy of the stream list in an additional slot, and have close map over them when closing the concatenated-stream.<br>
<br>
This bug manifests itself e.g. in the mel-base library.<br>
<br>
My fix (in l1-streams.lisp) looks like this:<br>
<br>
(defclass concatenated-stream (composite-stream-mixin fundamental-input-stream)<br>
    ((streams :initarg :streams :accessor concatenated-stream-streams)<br>
     (stream-list :initarg :stream-list :accessor concatenated-stream-stream-<wbr>list)))<br>
<br>
(defmethod close :after ((stream concatenated-stream) &key abort)<br>
  (mapc (lambda (s) (close s :abort abort))<br>
        (concatenated-stream-stream-<wbr>list stream)))<br>
<br>
(defun make-concatenated-stream (&rest streams)<br>
  "Return a stream which takes its input from each of the streams in turn,<br>
   going on to the next at EOF."<br>
  (dolist (s streams (make-instance 'concatenated-stream :streams streams :stream-list streams))<br>
    (unless (input-stream-p s)<br>
      (error "~S is not an input stream" s))))<br>
<br>
<br>
Paul Meurer<br>
<br>
______________________________<wbr>_________________<br>
Openmcl-devel mailing list<br>
<a href="mailto:Openmcl-devel@clozure.com">Openmcl-devel@clozure.com</a><br>
<a href="https://lists.clozure.com/mailman/listinfo/openmcl-devel" rel="noreferrer" target="_blank">https://lists.clozure.com/<wbr>mailman/listinfo/openmcl-devel</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">With best regards, Stas.</div>
</div>