Sloppy stdio stream lock tracking.
This commit is contained in:
parent
074790dfb9
commit
caa80a1e72
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: fgets.c,v 1.8 1998/02/03 18:41:09 perry Exp $ */
|
/* $NetBSD: fgets.c,v 1.9 1998/09/07 14:31:57 kleink Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1990, 1993
|
* Copyright (c) 1990, 1993
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)fgets.c 8.2 (Berkeley) 12/22/93";
|
static char sccsid[] = "@(#)fgets.c 8.2 (Berkeley) 12/22/93";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: fgets.c,v 1.8 1998/02/03 18:41:09 perry Exp $");
|
__RCSID("$NetBSD: fgets.c,v 1.9 1998/09/07 14:31:57 kleink Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
@ -78,8 +78,10 @@ fgets(buf, n, fp)
|
||||||
if ((len = fp->_r) <= 0) {
|
if ((len = fp->_r) <= 0) {
|
||||||
if (__srefill(fp)) {
|
if (__srefill(fp)) {
|
||||||
/* EOF/error: stop with partial or no line */
|
/* EOF/error: stop with partial or no line */
|
||||||
if (s == buf)
|
if (s == buf) {
|
||||||
|
FUNLOCKFILE(fp);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
len = fp->_r;
|
len = fp->_r;
|
||||||
|
@ -101,6 +103,7 @@ fgets(buf, n, fp)
|
||||||
fp->_p = t;
|
fp->_p = t;
|
||||||
(void)memcpy((void *)s, (void *)p, len);
|
(void)memcpy((void *)s, (void *)p, len);
|
||||||
s[len] = 0;
|
s[len] = 0;
|
||||||
|
FUNLOCKFILE(fp)
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
fp->_r -= len;
|
fp->_r -= len;
|
||||||
|
|
Loading…
Reference in New Issue