Report I/O error if ferror indicates one.
| Try to close file PTR, and print an error message if fails. |
`-------------------------------------------------------------*/
| Try to close file PTR, and print an error message if fails. |
`-------------------------------------------------------------*/
- result = fclose (ptr);
- if (result == EOF)
- error (EXIT_FAILURE, errno, _("cannot close file"));
+ if (ferror (ptr))
+ error (EXIT_FAILURE, 0, _("I/O error"));
+ if (fclose (ptr) != 0)
+ error (EXIT_FAILURE, errno, _("cannot close file"));