2 ===================================================================
3 RCS file: /cvs/root/Libc/stdio/FreeBSD/freopen.c,v
4 retrieving revision 1.3
5 diff -u -d -b -w -p -r1.3 freopen.c
6 --- freopen.c 2004/11/25 19:38:34 1.3
7 +++ freopen.c 2005/01/25 18:01:26
8 @@ -99,7 +99,7 @@ freopen(file, mode, fp)
9 (oflags & O_ACCMODE)) {
16 if ((oflags ^ dflags) & O_APPEND) {
17 @@ -136,6 +136,8 @@ freopen(file, mode, fp)
18 * descriptor (if any) was associated with it. If it was attached to
19 * a descriptor, defer closing it; freopen("/dev/stdin", "r", stdin)
20 * should work. This is unnecessary if it was not a Unix file.
22 + * For UNIX03, we always close if it was open.
24 if (fp->_flags == 0) {
25 fp->_flags = __SEOF; /* hold on to it */
26 @@ -146,11 +148,18 @@ freopen(file, mode, fp)
27 if (fp->_flags & __SWR)
29 /* if close is NULL, closing is a no-op, hence pointless */
32 + (void) (*fp->_close)(fp->_cookie);
35 +#else /* !__DARWIN_UNIX03 */
36 isopen = fp->_close != NULL;
37 if ((wantfd = fp->_file) < 0 && isopen) {
38 (void) (*fp->_close)(fp->_cookie);
41 +#endif /* __DARWIN_UNIX03 */
44 /* Get a new descriptor to refer to the new file. */