fix assumption in fputs that fwrite returning 0 implies an error
authorRich Felker <dalias@aerifal.cx>
Tue, 16 Feb 2016 18:26:16 +0000 (13:26 -0500)
committerRich Felker <dalias@aerifal.cx>
Tue, 16 Feb 2016 18:26:16 +0000 (13:26 -0500)
commit10a17dfbad2c267d885817abc9c7589fc7ff630b
tree18813bb6680ec2140a595e2b7364d61626a5a1d2
parent9c102700a7b9e743da692d3cb6bfa580fcdd4379
fix assumption in fputs that fwrite returning 0 implies an error

internally, the idiom of passing nmemb=1 to fwrite and interpreting
the return value of fwrite (which is necessarily 0 or 1) as
failure/success is fairly widely used. this is not correct, however,
when the size argument is unknown and may be zero, since C requires
fwrite to return 0 in that special case. previously fwrite always
returned nmemb on success, but this was changed for conformance with
ISO C by commit 500c6886c654fd45e4926990fee2c61d816be197.
src/stdio/fputs.c