GNU bug report logs -
#12216
peek-char incorrectly *CONSUMES* eof
Previous Next
Reported by: dwheeler <at> dwheeler.com
Date: Fri, 17 Aug 2012 02:03:01 UTC
Severity: normal
Done: Mark H Weaver <mhw <at> netris.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#12216: peek-char incorrectly *CONSUMES* eof
which was filed against the guile package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 12216 <at> debbugs.gnu.org.
--
12216: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12216
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
I've pushed 1ea37620c2c1794f7685b312d2530676a078ada7 to stable-2.0,
which fixes our number printer. Closing this bug.
Thanks,
Mark
[Message part 3 (message/rfc822, inline)]
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
This bug report was last modified 12 years and 50 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.