libc/wchar: Call mbsnrtowcs in mbrtowc to handle the partial sequence correctly
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
4c34075d10
commit
c19d37adf0
@ -57,15 +57,19 @@
|
||||
size_t mbrtowc(FAR wchar_t *pwc, FAR const char *s,
|
||||
size_t n, FAR mbstate_t *ps)
|
||||
{
|
||||
int retval = 0;
|
||||
FAR const char *e = s;
|
||||
size_t retval = 0;
|
||||
|
||||
if (s == NULL)
|
||||
{
|
||||
retval = mbtowc(NULL, "", 1);
|
||||
s = e = "";
|
||||
n = 1;
|
||||
}
|
||||
else
|
||||
|
||||
retval = mbsnrtowcs(pwc, &e, 1, n, ps);
|
||||
if (retval == 1)
|
||||
{
|
||||
retval = mbtowc(pwc, s, n);
|
||||
retval = e - s;
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
Loading…
Reference in New Issue
Block a user