summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-09-17 18:46:57 +0000
committerJim Meyering <jim@meyering.net>2003-09-17 18:46:57 +0000
commit651fd58f8fefec46eec1831f7d7ca8f78718b449 (patch)
treea62f04d17e71e78f07d3f1f7d5b8dda60a09d558 /lib
parent21158aed3acf8f6e925c2e3902b0c494aa7bf63b (diff)
downloadcoreutils-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.c5
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)