[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug with file I/O
- To: info-mcl@cambridge.apple.com, bug-mcl@cambridge.apple.com
- Subject: Bug with file I/O
- From: cornell@unix1.cs.umass.edu (Matthew Cornell)
- Date: Mon, 10 Jun 91 16:25:03 EDT
I believe the following code should write a sequence of 256 a's b's
and c's. Instead we get various incorrect results. I remember someone
reporting a similar problem not too long ago. I would be *very*
grateful for any patches that correct this problem.
matt
==== Start sample code ====
(defun file-test (file-name list-name)
(with-open-file (file-stream file-name
:direction :output
:if-exists :overwrite
:if-does-not-exist :create)
(write-it file-stream list-name)))
(defun write-it (file-stream list-name)
(dolist (cur-elem list-name)
(write-string-at-pos file-stream (cdr cur-elem) (car cur-elem))))
(defun write-string-at-pos (file-stream input-string position)
(declare (optimize speed))
(file-position file-stream position)
(with-input-from-string (my-stream input-string)
(let ((eof (list 'eof)))
(do ((current-object (read-char my-stream nil eof)
(read-char my-stream nil eof)))
((eq current-object eof) t)
(format file-stream "~a" current-object)))))
(setq tmpp
'((0 .
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
(256 .
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
(512 .
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc")
(768 .
"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd")
))
==== End sample code ====