Skip to content
Snippets Groups Projects
Commit 6442404a authored by ram's avatar ram
Browse files

Re-frobbed fd-stream-read-n-bytes to preserve the property of returning less

than the requested number of bytes when eof-error-p is NIL and that is what
unix-read read.
parent 714594b1
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
;;; Scott Fahlman or slisp-group@cs.cmu.edu. ;;; Scott Fahlman or slisp-group@cs.cmu.edu.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/fd-stream.lisp,v 1.32 1994/01/06 19:50:20 ram Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/fd-stream.lisp,v 1.33 1994/01/08 18:42:47 ram Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -743,9 +743,10 @@ non-server method is also significantly more efficient for large reads. ...@@ -743,9 +743,10 @@ non-server method is also significantly more efficient for large reads.
(unless count (unless count
(error "Error reading ~S: ~A" stream (error "Error reading ~S: ~A" stream
(unix:get-unix-error-msg err))) (unix:get-unix-error-msg err)))
(when (zerop count) (if eof-error-p
(return (eof-or-lose stream eof-error-p (when (zerop count)
(- requested now-needed)))) (error 'end-of-file :stream stream))
(return (- requested now-needed)))
(decf now-needed count) (decf now-needed count)
(when (zerop now-needed) (return requested)) (when (zerop now-needed) (return requested))
(incf offset count))))) (incf offset count)))))
...@@ -762,9 +763,9 @@ non-server method is also significantly more efficient for large reads. ...@@ -762,9 +763,9 @@ non-server method is also significantly more efficient for large reads.
(unless count (unless count
(error "Error reading ~S: ~A" stream (error "Error reading ~S: ~A" stream
(unix:get-unix-error-msg err))) (unix:get-unix-error-msg err)))
(when (zerop count) (when (and eof-error-p (zerop count))
(return (eof-or-lose stream eof-error-p (error 'end-of-file :stream stream))
(- requested now-needed))))
(let* ((copy (min now-needed count)) (let* ((copy (min now-needed count))
(copy-bits (* copy vm:byte-bits)) (copy-bits (* copy vm:byte-bits))
(buffer-start-bits (buffer-start-bits
...@@ -781,10 +782,10 @@ non-server method is also significantly more efficient for large reads. ...@@ -781,10 +782,10 @@ non-server method is also significantly more efficient for large reads.
copy-bits)) copy-bits))
(decf now-needed copy) (decf now-needed copy)
(when (zerop now-needed) (when (or (zerop now-needed) (not eof-error-p))
(setf (fd-stream-ibuf-head stream) copy) (setf (fd-stream-ibuf-head stream) copy)
(setf (fd-stream-ibuf-tail stream) count) (setf (fd-stream-ibuf-tail stream) count)
(return requested)) (return (- requested now-needed)))
(incf offset copy))))))))))) (incf offset copy)))))))))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment