From: Jim Meyering Date: Wed, 17 Sep 2003 18:46:57 +0000 (+0000) Subject: (getndelim2): Don't trash errno when a read X-Git-Tag: COREUTILS-5_1_0~600 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=651fd58f8fefec46eec1831f7d7ca8f78718b449;p=platform%2Fupstream%2Fcoreutils.git (getndelim2): Don't trash errno when a read fails, so that the caller gets the proper errno. --- diff --git a/lib/getndelim2.c b/lib/getndelim2.c index db81e1b..6f08689 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)