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:
parent
fa633171fd
commit
4ffa433443
1 changed files with 6 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue