From 4ffa433443f64bf9183d23dba82b122a2f7a3226 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Wed, 11 Jan 2006 19:42:40 +0000 Subject: 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. --- Src/Zle/zle_main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 4f1079747..840abe4b7 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -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 -- cgit 1.4.1