1
0
Fork 0
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:
Wayne Davison 2006-01-11 19:49:59 +00:00
parent 4ffa433443
commit c6798bc151

View file

@ -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;
}