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:
parent
f2569b9423
commit
b04ebb80e6
|
@ -24,7 +24,7 @@ utf8_decode_char2(const char* src, size_t size, size_t* used)
|
||||||
|
|
||||||
if(!src || !size) {
|
if(!src || !size) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return 0;
|
return (wchar_t)-1;
|
||||||
}
|
}
|
||||||
if(used) *used = 1;
|
if(used) *used = 1;
|
||||||
ch = *src++;
|
ch = *src++;
|
||||||
|
@ -57,18 +57,18 @@ utf8_decode_char2(const char* src, size_t size, size_t* used)
|
||||||
ret = ch & 0x01;
|
ret = ch & 0x01;
|
||||||
} else {
|
} else {
|
||||||
errno = EILSEQ;
|
errno = EILSEQ;
|
||||||
return 0;
|
return (wchar_t)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(remain--) {
|
while(remain--) {
|
||||||
if(!--size) {
|
if(!--size) {
|
||||||
errno = EILSEQ;
|
errno = EILSEQ;
|
||||||
return 0;
|
return (wchar_t)-1;
|
||||||
}
|
}
|
||||||
ch = *src++;
|
ch = *src++;
|
||||||
if((ch & 0xC0) != 0x80) {
|
if((ch & 0xC0) != 0x80) {
|
||||||
errno = EILSEQ;
|
errno = EILSEQ;
|
||||||
return 0;
|
return (wchar_t)-1;
|
||||||
}
|
}
|
||||||
ret <<= 6;
|
ret <<= 6;
|
||||||
ret |= ch & 0x3F;
|
ret |= ch & 0x3F;
|
||||||
|
@ -76,7 +76,7 @@ utf8_decode_char2(const char* src, size_t size, size_t* used)
|
||||||
|
|
||||||
if(ret < min) {
|
if(ret < min) {
|
||||||
errno = EILSEQ;
|
errno = EILSEQ;
|
||||||
return 0;
|
return (wchar_t)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -104,7 +104,7 @@ utf8_decode_char2_force(const char* src, size_t size, size_t* used,
|
||||||
|
|
||||||
if(!src || !size) {
|
if(!src || !size) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return 0;
|
return (wchar_t)-1;
|
||||||
}
|
}
|
||||||
if(used) *used = 1;
|
if(used) *used = 1;
|
||||||
ch = *src++;
|
ch = *src++;
|
||||||
|
@ -143,7 +143,7 @@ utf8_decode_char2_force(const char* src, size_t size, size_t* used,
|
||||||
ret |= ch & 0x3F;
|
ret |= ch & 0x3F;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ch < min) goto ILSEQ;
|
if(ret < min) goto ILSEQ;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue