musl/src/stdio/fputwc.c
Rich Felker 835f9f950e clean up stdio_impl.h
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.
2012-11-08 16:39:41 -05:00

35 lines
663 B
C

#include "stdio_impl.h"
#include <wchar.h>
#include <limits.h>
#include <ctype.h>
wint_t __fputwc_unlocked(wchar_t c, FILE *f)
{
char mbc[MB_LEN_MAX];
int l;
f->mode |= f->mode+1;
if (isascii(c)) {
c = putc_unlocked(c, f);
} else if (f->wpos + MB_LEN_MAX < f->wend) {
l = wctomb((void *)f->wpos, c);
if (l < 0) c = WEOF;
else f->wpos += l;
} else {
l = wctomb(mbc, c);
if (l < 0 || __fwritex((void *)mbc, l, f) < l) c = WEOF;
}
return c;
}
wint_t fputwc(wchar_t c, FILE *f)
{
FLOCK(f);
c = __fputwc_unlocked(c, f);
FUNLOCK(f);
return c;
}
weak_alias(__fputwc_unlocked, fputwc_unlocked);
weak_alias(__fputwc_unlocked, putwc_unlocked);