1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-30 19:20:53 +02:00

The return value of mbrtowc() is a size_t (unsigned), so don't

assign it to an int and then check if it's < 0, as that won't
work on a system where an int is larger than a size_t.
This commit is contained in:
Wayne Davison 2006-01-11 19:42:40 +00:00
parent fa633171fd
commit 4ffa433443

View file

@ -760,7 +760,7 @@ getrestchar(int inchar)
{
char c = inchar;
wchar_t outchar;
int ret, timeout;
int timeout;
static mbstate_t ps;
/*
@ -780,14 +780,17 @@ getrestchar(int inchar)
* Return may be zero if we have a NULL; handle this like
* any other character.
*/
while ((ret = mbrtowc(&outchar, &c, 1, &ps)) < 0) {
if (ret == -1) {
while (1) {
size_t cnt = mbrtowc(&outchar, &c, 1, &ps);
if (cnt == (size_t)-1) {
/*
* Invalid input. Hmm, what's the right thing to do here?
*/
memset(&ps, 0, sizeof(ps));
return lastchar_wide = WEOF;
}
if (cnt != (size_t)-2)
break;
/*
* Always apply KEYTIMEOUT to the remains of the input