2
* This code was written by Rich Felker in 2010; no copyright is claimed.
3
* This code is in the public domain. Attribution is appreciated but
14
size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict wcs, size_t wn, size_t n, mbstate_t *restrict st)
18
const wchar_t *ws = *wcs;
20
if (!dst) s = buf, n = sizeof buf;
23
while ( ws && n && ( (n2=wn)>=n || n2>32 ) ) {
26
l = wcsrtombs(s, &ws, n2, 0);
38
if (ws) while (n && wn) {
39
l = wcrtomb(s, *ws, 0);
46
/* safe - this loop runs fewer than sizeof(buf) times */