summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2006-01-11 19:42:40 +0000
committerWayne Davison <wayned@users.sourceforge.net>2006-01-11 19:42:40 +0000
commit4ffa433443f64bf9183d23dba82b122a2f7a3226 (patch)
tree4c1e7a0b74e7934bce3ec49e4d6a45812a8f4958 /Src
parentfa633171fd280096280628887947eb6a0dac3de7 (diff)
downloadzsh-4ffa433443f64bf9183d23dba82b122a2f7a3226.tar.gz
zsh-4ffa433443f64bf9183d23dba82b122a2f7a3226.tar.xz
zsh-4ffa433443f64bf9183d23dba82b122a2f7a3226.zip
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.
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/zle_main.c9
1 files 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