summaryrefslogtreecommitdiff
path: root/src/tac.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2002-01-22 17:50:41 +0000
committerJim Meyering <jim@meyering.net>2002-01-22 17:50:41 +0000
commitd283021a71673ff1a13c2954aa2cf781391d99fd (patch)
tree529f59f2f63f45eee56bdb94ee66589effa82f7a /src/tac.c
parent0e4a77847a070a4cddb9044f5ccc731b02d0e478 (diff)
downloadcoreutils-d283021a71673ff1a13c2954aa2cf781391d99fd.tar.xz
(save_stdin): Report proper errno value after
fwrite failures. Do not bother to rewind the temp file, as it'll be read backwards anyway.
Diffstat (limited to 'src/tac.c')
-rw-r--r--src/tac.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/tac.c b/src/tac.c
index de8579451..6e75aa357 100644
--- a/src/tac.c
+++ b/src/tac.c
@@ -1,5 +1,5 @@
/* tac - concatenate and print files in reverse
- Copyright (C) 1988-1991, 1995-2001 Free Software Foundation, Inc.
+ Copyright (C) 1988-1991, 1995-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -453,15 +453,13 @@ save_stdin (FILE **g_tmp, char **g_tempfile)
if (bytes_read < 0)
error (EXIT_FAILURE, errno, _("stdin: read error"));
- /* Don't bother checking for failure inside the loop -- check after. */
- fwrite (G_buffer, 1, bytes_read, tmp);
+ if (fwrite (G_buffer, 1, bytes_read, tmp) != bytes_read)
+ break;
}
if (ferror (tmp) || fflush (tmp) == EOF)
error (EXIT_FAILURE, errno, "%s", tempfile);
- rewind (tmp);
-
SET_BINARY (fileno (tmp));
*g_tmp = tmp;
*g_tempfile = tempfile;