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

Hi Andy,

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 only reason I haven't yet fixed this is because it will require some
refactoring in ports.c.  I guess the most straightforward approach is to
generalize 'get_codepoint', 'get_utf8_codepoint', and
'get_iconv_codepoint' to support a non-blocking mode of operation.

What do you think?

  Regards,
    Mark





  reply	other threads:[~2013-02-24 20:14 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 [this message]
2013-02-24 22:15     ` Andy Wingo
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=87ip5h79ma.fsf@tines.lan \
    --to=mhw@netris.org \
    --cc=10627@debbugs.gnu.org \
    --cc=wingo@pobox.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).