utf8_decode_char2(): fix return value

The return value of utf8_decode_char2() was 0, not (wchar_t)-1 as stated in the
documentation. Fix it.
This commit is contained in:
Laurence Withers 2009-10-14 15:27:07 +00:00
parent f2569b9423
commit b04ebb80e6
1 changed files with 7 additions and 7 deletions

View File

@ -24,7 +24,7 @@ utf8_decode_char2(const char* src, size_t size, size_t* used)
if(!src || !size) {
errno = EINVAL;
return 0;
return (wchar_t)-1;
}
if(used) *used = 1;
ch = *src++;
@ -57,18 +57,18 @@ utf8_decode_char2(const char* src, size_t size, size_t* used)
ret = ch & 0x01;
} else {
errno = EILSEQ;
return 0;
return (wchar_t)-1;
}
while(remain--) {
if(!--size) {
errno = EILSEQ;
return 0;
return (wchar_t)-1;
}
ch = *src++;
if((ch & 0xC0) != 0x80) {
errno = EILSEQ;
return 0;
return (wchar_t)-1;
}
ret <<= 6;
ret |= ch & 0x3F;
@ -76,7 +76,7 @@ utf8_decode_char2(const char* src, size_t size, size_t* used)
if(ret < min) {
errno = EILSEQ;
return 0;
return (wchar_t)-1;
}
return ret;
@ -104,7 +104,7 @@ utf8_decode_char2_force(const char* src, size_t size, size_t* used,
if(!src || !size) {
errno = EINVAL;
return 0;
return (wchar_t)-1;
}
if(used) *used = 1;
ch = *src++;
@ -143,7 +143,7 @@ utf8_decode_char2_force(const char* src, size_t size, size_t* used,
ret |= ch & 0x3F;
}
if(ch < min) goto ILSEQ;
if(ret < min) goto ILSEQ;
return ret;
}