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
4ffa433443
commit
c6798bc151
1 changed files with 7 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue