mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
(check_file): Report error right away if I/O fails,
so that the proper errno value is used. (check_file): Check for ferror (stdout) even if ostream == stdout. (check_file): Don't report bogus errno value after ferror discovers an output error. We don't know the proper errno value, since it might have been caused by any of a whole bunch of calls, and it might have been trashed in the meantime. Fixing this problem will require much more extensive changes; in the meantime just say "write error".
This commit is contained in:
1 parent
afd3a1e066
commit
8a0be33fd7
1 file changed
+8
-2
+8
-2
@@ -335,7 +335,11 @@ check_file (const char *infile, const char *outfile)
|
||||
char *thisfield;
|
||||
size_t thislen;
|
||||
if (readlinebuffer (thisline, istream) == 0)
|
||||
break;
|
||||
{
|
||||
if (ferror (istream))
|
||||
goto closefiles;
|
||||
break;
|
||||
}
|
||||
thisfield = find_field (thisline);
|
||||
thislen = thisline->length - 1 - (thisfield - thisline->buffer);
|
||||
match = !different (thisfield, prevfield, thislen, prevlen);
|
||||
@@ -377,9 +381,11 @@ check_file (const char *infile, const char *outfile)
|
||||
if (ferror (istream) || fclose (istream) == EOF)
|
||||
error (EXIT_FAILURE, errno, _("error reading %s"), infile);
|
||||
|
||||
if (ferror (ostream))
|
||||
error (EXIT_FAILURE, 0, _("error writing %s"), outfile);
|
||||
/* Close ostream only if it's not stdout -- the latter is closed
|
||||
via the atexit-invoked close_stdout. */
|
||||
if (ostream != stdout && (ferror (ostream) || fclose (ostream) == EOF))
|
||||
if (ostream != stdout && fclose (ostream) != 0)
|
||||
error (EXIT_FAILURE, errno, _("error writing %s"), outfile);
|
||||
|
||||
free (lb1.buffer);
|
||||
|
||||
Reference in new issue
Block a user