Use ferror instead of checking errno to detect errors in read_file

glibc sets errno even though the file read did not have an error
Fixes #1731
This commit is contained in:
ridiculousfish 2014-10-04 14:27:08 -07:00
parent 1665f84d60
commit d7b3821c0a

View file

@ -54,11 +54,10 @@ static void read_file(FILE *f, wcstring &b)
{
while (1)
{
errno=0;
wint_t c = fgetwc(f);
if (c == WEOF)
{
if (errno)
if (ferror(f))
{
wperror(L"fgetwc");
exit(1);