mirror of
https://github.com/fluencelabs/musl
synced 2025-06-03 10:01:38 +00:00
this header evolved to facilitate the extremely lazy practice of omitting explicit includes of the necessary headers in individual stdio source files; not only was this sloppy, but it also increased build time. now, stdio_impl.h is only including the headers it needs for its own use; any further headers needed by source files are included directly where needed.
25 lines
405 B
C
25 lines
405 B
C
#include "stdio_impl.h"
|
|
#include <wchar.h>
|
|
|
|
int fputws(const wchar_t *restrict ws, FILE *restrict f)
|
|
{
|
|
unsigned char buf[BUFSIZ];
|
|
size_t l=0;
|
|
|
|
FLOCK(f);
|
|
|
|
f->mode |= f->mode+1;
|
|
|
|
while (ws && (l = wcsrtombs((void *)buf, (void*)&ws, sizeof buf, 0))+1 > 1)
|
|
if (__fwritex(buf, l, f) < l) {
|
|
FUNLOCK(f);
|
|
return -1;
|
|
}
|
|
|
|
FUNLOCK(f);
|
|
|
|
return l; /* 0 or -1 */
|
|
}
|
|
|
|
weak_alias(fputws, fputws_unlocked);
|