summaryrefslogtreecommitdiffstats
path: root/freebsd/lib/libc/stdio/fgetln.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-08-07 14:56:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-09-21 10:29:37 +0200
commitc37f9fba70085fedc8eede7559489d2321393005 (patch)
tree042455ebf1fa89a277a825f72e1ed805d0b4d296 /freebsd/lib/libc/stdio/fgetln.c
parentUpdate to FreeBSD head 2017-06-01 (diff)
downloadrtems-libbsd-c37f9fba70085fedc8eede7559489d2321393005.tar.bz2
Update to FreeBSD head 2017-08-01
Git mirror commit f5002f5e5f78cae9f0269d812dc0aedb0339312c. Update #3472.
Diffstat (limited to 'freebsd/lib/libc/stdio/fgetln.c')
-rw-r--r--freebsd/lib/libc/stdio/fgetln.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/freebsd/lib/libc/stdio/fgetln.c b/freebsd/lib/libc/stdio/fgetln.c
index 8d1235c5..7f5e18b3 100644
--- a/freebsd/lib/libc/stdio/fgetln.c
+++ b/freebsd/lib/libc/stdio/fgetln.c
@@ -87,22 +87,25 @@ char *
fgetln(FILE *fp, size_t *lenp)
{
unsigned char *p;
+ char *ret;
size_t len;
size_t off;
+#ifndef __rtems__
+ FLOCKFILE_CANCELSAFE(fp);
+#else /* __rtems__ */
FLOCKFILE(fp);
+#endif /* __rtems__ */
ORIENT(fp, -1);
/* make sure there is input */
if (fp->_r <= 0 && __srefill(fp)) {
*lenp = 0;
- FUNLOCKFILE(fp);
- return (NULL);
+ ret = NULL;
+ goto end;
}
/* look for a newline in the input */
if ((p = memchr((void *)fp->_p, '\n', (size_t)fp->_r)) != NULL) {
- char *ret;
-
/*
* Found one. Flag buffer as modified to keep fseek from
* `optimising' a backward seek, in case the user stomps on
@@ -116,8 +119,7 @@ fgetln(FILE *fp, size_t *lenp)
#endif /* __rtems__ */
fp->_r -= len;
fp->_p = p;
- FUNLOCKFILE(fp);
- return (ret);
+ goto end;
}
/*
@@ -167,12 +169,18 @@ fgetln(FILE *fp, size_t *lenp)
#ifdef notdef
fp->_lb._base[len] = '\0';
#endif
+ ret = (char *)fp->_lb._base;
+end:
+#ifndef __rtems__
+ FUNLOCKFILE_CANCELSAFE();
+#else /* __rtems__ */
FUNLOCKFILE(fp);
- return ((char *)fp->_lb._base);
+#endif /* __rtems__ */
+ return (ret);
error:
*lenp = 0; /* ??? */
fp->_flags |= __SERR;
- FUNLOCKFILE(fp);
- return (NULL); /* ??? */
+ ret = NULL;
+ goto end;
}