--- Begin Message ---
Subject: |
peek-char incorrectly *CONSUMES* eof |
Date: |
Thu, 16 Aug 2012 21:53:23 -0400 (EDT) |
All:
Guile's peek-char has a bug; it incorrectly *consumes* eof instead of just
reporting it.
According to R5RS, "The value returned by a call to peek-char is the same as
the value that would have been returned by a call to read-char with the same
port. The only difference is that the very next call to read-char or peek-char
on that port will return the value returned by the preceding call to peek-char."
However, if the value returned is #eof, guile does *not* meet the spec; you
*can* get two successive peek-chars with different results.
This doesn't matter for files, but it *does* matter for interactive use. It
means that successive peek-char calls will actually *READ* characters, and they
can even different in results. Which means that code that does several
peek-chars can act oddly when someone tries to end it with control-D.
We've confirmed this bug is true for guile 2.0, 1.8, and 1.6.
You can confirm this by placing this in "bug-demo":
===================
(write (peek-char))
(write (peek-char))
======================
Then run "guile bug-demo". Press control-D, then newline. You can see that
two successive calls to peek-char are reporting different results (eof, then
newline), which is NEVER supposed to happen!
I just had to write some code to work around this, but it'd be nice for this to
work "correctly" in the future for interactive use. (This was code for the
"readable" project, http://readable.sourceforge.net, where we do a lot with
guile.)
Thanks for your time... and thanks for guile!
--- David A. Wheeler
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#12216: peek-char incorrectly *CONSUMES* eof |
Date: |
Thu, 04 Apr 2013 17:53:50 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Andy Wingo <address@hidden> writes:
> Looks great to me. Thanks for following up on this!
Excellent! I pushed this to stable-2.0, so it will be in Guile 2.0.8.
Closing this bug now.
Thanks!
Mark
--- End Message ---