[Cl-darcs-cvs] r4 - cl-darcs/trunk

mhenoch at common-lisp.net mhenoch at common-lisp.net
Tue May 23 17:12:51 UTC 2006


Author: mhenoch
Date: Tue May 23 13:12:51 2006
New Revision: 4

Modified:
   cl-darcs/trunk/unreadable-stream.lisp
Log:
Handle unreading of empty sequences.


Modified: cl-darcs/trunk/unreadable-stream.lisp
==============================================================================
--- cl-darcs/trunk/unreadable-stream.lisp	(original)
+++ cl-darcs/trunk/unreadable-stream.lisp	Tue May 23 13:12:51 2006
@@ -112,7 +112,7 @@
 		(sequence (third buffer-entry)))
 	    (pop buffer)
 	    ;; Simple case: it's a vector, and we haven't begun nibbling at it.
-	    (if (and (vectorp sequence) (= (first buffer-entry) 0))
+	    (if (and (vectorp sequence) (= start 0))
 		sequence
 		;; Otherwise, make a new vector.
 		(make-array (- end start) :element-type '(unsigned-byte 8)
@@ -133,13 +133,18 @@
   "Store SEQUENCE at the head of the unread buffer.
 It is assumed that SEQUENCE will not be modified."
   (with-slots (buffer) stream
-    (push (list 0 (length sequence) sequence) buffer)))
+    ;; Empty sequences must not be stored in the buffer.
+    (unless (zerop (length sequence))
+      (push (list 0 (length sequence) sequence) buffer))))
 
 (defmethod unread-line ((stream unreadable-stream) line)
   "Store LINE with an appended newline at the head of the unread buffer.
 It is assumed that SEQUENCE will not be modified."
   (with-slots (buffer) stream
-    (push (list 0 (length line) line :line) buffer)))
+    ;; If the line is empty, just store a newline.
+    (if (zerop (length line))
+	(push 10 buffer)
+	(push (list 0 (length line) line :line) buffer))))
 
 (defmethod print-object ((object unreadable-stream) stream)
   (if *print-readably* (call-next-method)



More information about the Cl-darcs-cvs mailing list