diff options
author | Jim Meyering <jim@meyering.net> | 2003-09-23 12:12:25 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-09-23 12:12:25 +0000 |
commit | 57a5d2a4dbee673e38a01583b6b29ad4030324c5 (patch) | |
tree | ed3b2bc085ae73f120e898936458956ddef1c7b7 | |
parent | 80aa0840d7337070947243902370609cc69cb2ee (diff) | |
download | coreutils-57a5d2a4dbee673e38a01583b6b29ad4030324c5.tar.xz |
(fold_file): Save errno after input error, to report proper errno value.
-rw-r--r-- | src/fold.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/fold.c b/src/fold.c index 293766072..517be282a 100644 --- a/src/fold.c +++ b/src/fold.c @@ -126,6 +126,7 @@ fold_file (char *filename, int width) int offset_out = 0; /* Index in `line_out' for next char. */ static char *line_out = NULL; static int allocated_out = 0; + int saved_errno; if (STREQ (filename, "-")) { @@ -209,12 +210,14 @@ fold_file (char *filename, int width) line_out[offset_out++] = c; } + saved_errno = errno; + if (offset_out) fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); if (ferror (istream)) { - error (0, errno, "%s", filename); + error (0, saved_errno, "%s", filename); if (!STREQ (filename, "-")) fclose (istream); return 1; |