diff options
author | Wayne Davison <wayned@users.sourceforge.net> | 2006-01-11 19:49:59 +0000 |
---|---|---|
committer | Wayne Davison <wayned@users.sourceforge.net> | 2006-01-11 19:49:59 +0000 |
commit | c6798bc1516dcd1f81b43ca010b448b65dc68228 (patch) | |
tree | 7bb34ef72059979148683cfac7cb74dccd4b8fc6 | |
parent | 4ffa433443f64bf9183d23dba82b122a2f7a3226 (diff) | |
download | zsh-c6798bc1516dcd1f81b43ca010b448b65dc68228.tar.gz zsh-c6798bc1516dcd1f81b43ca010b448b65dc68228.tar.xz zsh-c6798bc1516dcd1f81b43ca010b448b65dc68228.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.
-rw-r--r-- | Src/Zle/zle_tricky.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index ce5855b5c..d89c47b50 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -1912,10 +1912,11 @@ pfxlen(char *s, char *t) #ifdef MULTIBYTE_SUPPORT wchar_t wc; mbstate_t ps; - int ret, lasti = 0; + size_t cnt; + int lasti = 0; char inc; - memset(&ps, 0, sizeof(mbstate_t)); + memset(&ps, 0, sizeof ps); while (*s) { if (*s == Meta) { if (*t != Meta || t[1] != s[1]) @@ -1933,11 +1934,12 @@ pfxlen(char *s, char *t) t++; } - ret = mbrtowc(&wc, &inc, 1, &ps); - if (ret == -1) { + cnt = mbrtowc(&wc, &inc, 1, &ps); + if (cnt == (size_t)-1) { /* error */ break; - } else if (ret >= 0) { + } + if (cnt != (size_t)-2) { /* successfully found complete character, record position */ lasti = i; } |