mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
(getndelim2): Don't trash errno when a read
fails, so that the caller gets the proper errno.
This commit is contained in:
1 parent
21158aed3a
commit
651fd58f8f
1 file changed
+3
-2
+3
-2
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user