diff options
Diffstat (limited to 'system/lib/libc/musl/src/stdio/fputwc.c')
-rw-r--r-- | system/lib/libc/musl/src/stdio/fputwc.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/system/lib/libc/musl/src/stdio/fputwc.c b/system/lib/libc/musl/src/stdio/fputwc.c index e87e47d4..603fa615 100644 --- a/system/lib/libc/musl/src/stdio/fputwc.c +++ b/system/lib/libc/musl/src/stdio/fputwc.c @@ -17,15 +17,28 @@ wint_t __fputwc_unlocked(wchar_t c, FILE *f) l = wctomb((void *)f->wpos, c); if (l < 0) c = WEOF; else f->wpos += l; -#else - if (isascii(c)) { - c = fputc(c, f); -#endif } else { l = wctomb(mbc, c); if (l < 0 || __fwritex((void *)mbc, l, f) < l) c = WEOF; } return c; +#else + if (isascii(c)) { + c = fputc(c, f); + } else { + l = wctomb(mbc, c); + if (l < 0) c = WEOF; + else { + for (int i = 0; i < l; i++) { + if (fputc(mbc[i], f) == EOF) { + c = WEOF; + break; + } + } + } + } +#endif + return c; } wint_t fputwc(wchar_t c, FILE *f) |