rewrite popen to use posix_spawn instead of fragile vfork hacks
[musl] / src / stdio / fputws.c
1 #include "stdio_impl.h"
2 #include <wchar.h>
3
4 int fputws(const wchar_t *restrict ws, FILE *restrict f)
5 {
6         unsigned char buf[BUFSIZ];
7         size_t l=0;
8
9         FLOCK(f);
10
11         f->mode |= f->mode+1;
12
13         while (ws && (l = wcsrtombs((void *)buf, (void*)&ws, sizeof buf, 0))+1 > 1)
14                 if (__fwritex(buf, l, f) < l) {
15                         FUNLOCK(f);
16                         return -1;
17                 }
18
19         FUNLOCK(f);
20
21         return l; /* 0 or -1 */
22 }
23
24 weak_alias(fputws, fputws_unlocked);