]> git.saurik.com Git - apple/libc.git/blob - stdio/FreeBSD/freopen.c.patch
Libc-391.4.1.tar.gz
[apple/libc.git] / stdio / FreeBSD / freopen.c.patch
1 --- freopen.c.orig 2004-10-28 23:51:35.000000000 -0700
2 +++ freopen.c 2004-10-28 23:53:14.000000000 -0700
3 @@ -136,6 +136,8 @@
4 * descriptor (if any) was associated with it. If it was attached to
5 * a descriptor, defer closing it; freopen("/dev/stdin", "r", stdin)
6 * should work. This is unnecessary if it was not a Unix file.
7 + *
8 + * For UNIX03, we always close if it was open.
9 */
10 if (fp->_flags == 0) {
11 fp->_flags = __SEOF; /* hold on to it */
12 @@ -146,11 +148,18 @@
13 if (fp->_flags & __SWR)
14 (void) __sflush(fp);
15 /* if close is NULL, closing is a no-op, hence pointless */
16 +#if __DARWIN_UNIX03
17 + if (fp->_close)
18 + (void) (*fp->_close)(fp->_cookie);
19 + isopen = 0;
20 + wantfd = -1;
21 +#else /* !__DARWIN_UNIX03 */
22 isopen = fp->_close != NULL;
23 if ((wantfd = fp->_file) < 0 && isopen) {
24 (void) (*fp->_close)(fp->_cookie);
25 isopen = 0;
26 }
27 +#endif /* __DARWIN_UNIX03 */
28 }
29
30 /* Get a new descriptor to refer to the new file. */