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>
Mon, 28 Jul 2014 04:27:58 +0000 (00:27 -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.

(cherry picked from commit ebd8142a6ae19db1a5440d11c01afc7529eae0cd)

src/stdio/fwide.c

index fdf8e4bb334706ad8e4d2f911de30876e50b3bd4..8088e7ad4311f116a579c998f7aa4bee3e3e85c7 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;
 }