[Openmcl-devel] peek-char advances the file-position

Pascal J. Bourguignon pjb at informatimago.com
Wed Apr 4 05:54:15 PDT 2012


Gary Byers <gb at clozure.com> writes:

> On Wed, 4 Apr 2012, Pascal J. Bourguignon wrote:
> [Calling PEEK-CHAR on a FILE-STREAM changes the value returned by FILE-POSITION.]
>
> A simple test case:
>
> (with-open-file (f "some-file")
>   (loop
>     (let* ((before (file-position f))
>            (ch (peek-char nil f nil nil))
>            (after (file-position f)))
>       (when (null ch) (return))
>       (unless (eql before after)
>         (error "PEEK-CHAR changed file position from ~s to ~s." before after))
>       (read-char f)))
>
> errors on the first iteration (and would show that the file position changes
> on every iteration if the test was changed to simply print that fact.)  That's
> been present for a few years, and there doesn't seem to be anything very subtle
> about it.
>
> That should be fixed in the trunk in r15292 and (after a bit of smoke-testing)
> should probably be propagated to the 1.8 branch as well.

Indeed.  In my case I use (peek-char t …), not (peek-char nil …), and
there it seems the bad result is more random.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.



More information about the Openmcl-devel mailing list