/[cmucl]/src/code/stream.lisp
ViewVC logotype

Diff of /src/code/stream.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.93 by rtoy, Fri Jul 2 02:50:35 2010 UTC revision 1.94 by rtoy, Mon Jul 5 03:40:02 2010 UTC
# Line 723  Line 723 
723    ;; Like fast-read-char-refill, but we don't need or want the    ;; Like fast-read-char-refill, but we don't need or want the
724    ;; in-buffer-extra.    ;; in-buffer-extra.
725    (let* ((ibuf (lisp-stream-in-buffer stream))    (let* ((ibuf (lisp-stream-in-buffer stream))
726           (index (lisp-stream-in-index stream)))           (index (lisp-stream-in-index stream))
727      (declare (type (integer 0 #.in-buffer-length) index))           (in-length (fd-stream-in-length stream)))
728        (declare (type (integer 0 #.in-buffer-length) index in-length))
729    
730        #+(or debug-frc-sr)
731        (progn
732          (format t "index = ~A~%" index)
733          (format t "in-length = ~A~%" in-length)
734          (format t "ibuf before = ~A~%" ibuf))
735    
736      ;; Copy the stuff we haven't read from in-buffer to the beginning      ;; Copy the stuff we haven't read from in-buffer to the beginning
737      ;; of the buffer.      ;; of the buffer.
738      (replace ibuf ibuf      (if (< index in-length)
739               :start1 0          (replace ibuf ibuf
740               :start2 index :end2 in-buffer-length)                   :start1 0
741                     :start2 index :end2 in-length)
742            (setf index in-length))
743        (setf index (- in-length index))
744    
745        #+(or debug-frc-sr)
746        (format t "ibuf after  = ~A~%" ibuf)
747    
748      (let ((count (funcall (lisp-stream-n-bin stream) stream      (let ((count (funcall (lisp-stream-n-bin stream) stream
749                            ibuf (- in-buffer-length index)                            ibuf index
750                            index                            (- in-buffer-length index)
751                            nil)))                            nil)))
752        (declare (type (integer 0 #.in-buffer-length) count))        (declare (type (integer 0 #.in-buffer-length) count))
753    
754          #+(or debug-frc-sr)
755          (progn
756            (format t "count = ~D~%" count)
757            (format t "new ibuf = ~A~%" ibuf))
758    
759        (cond ((zerop count)        (cond ((zerop count)
760               ;; Nothing left in the stream, so update our pointers to               ;; Nothing left in the stream, so update our pointers to
761               ;; indicate we've read everything and call the stream-in               ;; indicate we've read everything and call the stream-in
# Line 759  Line 777 
777                 ;; valid (in case end-of-file was reached), and what                 ;; valid (in case end-of-file was reached), and what
778                 ;; the state was when originally converting the octets                 ;; the state was when originally converting the octets
779                 ;; to characters.                 ;; to characters.
780                 (setf (fd-stream-in-length stream) (+ count (- in-buffer-length index)))                 (setf (fd-stream-in-length stream) (+ count index))
781                   #+(or debug-frc-sr)
782                   (format t "in-length = ~D~%" (fd-stream-in-length stream))
783                 (let ((state (fd-stream-oc-state stream)))                 (let ((state (fd-stream-oc-state stream)))
784                   (setf (fd-stream-saved-oc-state stream)                   (setf (fd-stream-saved-oc-state stream)
785                         (cons (car state)                         (cons (car state)
# Line 768  Line 788 
788    
789                 ;; Copy the last read character to the beginning of the                 ;; Copy the last read character to the beginning of the
790                 ;; buffer to support unreading.                 ;; buffer to support unreading.
791                   #+(or)
792                   (format t "slen = ~A~%" slen)
793                 (when (plusp slen)                 (when (plusp slen)
794                   (setf (schar sbuf 0) (schar sbuf (1- slen))))                   (setf (schar sbuf 0) (schar sbuf (1- slen))))
795    
# Line 777  Line 799 
799                 (multiple-value-bind (s char-count octet-count new-state)                 (multiple-value-bind (s char-count octet-count new-state)
800                     (octets-to-string ibuf                     (octets-to-string ibuf
801                                       :start 0                                       :start 0
802                                       :end (+ count (- in-buffer-length index))                                       :end (fd-stream-in-length stream)
803                                       :state (fd-stream-oc-state stream)                                       :state (fd-stream-oc-state stream)
804                                       :string sbuf                                       :string sbuf
805                                       :s-start 1                                       :s-start 1
# Line 788  Line 810 
810                   (setf (lisp-stream-string-buffer-len stream) char-count)                   (setf (lisp-stream-string-buffer-len stream) char-count)
811                   (setf (lisp-stream-string-index stream) 2)                   (setf (lisp-stream-string-index stream) 2)
812                   (setf (lisp-stream-in-index stream) octet-count)                   (setf (lisp-stream-in-index stream) octet-count)
813                     #+(or debug-frc-sr)
814                     (format t "new in-index = ~A~%" (lisp-stream-in-index stream))
815                   (schar sbuf 1))))))))                   (schar sbuf 1))))))))
816    
817  ;;; FAST-READ-BYTE-REFILL  --  Interface  ;;; FAST-READ-BYTE-REFILL  --  Interface

Legend:
Removed from v.1.93  
changed lines
  Added in v.1.94

  ViewVC Help
Powered by ViewVC 1.1.5