(getndelim2): Don't trash errno when a read

fails, so that the caller gets the proper errno.
This commit is contained in:
Jim Meyering committed 2003-09-17 18:46:57 +00:00
1 parent 21158aed3a
commit 651fd58f8f
1 file changed
+3 -2
+3 -2
View File
@@ -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)