suppress null termination when fgets reads EOF with no data
[musl] / src / stdio / fwide.c
1 #include <wchar.h>
2 #include "stdio_impl.h"
3
4 #define SH (8*sizeof(int)-1)
5 #define NORMALIZE(x) ((x)>>SH | -((-(x))>>SH))
6
7 int fwide(FILE *f, int mode)
8 {
9         FLOCK(f);
10         if (!f->mode) f->mode = NORMALIZE(mode);
11         mode = f->mode;
12         FUNLOCK(f);
13         return mode;
14 }