-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Jeff Johnston on 1/9/2006 10:54 AM:
Patch checked in with minor modifications. A check was required for
HAVE_FCNTL before using _fcntl_r. I also initialized e which was
generating a warning message because of the new if clause.
Phooey - I botched the patch. Please check in this correction:
2006-01-10 Eric Blake <ebb9@byu.net>
* libc/stdio/freopen.c (_freopen_r): Fix use of oflags.
* libc/stdio64/freopen64.c (_freopen64_r): Likewise.
- --
Life is short - so eat dessert first!
Eric Blake ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDw7nr84KuGfSFAYARAlCEAKDGWwM/FLYteXvYz9lLix4Jw+2bKgCeNK48
UyL/CYPb1mrOHL+k/OXSUxc=
=MSzn
-----END PGP SIGNATURE-----
------------------------------------------------------------------------
Index: libc/stdio/freopen.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/freopen.c,v
retrieving revision 1.14
diff -u -p -b -r1.14 freopen.c
--- libc/stdio/freopen.c 9 Jan 2006 20:01:09 -0000 1.14
+++ libc/stdio/freopen.c 10 Jan 2006 13:42:01 -0000
@@ -146,14 +146,15 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp)
else
{
#ifdef HAVE_FCNTL
+ int oldflags;
/*
* Reuse the file descriptor, but only if the access mode is
* unchanged. F_SETFL correctly ignores creation flags.
*/
f = fp->_file;
- if ((oflags = _fcntl_r (ptr, f, F_GETFL, 0)) == -1
- || ((oflags ^ flags) & O_ACCMODE) != 0
- || _fcntl_r (ptr, f, F_SETFL, flags) == -1)
+ if ((oldflags = _fcntl_r (ptr, f, F_GETFL, 0)) == -1
+ || ((oldflags ^ oflags) & O_ACCMODE) != 0
+ || _fcntl_r (ptr, f, F_SETFL, oflags) == -1)
f = -1;
#else
/* We cannot modify without fcntl support. */
Index: libc/stdio64/freopen64.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio64/freopen64.c,v
retrieving revision 1.9
diff -u -p -b -r1.9 freopen64.c
--- libc/stdio64/freopen64.c 9 Jan 2006 20:01:09 -0000 1.9
+++ libc/stdio64/freopen64.c 10 Jan 2006 13:42:01 -0000
@@ -146,14 +146,15 @@ _DEFUN (_freopen64_r, (ptr, file, mode,
else
{
#ifdef HAVE_FCNTL
+ int oldflags;
/*
* Reuse the file descriptor, but only if the access mode is
* unchanged. F_SETFL correctly ignores creation flags.
*/
f = fp->_file;
- if ((oflags = _fcntl_r (ptr, f, F_GETFL, 0)) == -1
- || ((oflags ^ flags) & O_ACCMODE) != 0
- || _fcntl_r (ptr, f, F_SETFL, flags) == -1)
+ if ((oldflags = _fcntl_r (ptr, f, F_GETFL, 0)) == -1
+ || ((oldflags ^ oflags) & O_ACCMODE) != 0
+ || _fcntl_r (ptr, f, F_SETFL, oflags) == -1)
f = -1;
#else
/* We cannot modify without fcntl support. */