From a1c04fe77fbea96b5c038547f64a6fff0089ed77 Mon Sep 17 00:00:00 2001
From: Raymond Toy <toy.raymond@gmail.com>
Date: Sat, 23 Mar 2013 10:27:43 -0700
Subject: [PATCH] Fix ticket:79

 * Initialize in-length to in-buffer-length, not 0.
 * Added a few more debugging prints.
---
 src/code/fd-stream.lisp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/code/fd-stream.lisp b/src/code/fd-stream.lisp
index 7fcd0bca8..80e294141 100644
--- a/src/code/fd-stream.lisp
+++ b/src/code/fd-stream.lisp
@@ -260,7 +260,7 @@
   ;; in-buffer-length, but could be less if we reached the
   ;; end-of-file.
   #+unicode
-  (in-length 0 :type index)
+  (in-length in-buffer-length :type index)
   ;;
   ;; Indicates how to handle errors when converting octets to
   ;; characters.  If NIL, then the external format should handle it
@@ -1697,6 +1697,8 @@
 	      (posn errno)
 	    (unix:unix-lseek (fd-stream-fd stream) 0 unix:l_incr)
 	  (declare (type (or (integer 0) null) posn))
+	  #+nil
+	  (format t "lseek returns ~D ~D~%" posn errno)
 	  (cond (posn
 		 ;; Adjust for buffered output:
 		 ;;  If there is any output buffered, the *real* file position
@@ -1716,6 +1718,8 @@
 		 (decf posn (- (fd-stream-ibuf-tail stream)
 			       (fd-stream-ibuf-head stream)))
 
+		 #+nil
+		 (format t "Updated posn = ~D~%" posn)
 		 #+unicode
 		 (when (fd-stream-string-buffer stream)
 		   ;; The string buffer contains Lisp characters,
@@ -1742,6 +1746,7 @@
 		       (progn
 			 (format t "new posn = ~D~%" posn)
 			 (format t "in-buffer-length = ~D~%" in-buffer-length)
+			 (format t "in-length = ~D~%" (fd-stream-in-length stream))
 			 (format t "fd-stream-in-index = ~D~%" (fd-stream-in-index stream))))))
 		 (when (fd-stream-in-buffer stream)
 		   ;; When we have an in-buffer (whether we have a
-- 
GitLab