From d7b3821c0aa6402a89dd10f1e47e58524a8fe977 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 4 Oct 2014 14:27:08 -0700 Subject: [PATCH] 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 --- fish_indent.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fish_indent.cpp b/fish_indent.cpp index 1332db5e8..21ffd47f7 100644 --- a/fish_indent.cpp +++ b/fish_indent.cpp @@ -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);