unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: dwheeler@dwheeler.com
Cc: almkglor@gmail.com, 12216@debbugs.gnu.org
Subject: bug#12216: peek-char incorrectly *CONSUMES* eof
Date: Tue, 05 Mar 2013 17:53:45 +0100	[thread overview]
Message-ID: <87sj49vld2.fsf@pobox.com> (raw)
In-Reply-To: <E1T2BkZ-0000eD-Hg@fenris.runbox.com> (David A. Wheeler's message of "Thu, 16 Aug 2012 21:53:23 -0400 (EDT)")

Hi,

On Fri 17 Aug 2012 03:53, "David A. Wheeler" <dwheeler@dwheeler.com> writes:

> Guile's peek-char has a bug; it incorrectly *consumes* eof instead of
> just reporting it.

I'm not sure there is a sane way to deal with this.  Guile's ports are
fundamentally binary, underneath.  The backing store is a byte buffer
that is decoded and encoded to Scheme characters at need, along with
vtable to fill and flush that buffer.  You can do strange things like
unread characters, switch the encoding, and read them back out in a
different encoding.  There is no way to represent EOF in that buffer.

I have the feeling that for interactive use, if you expect to read a EOF
from a port and then continue, you have to not use peek-char.  You need
to handle your own lookahead buffer.  I know it's not a great answer,
but I can't think of anything else that makes sense.

What do you think?

Andy
-- 
http://wingolog.org/





  reply	other threads:[~2013-03-05 16:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1T29qG-00049i-Rt@fenris.runbox.com>
     [not found] ` <CAF+kUQVT7BmVaZ-XNFDNpaPFXyWUZv9msC_3m9iNa3yQzKw_1w@mail.gmail.com>
2012-08-17  1:53   ` bug#12216: peek-char incorrectly *CONSUMES* eof David A. Wheeler
2013-03-05 16:53     ` Andy Wingo [this message]
2013-03-05 19:17       ` David A. Wheeler
2013-03-07 21:32         ` Andy Wingo
2013-03-09  2:25           ` Daniel Hartwig
2013-03-09 17:11             ` David A. Wheeler
2013-03-10  0:23               ` Daniel Hartwig
2013-03-13 11:02               ` Andy Wingo
2013-03-13 13:09                 ` David A. Wheeler
2013-03-13 14:33                   ` Andy Wingo
2013-03-13 18:10                     ` Mark H Weaver
2013-03-13 18:22                       ` Andy Wingo
2013-03-14 17:13                         ` Mark H Weaver
2013-03-14 17:43                           ` David A. Wheeler
2013-03-30 22:37                         ` Mark H Weaver
2013-03-30 23:02                           ` David A. Wheeler
2013-04-01  2:05                           ` Mark H Weaver
2013-04-01 21:27                             ` Mark H Weaver
2013-04-01 21:33                               ` David A. Wheeler
2013-04-02  7:58                               ` Andy Wingo
2013-04-02 19:41                                 ` Mark H Weaver
2013-04-04 20:00                                   ` Andy Wingo
2013-04-04 21:53                                     ` Mark H Weaver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sj49vld2.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=12216@debbugs.gnu.org \
    --cc=almkglor@gmail.com \
    --cc=dwheeler@dwheeler.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).