X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/901ec1537a0ceb980398a5395751ea0e445c4ce5..9906579faa96e719a947b1057ccadaf662a9a969:/src/files.c diff --git a/src/files.c b/src/files.c index 92573585..da4c36b1 100644 --- a/src/files.c +++ b/src/files.c @@ -120,19 +120,17 @@ xfopen (const char *name, const char *mode) | Try to close file PTR, and print an error message if fails. | `-------------------------------------------------------------*/ -int +void xfclose (FILE *ptr) { - int result; - if (ptr == NULL) - return 0; + return; - result = fclose (ptr); - if (result == EOF) - error (EXIT_FAILURE, errno, _("cannot close file")); + if (ferror (ptr)) + error (EXIT_FAILURE, 0, _("I/O error")); - return result; + if (fclose (ptr) != 0) + error (EXIT_FAILURE, errno, _("cannot close file")); }