fix incorrect return value for fwide function
authorRich Felker <dalias@aerifal.cx>
Tue, 1 Jul 2014 22:49:54 +0000 (18:49 -0400)
committerRich Felker <dalias@aerifal.cx>
Tue, 1 Jul 2014 22:49:54 +0000 (18:49 -0400)
when the orientation of the stream was already set, fwide was
incorrectly returning its argument (the requested orientation) rather
than the actual orientation of the stream.

src/stdio/fwide.c

index fdf8e4b..8088e7a 100644 (file)
@@ -7,7 +7,8 @@
 int fwide(FILE *f, int mode)
 {
        FLOCK(f);
-       if (!f->mode) mode = f->mode = NORMALIZE(mode);
+       if (!f->mode) f->mode = NORMALIZE(mode);
+       mode = f->mode;
        FUNLOCK(f);
        return mode;
 }