/[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.87 by rtoy, Mon Aug 10 16:47:41 2009 UTC revision 1.87.6.1 by rtoy, Sat Sep 19 15:16:05 2009 UTC
# Line 459  Line 459 
459        ;; simple-stream        ;; simple-stream
460        (stream::%unread-char stream character)        (stream::%unread-char stream character)
461        ;; lisp-stream        ;; lisp-stream
462          #-unicode
463        (let ((index (1- (lisp-stream-in-index stream)))        (let ((index (1- (lisp-stream-in-index stream)))
464              (buffer (lisp-stream-in-buffer stream)))              (buffer (lisp-stream-in-buffer stream)))
465          (declare (fixnum index))          (declare (fixnum index))
# Line 469  Line 470 
470                (t                (t
471                 (funcall (lisp-stream-misc stream) stream                 (funcall (lisp-stream-misc stream) stream
472                          :unread character))))                          :unread character))))
473          #+unicode
474          (let ((index (1- (lisp-stream-string-index stream)))
475                (buffer (lisp-stream-string-buffer stream)))
476            (declare (fixnum index))
477            (when (and buffer (minusp index)) (error "Nothing to unread."))
478            (cond (buffer
479                   (setf (aref buffer index) character)
480                   (setf (lisp-stream-string-index stream) index))
481                  (t
482                   (funcall (lisp-stream-misc stream) stream
483                            :unread character))))
484        ;; fundamental-stream        ;; fundamental-stream
485        (stream-unread-char stream character)))        (stream-unread-char stream character)))
486    nil)    nil)
# Line 703  Line 715 
715             (setf (lisp-stream-in-index stream) (1+ start))             (setf (lisp-stream-in-index stream) (1+ start))
716             (code-char (aref ibuf start))))))             (code-char (aref ibuf start))))))
717    
718    (defun fast-read-char-string-refill (stream eof-errorp eof-value)
719      #+nil
720      (progn
721        (format *debug-io* "fast-read-char-refill.  Stream before refill:~%")
722        (describe stream))
723    
724      ;; Like fast-read-char-refill, but we don't need or want the
725      ;; in-buffer-extra.
726      (let* ((ibuf (lisp-stream-in-buffer stream))
727             (index (lisp-stream-in-index stream)))
728        (declare (type index))
729        ;; Copy the stuff we haven't read to the beginning of the buffer.
730        (replace ibuf ibuf
731                 :start1 0
732                 :start2 index :end2 in-buffer-length)
733        (let ((count (funcall (lisp-stream-n-bin stream) stream
734                              ibuf (- in-buffer-length index)
735                              index
736                              nil)))
737          (declare (type index count))
738          (cond ((zerop count)
739                 (setf (lisp-stream-in-index stream) in-buffer-length)
740                 (funcall (lisp-stream-in stream) stream eof-errorp eof-value))
741                (t
742                 (setf (lisp-stream-in-index stream) 0)
743    
744                 #+nil
745                 (progn
746                   (format *debug-io* "~& Stream after refill:~%")
747                   (describe stream))
748                 (multiple-value-bind (s char-count octet-count)
749                     (octets-to-string (lisp-stream-in-buffer stream)
750                                       :start (lisp-stream-in-index stream)
751                                       :end count
752                                       :string (lisp-stream-string-buffer stream)
753                                       :external-format (fd-stream-external-format stream))
754                   (declare (ignore s))
755                   (setf (lisp-stream-string-buffer-len stream) char-count)
756                   (setf (lisp-stream-string-index stream) 1)
757                   (incf (lisp-stream-in-index stream) octet-count)
758                   #+nil
759                   (progn
760                     (format *debug-io* "~& Stream after OS~%")
761                     (describe stream))
762                   (schar (lisp-stream-string-buffer stream) 0)))))))
763    
764    
765  ;;; FAST-READ-BYTE-REFILL  --  Interface  ;;; FAST-READ-BYTE-REFILL  --  Interface
766  ;;;  ;;;

Legend:
Removed from v.1.87  
changed lines
  Added in v.1.87.6.1

  ViewVC Help
Powered by ViewVC 1.1.5