diff options
author | Jim Meyering <jim@meyering.net> | 2003-09-23 17:47:59 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-09-23 17:47:59 +0000 |
commit | a3f05cf720073b01960be0ea389158937d81801d (patch) | |
tree | f843014fca820a61975abd6419db2e35614dc893 /src/paste.c | |
parent | 57a5d2a4dbee673e38a01583b6b29ad4030324c5 (diff) | |
download | coreutils-a3f05cf720073b01960be0ea389158937d81801d.tar.gz coreutils-a3f05cf720073b01960be0ea389158937d81801d.tar.bz2 coreutils-a3f05cf720073b01960be0ea389158937d81801d.zip |
(paste_serial): Save errno after input error,
to report proper errno value.
Based on a patch from Paul Eggert.
Diffstat (limited to 'src/paste.c')
-rw-r--r-- | src/paste.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/paste.c b/src/paste.c index 5ddb16f45..1f6a98101 100644 --- a/src/paste.c +++ b/src/paste.c @@ -328,6 +328,7 @@ paste_serial (int nfiles, char **fnamptr) for (; nfiles; nfiles--, fnamptr++) { + int saved_errno; if (STREQ (*fnamptr, "-")) { have_read_stdin = 1; @@ -347,6 +348,7 @@ paste_serial (int nfiles, char **fnamptr) delimptr = delims; /* Set up for delimiter string. */ charold = getc (fileptr); + saved_errno = errno; if (charold != EOF) { /* `charold' is set up. Hit it! @@ -371,6 +373,7 @@ paste_serial (int nfiles, char **fnamptr) charold = charnew; } + saved_errno = errno; /* Hit EOF. Process that last character. */ putc (charold, stdout); @@ -381,7 +384,7 @@ paste_serial (int nfiles, char **fnamptr) if (ferror (fileptr)) { - error (0, errno, "%s", *fnamptr); + error (0, saved_errno, "%s", *fnamptr); errors = 1; } if (fileptr == stdin) |