1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-07 09:21:18 +02:00

- Use "mbs" for the multi-byte state variable name (for consistency).

- Use the new MB_INVALID and MB_INCOMPLETE defines for the size_t
  -1 and -2 values (respectively).
This commit is contained in:
Wayne Davison 2006-01-12 00:51:53 +00:00
parent 542797377a
commit f6fefb2db3

View file

@ -1911,12 +1911,12 @@ pfxlen(char *s, char *t)
#ifdef MULTIBYTE_SUPPORT
wchar_t wc;
mbstate_t ps;
mbstate_t mbs;
size_t cnt;
int lasti = 0;
char inc;
memset(&ps, 0, sizeof ps);
memset(&mbs, 0, sizeof mbs);
while (*s) {
if (*s == Meta) {
if (*t != Meta || t[1] != s[1])
@ -1934,12 +1934,12 @@ pfxlen(char *s, char *t)
t++;
}
cnt = mbrtowc(&wc, &inc, 1, &ps);
if (cnt == (size_t)-1) {
cnt = mbrtowc(&wc, &inc, 1, &mbs);
if (cnt == MB_INVALID) {
/* error */
break;
}
if (cnt != (size_t)-2) {
if (cnt != MB_INCOMPLETE) {
/* successfully found complete character, record position */
lasti = i;
}