X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fstdio%2Ffwide.c;h=8bab634ae0b50ad4245d38b52c00c8e1762c6ab5;hb=5690668a1bb9f551bb78d825bc804dcebe84b7e7;hp=f4da47f6da8ceca422dee4f6c4b1ad45af045ca5;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/stdio/fwide.c b/src/stdio/fwide.c index f4da47f6..8bab634a 100644 --- a/src/stdio/fwide.c +++ b/src/stdio/fwide.c @@ -1,10 +1,16 @@ +#include #include "stdio_impl.h" - -#define SH (8*sizeof(int)-1) -#define NORMALIZE(x) ((x)>>SH | -((-(x))>>SH)) +#include "locale_impl.h" int fwide(FILE *f, int mode) { - if (!f->mode) f->mode = NORMALIZE(mode); - return f->mode; + FLOCK(f); + if (mode) { + if (!f->locale) f->locale = MB_CUR_MAX==1 + ? C_LOCALE : UTF8_LOCALE; + if (!f->mode) f->mode = mode>0 ? 1 : -1; + } + mode = f->mode; + FUNLOCK(f); + return mode; }