- while (len > 0) {
- if (len > (size_t)MB_CUR_MAX) {
- /* Enough space to translate in-place. */
- if ((nb = (int)wcrtomb(dst, *s, NULL)) < 0) {
- *src = s;
- return ((size_t)-1);
- }
- } else {
- /* May not be enough space; use temp. buffer. */
- if ((nb = (int)wcrtomb(buf, *s, NULL)) < 0) {
- *src = s;
- return ((size_t)-1);
- }
- if (nb > (int)len)
- /* MB sequence for character won't fit. */
- break;
- memcpy(dst, buf, nb);
- }
- if (*s == L'\0') {
- *src = NULL;
- return (nbytes + nb - 1);
- }
- s++;
- dst += nb;
- len -= nb;
- nbytes += nb;
- }
- *src = s;
- return (nbytes);
+size_t
+wcsrtombs(char * __restrict dst, const wchar_t ** __restrict src, size_t len,
+ mbstate_t * __restrict ps)
+{
+ return wcsrtombs_l(dst, src, len, ps, __current_locale());