/[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.66 by toy, Mon Jan 19 20:04:09 2004 UTC revision 1.67 by toy, Tue Jan 20 17:32:20 2004 UTC
# Line 489  Line 489 
489               ,skipped-char-form))               ,skipped-char-form))
490            ((null ,peek-type)            ((null ,peek-type)
491             ,unread-form             ,unread-form
492               ,(if eof-detected-form
493                    (when (eql char-var eof-value)
494                      eof-detected-form))
495             ,char-var)             ,char-var)
496            (t            (t
497             (error "Impossible case reached in PEEK-CHAR")))))             (error "Impossible case reached in PEEK-CHAR")))))
# Line 518  Line 521 
521            (generalized-peeking-mechanism            (generalized-peeking-mechanism
522             peek-type eof-value char             peek-type eof-value char
523             (read-char stream eof-errorp eof-value)             (read-char stream eof-errorp eof-value)
524             (unread-char char stream))             (unread-char char stream)
525               nil
526               (eof-or-lose stream (or eof-errorp recursive-p) eof-value))
527            ;; fundamental-stream            ;; fundamental-stream
528            (generalized-peeking-mechanism            (generalized-peeking-mechanism
529             peek-type :eof char             peek-type :eof char
# Line 763  Line 768 
768  (defun write-line (string &optional (stream *standard-output*)  (defun write-line (string &optional (stream *standard-output*)
769                            &key (start 0) (end (length string)))                            &key (start 0) (end (length string)))
770    "Outputs the String to the given Stream, followed by a newline character."    "Outputs the String to the given Stream, followed by a newline character."
771    (write-line* string stream start end))    (write-line* string stream start (or end (length string))))
772    
773  (defun write-line* (string &optional (stream *standard-output*)  (defun write-line* (string &optional (stream *standard-output*)
774                             (start 0) (end (length string)))                             (start 0) (end (length string)))
# Line 2029  POSITION: an INTEGER greater than or equ Line 2034  POSITION: an INTEGER greater than or equ
2034                 (simple-array            ; We also know that it is a 'vector'.                 (simple-array            ; We also know that it is a 'vector'.
2035                  (read-into-simple-array seq stream start end))                  (read-into-simple-array seq stream start end))
2036                 (vector                 (vector
2037                  (read-into-vector seq stream start end)))                  (read-into-vector seq stream start end))))))
              )))  
2038      ;; fundamental-stream      ;; fundamental-stream
2039      (stream-read-sequence stream seq start end)))      (stream-read-sequence stream seq start end)))
2040    
# Line 2079  POSITION: an INTEGER greater than or equ Line 2083  POSITION: an INTEGER greater than or equ
2083    ;; The declaration for I may be too restrictive in the case of    ;; The declaration for I may be too restrictive in the case of
2084    ;; lists.  But then again, it is still a huge number.    ;; lists.  But then again, it is still a huge number.
2085    (do ((lis l (rest lis))    (do ((lis l (rest lis))
2086         (i start (1+ i))         (i start (1+ i)))
2087         )        ((or (endp lis)
2088        ((or (endp lis) (>= i end)) i)             (>= i end))
2089           i)
2090      (declare (type list lis))      (declare (type list lis))
2091      (declare (type index i))      (declare (type index i))
2092      (let* ((eof-marker (load-time-value (list 'eof-marker)))      (let* ((eof-marker (load-time-value (list 'eof-marker)))
# Line 2110  POSITION: an INTEGER greater than or equ Line 2115  POSITION: an INTEGER greater than or equ
2115      (loop while (plusp numbytes) do      (loop while (plusp numbytes) do
2116            (let ((bytes-read (system:read-n-bytes stream s start numbytes nil)))            (let ((bytes-read (system:read-n-bytes stream s start numbytes nil)))
2117              (when (zerop bytes-read)              (when (zerop bytes-read)
2118                (return-from read-into-simple-string total-bytes))                (return-from read-into-simple-string start))
2119              (incf total-bytes bytes-read)              (incf total-bytes bytes-read)
2120              (incf start bytes-read)              (incf start bytes-read)
2121              (decf numbytes bytes-read)))              (decf numbytes bytes-read)))
2122      total-bytes))      start))
2123    
2124    
2125  (defun read-into-string (s stream start end)  (defun read-into-string (s stream start end)
# Line 2127  POSITION: an INTEGER greater than or equ Line 2132  POSITION: an INTEGER greater than or equ
2132             :expected-type (stream-element-type stream)             :expected-type (stream-element-type stream)
2133             :format-control "Trying to read characters from a binary stream."))             :format-control "Trying to read characters from a binary stream."))
2134    (do ((i start (1+ i))    (do ((i start (1+ i))
2135         (s-len (length s))         (s-len (length s)))
2136         )        ((or (>= i s-len)
2137        ((or (>= i s-len) (>= i end)) i)             (>= i end))
2138           i)
2139      (declare (type index i s-len))      (declare (type index i s-len))
2140      (let* ((eof-marker (load-time-value (list 'eof-marker)))      (let* ((eof-marker (load-time-value (list 'eof-marker)))
2141             (el (read-char stream nil eof-marker)))             (el (read-char stream nil eof-marker)))
# Line 2157  POSITION: an INTEGER greater than or equ Line 2163  POSITION: an INTEGER greater than or equ
2163      (unsigned-byte 32)      (unsigned-byte 32)
2164      (signed-byte 8)      (signed-byte 8)
2165      (signed-byte 16)      (signed-byte 16)
   
2166      (signed-byte 32)      (signed-byte 32)
2167      ))      ))
2168    
# Line 2177  POSITION: an INTEGER greater than or equ Line 2182  POSITION: an INTEGER greater than or equ
2182                       (simple-array (signed-byte 32) (*))                       (simple-array (signed-byte 32) (*))
2183                       (simple-array (unsigned-byte *) (*))                       (simple-array (unsigned-byte *) (*))
2184                       (simple-array (signed-byte *) (*))                       (simple-array (signed-byte *) (*))
2185                       )                       simple-bit-vector)
2186                   s))                   s))
2187    
2188    (declare (type stream stream))    (declare (type stream stream))
# Line 2264  POSITION: an INTEGER greater than or equ Line 2269  POSITION: an INTEGER greater than or equ
2269                    (read-n-x8-bytes stream data offset-start offset-end 32))                    (read-n-x8-bytes stream data offset-start offset-end 32))
2270    
2271                   ;; Otherwise we resort to the READ-BYTE based operation.                   ;; Otherwise we resort to the READ-BYTE based operation.
2272                     (simple-bit-vector
2273                      (read-into-vector s stream start end))
2274                   ((simple-array (unsigned-byte *) (*))                   ((simple-array (unsigned-byte *) (*))
2275                    (read-into-vector s stream start end))                    (read-into-vector s stream start end))
   
2276                   ((simple-array (signed-byte *) (*))                   ((simple-array (signed-byte *) (*))
2277                    (read-into-vector s stream start end))                    (read-into-vector s stream start end)))))))))
                  ))                     ; with-array-data  
              )                          ; flet  
            ))  
     ))  
2278    
2279    
2280  ;;; READ-INTO-VECTOR --  ;;; READ-INTO-VECTOR --
# Line 2284  POSITION: an INTEGER greater than or equ Line 2286  POSITION: an INTEGER greater than or equ
2286    (let* ((stream-et (stream-element-type stream))    (let* ((stream-et (stream-element-type stream))
2287           (read-function (if (subtypep stream-et 'character)           (read-function (if (subtypep stream-et 'character)
2288                              #'read-char                              #'read-char
2289                              #'read-byte))                              #'read-byte)))
          )  
2290      (do ((i start (1+ i))      (do ((i start (1+ i))
2291           (a-len (length v))           (a-len (length v)))
2292           )          ((or (>= i a-len) (>= i end))
2293          ((or (>= i a-len) (>= i end)) i)           i)
2294        (declare (type index i a-len))        (declare (type index i a-len))
2295        (let* ((eof-marker (load-time-value (list 'eof-marker)))        (let* ((eof-marker (load-time-value (list 'eof-marker)))
2296               (el (funcall read-function stream nil eof-marker)))               (el (funcall read-function stream nil eof-marker)))

Legend:
Removed from v.1.66  
changed lines
  Added in v.1.67

  ViewVC Help
Powered by ViewVC 1.1.5