(xfclose): Return void, not int, since it always returned zero.

Report I/O error if ferror indicates one.
This commit is contained in:
Paul Eggert
2002-10-30 06:19:00 +00:00
parent 760d7aa8fa
commit e63ee1f16c

View File

@@ -120,19 +120,17 @@ xfopen (const char *name, const char *mode)
| Try to close file PTR, and print an error message if fails. | | Try to close file PTR, and print an error message if fails. |
`-------------------------------------------------------------*/ `-------------------------------------------------------------*/
int void
xfclose (FILE *ptr) xfclose (FILE *ptr)
{ {
int result;
if (ptr == NULL) if (ptr == NULL)
return 0; return;
result = fclose (ptr); if (ferror (ptr))
if (result == EOF) error (EXIT_FAILURE, 0, _("I/O error"));
if (fclose (ptr) != 0)
error (EXIT_FAILURE, errno, _("cannot close file")); error (EXIT_FAILURE, errno, _("cannot close file"));
return result;
} }