bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get_wch issue


From: Thomas Dickey
Subject: Re: get_wch issue
Date: Sat, 12 Aug 2006 15:49:18 -0400
User-agent: Mutt/1.5.9i

On Sat, Aug 12, 2006 at 02:12:55AM +0100, St?phane Bisinger wrote:
> Hi all
> I think I found a little bug in the wide-character
> functions of ncurses:
> if you call get_wch() without setting the CTYPE
> locale, it waits forever for new input (or until the
> buffer is full, which takes a lot of characters to
> happen...).
> 
> This happens because the code, as it is structured,
> does not check the return value of mblen (or mbrlen)
> for errors: if the return value is 0 or more, the
> function translates the chars in a wchar, otherwise it
> loops again. But there are two different return values
> for mblen errors: (size_t)(-2) is for an incomplete
> wide-character, (size_t)(-1) for an invalid
> wide-character. The latter is what you get if you try
> to read a wide-character without setting CTYPE and the
> function loops until the buffer is full.

Close - but it seems that mblen() returns only a -1 for error,
while mbrlen() could return a -1 or -2.  However, mblen() is
selected ahead of mbrlen() because iirc to work around bugs on Solaris.

-- 
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]