0.9.1.3
authorRudi Schlatte <rudi@constantly.at>
Sun, 29 May 2005 10:27:38 +0000 (10:27 +0000)
committerRudi Schlatte <rudi@constantly.at>
Sun, 29 May 2005 10:27:38 +0000 (10:27 +0000)
Small stream cleanups:
  - Use same names in generalized-peeking-mechanism as cmucl
  - set-fd-stream-routines can now in theory be used to change stream
    element-type and external-format (but this clashes with
    fast-read-char/-byte, since these work off another layer of buffers)

src/code/fd-stream.lisp
src/code/target-stream.lisp
version.lisp-expr

index 5c17dd1..03bca62 100644 (file)
        (output-size nil)
        (character-stream-p (subtypep type 'character)))
 
-    (when (fd-stream-obuf-sap fd-stream)
+    ;; drop buffers when direction changes
+    (when (and (fd-stream-obuf-sap fd-stream) (not output-p))
       (push (fd-stream-obuf-sap fd-stream) *available-buffers*)
       (setf (fd-stream-obuf-sap fd-stream) nil))
-    (when (fd-stream-ibuf-sap fd-stream)
+    (when (and (fd-stream-ibuf-sap fd-stream) (not input-p))
       (push (fd-stream-ibuf-sap fd-stream) *available-buffers*)
       (setf (fd-stream-ibuf-sap fd-stream) nil))
 
                 normalized-external-format))
        (unless routine
          (error "could not find any input routine for ~S" target-type))
-       (setf (fd-stream-ibuf-sap fd-stream) (next-available-buffer))
-       (setf (fd-stream-ibuf-length fd-stream) bytes-per-buffer)
-       (setf (fd-stream-ibuf-tail fd-stream) 0)
        (if character-stream-p
            (setf (fd-stream-in fd-stream) routine
                  (fd-stream-bin fd-stream) #'ill-bin)
          (error "could not find any output routine for ~S buffered ~S"
                 (fd-stream-buffering fd-stream)
                 target-type))
-       (setf (fd-stream-obuf-sap fd-stream) (next-available-buffer))
-       (setf (fd-stream-obuf-length fd-stream) bytes-per-buffer)
-       (setf (fd-stream-obuf-tail fd-stream) 0)
        (when character-stream-p
          (setf (fd-stream-output-bytes fd-stream) output-bytes))
        (if character-stream-p
                (fd-stream-bout fd-stream) routine))
        (setf (fd-stream-sout fd-stream)
              (if (eql size 1) #'fd-sout #'ill-out))
-       (setf (fd-stream-char-pos fd-stream) 0)
        (setf output-size size)
        (setf output-type type)))
 
                                 :dual-channel-p dual-channel-p
                                 :external-format external-format
                                 :timeout timeout)))
+    (when input
+      (setf (fd-stream-ibuf-sap stream) (next-available-buffer))
+      (setf (fd-stream-ibuf-length stream) bytes-per-buffer)
+      (setf (fd-stream-ibuf-tail stream) 0))
+    (when output
+      (setf (fd-stream-obuf-sap stream) (next-available-buffer))
+      (setf (fd-stream-obuf-length stream) bytes-per-buffer)
+      (setf (fd-stream-obuf-tail stream) 0)
+      (setf (fd-stream-char-pos stream) 0))
     (set-fd-stream-routines stream element-type input output input-buffer-p)
     (when (and auto-close (fboundp 'finalize))
       (finalize stream
index 9593cd2..3144550 100644 (file)
 ;;; EOF-DETECTED-FORM - the form to execute when EOF has been detected
 ;;;                     (this will default to EOF-RESULT)
 (sb!xc:defmacro generalized-peeking-mechanism
-    (peek-type eof-result char-var read-form eof-value unread-form
+    (peek-type eof-value char-var read-form read-eof unread-form
      &optional (skipped-char-form nil) (eof-detected-form nil))
   `(let ((,char-var ,read-form))
-    (cond ((eql ,char-var ,eof-value)
+    (cond ((eql ,char-var ,read-eof)
            ,(if eof-detected-form
                 eof-detected-form
-                eof-result))
+                eof-value))
           ((characterp ,peek-type)
            (do ((,char-var ,char-var ,read-form))
-               ((or (eql ,char-var ,eof-value) 
+               ((or (eql ,char-var ,read-eof) 
                     (char= ,char-var ,peek-type))
-                (cond ((eql ,char-var ,eof-value)
+                (cond ((eql ,char-var ,read-eof)
                        ,(if eof-detected-form
                             eof-detected-form
-                            eof-result))
+                            eof-value))
                       (t ,unread-form
                          ,char-var)))
              ,skipped-char-form))
           ((eql ,peek-type t)
            (do ((,char-var ,char-var ,read-form))
-               ((or (eql ,char-var ,eof-value)
+               ((or (eql ,char-var ,read-eof)
                     (not (whitespacep ,char-var)))
-                (cond ((eql ,char-var ,eof-value)
+                (cond ((eql ,char-var ,read-eof)
                        ,(if eof-detected-form
                             eof-detected-form
-                            eof-result))
+                            eof-value))
                       (t ,unread-form
                          ,char-var)))
              ,skipped-char-form))
index f5a3c4f..225e0e6 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.9.1.2"
+"0.9.1.3"