diff options
author | Jim Meyering <jim@meyering.net> | 2003-09-17 18:46:57 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-09-17 18:46:57 +0000 |
commit | 651fd58f8fefec46eec1831f7d7ca8f78718b449 (patch) | |
tree | a62f04d17e71e78f07d3f1f7d5b8dda60a09d558 /lib | |
parent | 21158aed3acf8f6e925c2e3902b0c494aa7bf63b (diff) | |
download | coreutils-651fd58f8fefec46eec1831f7d7ca8f78718b449.tar.xz |
(getndelim2): Don't trash errno when a read
fails, so that the caller gets the proper errno.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/getndelim2.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/getndelim2.c b/lib/getndelim2.c index db81e1b29..6f0868999 100644 --- a/lib/getndelim2.c +++ b/lib/getndelim2.c @@ -70,7 +70,7 @@ getndelim2 (char **lineptr, size_t *linesize, size_t nmax, { /* Here always *lineptr + *linesize == read_pos + nbytes_avail. */ - register int c = getc (stream); + register int c; /* We always want at least one char left in the buffer, since we always (unless we get an error while reading the first char) @@ -95,7 +95,8 @@ getndelim2 (char **lineptr, size_t *linesize, size_t nmax, } } - if (c == EOF || ferror (stream)) + c = getc (stream); + if (c == EOF) { /* Return partial line, if any. */ if (read_pos == *lineptr) |