mirror of
https://github.com/opnsense/src.git
synced 2026-06-08 16:22:46 -04:00
Original fgetln() from 44lite return sucess for line tail errors,
i.e. partial line, but set __SERR and errno in the same time, which is inconsistent. Now both OpenBSD and NetBSD return failure, i.e. no line and set error indicators for such case, so make our fgetln() and fgetwln() (as its wide version) compatible with the rest of *BSD. PR: 212033 MFC after: 7 days
This commit is contained in:
parent
d14b24ef84
commit
3e48993c7c
2 changed files with 6 additions and 4 deletions
|
|
@ -139,8 +139,11 @@ fgetln(FILE *fp, size_t *lenp)
|
|||
(void)memcpy((void *)(fp->_lb._base + off), (void *)fp->_p,
|
||||
len - off);
|
||||
off = len;
|
||||
if (__srefill(fp))
|
||||
break; /* EOF or error: return partial line */
|
||||
if (__srefill(fp)) {
|
||||
if (__sfeof(fp))
|
||||
break;
|
||||
goto error;
|
||||
}
|
||||
if ((p = memchr((void *)fp->_p, '\n', (size_t)fp->_r)) == NULL)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ fgetwln_l(FILE * __restrict fp, size_t *lenp, locale_t locale)
|
|||
ORIENT(fp, 1);
|
||||
|
||||
len = 0;
|
||||
/* WEOF or error: return partial line, see fgetln(3). */
|
||||
while ((wc = __fgetwc(fp, locale)) != WEOF) {
|
||||
#define GROW 512
|
||||
if (len * sizeof(wchar_t) >= fp->_lb._size &&
|
||||
|
|
@ -65,7 +64,7 @@ fgetwln_l(FILE * __restrict fp, size_t *lenp, locale_t locale)
|
|||
if (wc == L'\n')
|
||||
break;
|
||||
}
|
||||
if (len == 0)
|
||||
if (len == 0 || (wc == WEOF && !__sfeof(fp)))
|
||||
goto error;
|
||||
|
||||
FUNLOCKFILE(fp);
|
||||
|
|
|
|||
Loading…
Reference in a new issue