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
9 size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict wcs, size_t wn, size_t n, mbstate_t *restrict st)
13 const wchar_t *ws = *wcs;
15 if (!dst) s = buf, n = sizeof buf;
18 while ( ws && n && ( (n2=wn)>=n || n2>32 ) ) {
21 l = wcsrtombs(s, &ws, n2, 0);
33 if (ws) while (n && wn) {
34 l = wcrtomb(s, *ws, 0);
41 /* safe - this loop runs fewer than sizeof(buf) times */