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 *dst, const wchar_t **wcs, size_t wn, size_t n, mbstate_t *st)
18 const wchar_t *ws = *wcs;
20 if (!dst) s = buf, n = sizeof buf;
23 while ( n && ( (n2=wn)>=n || n2>32 ) ) {
26 l = wcsrtombs(s, &ws, n2, 0);
39 l = wcrtomb(s, *ws, 0);
45 /* safe - this loop runs fewer than sizeof(buf) times */