From 629cab425f0439866694dfbf44650b6dc6623ea5 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Sat, 15 Aug 2020 15:24:14 -0400 Subject: cleanup --- src/wchar/fputwc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/wchar/fputwc.c b/src/wchar/fputwc.c index 803ccfdb..056ff472 100644 --- a/src/wchar/fputwc.c +++ b/src/wchar/fputwc.c @@ -1,25 +1,23 @@ #include -#include "stdio.h" -#include "../stdio/_stdio.h" -#include "limits.h" -#include "errno.h" +#include +#include +#include +#include "stdio/_stdio.h" wint_t fputwc(wchar_t c, FILE * stream) { + char mbs[MB_LEN_MAX+1] = {0}; + mbstate_t ps = 0; + size_t len = wcrtomb(mbs, c, &ps); size_t i; if (fwide(stream, 1) <= 0) { - /* not a wide stream */ return WEOF; } flockfile(stream); stream->orientation = -1; - char mbs[MB_LEN_MAX+1] = {0}; - mbstate_t ps = 0; - size_t len = wcrtomb(mbs, c, &ps); - if (len == (size_t)-1) { errno = EILSEQ; return WEOF; @@ -27,7 +25,7 @@ wint_t fputwc(wchar_t c, FILE * stream) /* FIXME: check for errors here */ for (i = 0; i < len; i++) { - fputc(mbs[i], stream); + putc_unlocked(mbs[i], stream); } stream->orientation = 1; -- cgit v1.2.1