unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Mark H Weaver <mhw@netris.org>
Cc: 10627@debbugs.gnu.org
Subject: bug#10627: char-ready? is broken for multibyte encodings
Date: Sun, 24 Feb 2013 23:15:33 +0100	[thread overview]
Message-ID: <87y5ed8ika.fsf@pobox.com> (raw)
In-Reply-To: <87ip5h79ma.fsf@tines.lan> (Mark H. Weaver's message of "Sun, 24 Feb 2013 15:14:05 -0500")

Hi :)

On Sun 24 Feb 2013 21:14, Mark H Weaver <mhw@netris.org> writes:

> Andy Wingo <wingo@pobox.com> writes:
>
>> On Sat 28 Jan 2012 11:21, Mark H Weaver <mhw@netris.org> writes:
>>
>>> The R5RS specifies that if 'char-ready?' returns #t, then the next
>>> 'read-char' operation is guaranteed not to hang.  This is not currently
>>> the case for ports using a multibyte encoding.
>>>
>>> 'char-ready?' currently returns #t whenever at least one _byte_ is
>>> available.  This is not correct in general.  It should return #t only if
>>> there is a complete _character_ available.
>>
>> This procedure is omitted in the R6RS because it is not a good
>> interface.  Besides its semantic difficulties, can you think of a sane
>> implementation for multibyte characters?
>
> Maybe I'm missing something, but I don't see any semantic problem here,
> and it seems straightforward to implement.  'char-ready?' should simply
> read bytes until either a complete character is available, or no more
> bytes are ready.  In either case, all the bytes should then be 'unget'
> before returning.  What's the problem?

The problem is that char-ready? should not read anything.  If you want
to peek, use peek-char.  Note that if the stream is at EOF, char-ready?
should return #t.

Andy
-- 
http://wingolog.org/





  reply	other threads:[~2013-02-24 22:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-28 10:21 bug#10627: char-ready? is broken for multibyte encodings Mark H Weaver
2013-02-24 19:11 ` Andy Wingo
2013-02-24 20:14   ` Mark H Weaver
2013-02-24 22:15     ` Andy Wingo [this message]
2013-02-25  0:06       ` Mark H Weaver
2013-02-25  1:23         ` Daniel Hartwig
2013-02-25  8:55         ` Andy Wingo
2013-02-26 19:50           ` Mark H Weaver
2013-02-26 19:59             ` Andy Wingo
2016-06-20 19:23               ` Andy Wingo

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=87y5ed8ika.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=10627@debbugs.gnu.org \
    --cc=mhw@netris.org \
    /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).