libc: Restore fp state upon flush error in fputc
This is akin to commit bafaa70b6f9098d83d074968c8e6747ecec1e118.
Reported by: Guy Yur <guyyur@gmail.com>
Fixes: 86a16ada1ea6
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 6e13794fbe6e82c21365d0fd66769bf8b19c0197)