X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=inline;f=src%2Fstdio%2Ffputws.c;h=0ed02f1c004e8622e0d4367116a60f22e249720f;hb=3733c831f293b3bbfd0e51faec8ee71112c62c3e;hp=0b593c08d1d50d28d0c5832323402de72ec0c42f;hpb=400c5e5c8307a2ebe44ef1f203f5a15669f20347;p=musl diff --git a/src/stdio/fputws.c b/src/stdio/fputws.c index 0b593c08..0ed02f1c 100644 --- a/src/stdio/fputws.c +++ b/src/stdio/fputws.c @@ -1,22 +1,28 @@ #include "stdio_impl.h" +#include "locale_impl.h" +#include int fputws(const wchar_t *restrict ws, FILE *restrict f) { unsigned char buf[BUFSIZ]; size_t l=0; + locale_t *ploc = &CURRENT_LOCALE, loc = *ploc; FLOCK(f); - f->mode |= f->mode+1; + fwide(f, 1); + *ploc = f->locale; while (ws && (l = wcsrtombs((void *)buf, (void*)&ws, sizeof buf, 0))+1 > 1) if (__fwritex(buf, l, f) < l) { FUNLOCK(f); + *ploc = loc; return -1; } FUNLOCK(f); + *ploc = loc; return l; /* 0 or -1 */ }