From 651fd58f8fefec46eec1831f7d7ca8f78718b449 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 17 Sep 2003 18:46:57 +0000 Subject: (getndelim2): Don't trash errno when a read fails, so that the caller gets the proper errno. --- lib/getndelim2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') 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) -- cgit v1.2.3-70-g09d2