Last change
on this file since 577 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
644 bytes
|
Line | |
---|
1 | #include <stdlib.h> |
---|
2 | #include <wchar.h> |
---|
3 | #include "local.h" |
---|
4 | |
---|
5 | size_t |
---|
6 | _mbstowcs_r (struct _reent *r, |
---|
7 | wchar_t *__restrict pwcs, |
---|
8 | const char *__restrict s, |
---|
9 | size_t n, |
---|
10 | mbstate_t *state) |
---|
11 | { |
---|
12 | size_t ret = 0; |
---|
13 | char *t = (char *)s; |
---|
14 | int bytes; |
---|
15 | |
---|
16 | if (!pwcs) |
---|
17 | n = (size_t) 1; /* Value doesn't matter as long as it's not 0. */ |
---|
18 | while (n > 0) |
---|
19 | { |
---|
20 | bytes = __MBTOWC (r, pwcs, t, MB_CUR_MAX, state); |
---|
21 | if (bytes < 0) |
---|
22 | { |
---|
23 | state->__count = 0; |
---|
24 | return -1; |
---|
25 | } |
---|
26 | else if (bytes == 0) |
---|
27 | break; |
---|
28 | t += bytes; |
---|
29 | ++ret; |
---|
30 | if (pwcs) |
---|
31 | { |
---|
32 | ++pwcs; |
---|
33 | --n; |
---|
34 | } |
---|
35 | } |
---|
36 | return ret; |
---|
37 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.