GNU bug report logs - #12216
peek-char incorrectly *CONSUMES* eof

Previous Next

Package: guile;

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

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Mark H Weaver <mhw <at> netris.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#12216: closed (peek-char incorrectly *CONSUMES* eof)
Date: Sun, 17 Mar 2013 23:50:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sun, 17 Mar 2013 19:47:35 -0400
with message-id <87ehfdh9m0.fsf <at> tines.lan>
and subject line Re: Problems with Guile's number printer
has caused the debbugs.gnu.org bug report #12216,
regarding peek-char incorrectly *CONSUMES* eof
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> 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)]
From: "David A. Wheeler" <dwheeler <at> dwheeler.com>
To: bug-guile <at> gnu.org
Cc: almkglor <at> gmail.com
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


[Message part 3 (message/rfc822, inline)]
From: Mark H Weaver <mhw <at> netris.org>
To: Andy Wingo <wingo <at> pobox.com>
Cc: 12216-done <at> debbugs.gnu.org, Daniel Llorens <daniel.llorens <at> bluewin.ch>
Subject: Re: Problems with Guile's number printer
Date: Sun, 17 Mar 2013 19:47:35 -0400
I've pushed 1ea37620c2c1794f7685b312d2530676a078ada7 to stable-2.0,
which fixes our number printer.  Closing this bug.

   Thanks,
     Mark


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.