diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2006-01-10 17:09:43 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2006-01-10 17:09:43 +0000 |
commit | dea958bc0612f79a603e4a8a915c8beeafc464e1 (patch) | |
tree | fb7764130a9e1da8e25d0fe035e7999164f02102 | |
parent | 216633f73cd9c8163b2b2fe5f6c00e8d819ade1f (diff) | |
download | cygnal-dea958bc0612f79a603e4a8a915c8beeafc464e1.tar.gz cygnal-dea958bc0612f79a603e4a8a915c8beeafc464e1.tar.bz2 cygnal-dea958bc0612f79a603e4a8a915c8beeafc464e1.zip |
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.
-rw-r--r-- | newlib/ChangeLog | 5 | ||||
-rw-r--r-- | newlib/libc/stdio/freopen.c | 7 | ||||
-rw-r--r-- | newlib/libc/stdio64/freopen64.c | 7 |
3 files changed, 13 insertions, 6 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 8e18f7f2f..6b14e7e0f 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +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. + 2006-01-10 Jeff Johnston <jjohnstn@redhat.com> * libm/mathfp/s_frexp.c: Check for special values on diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c index ec195c819..d5582d421 100644 --- a/newlib/libc/stdio/freopen.c +++ b/newlib/libc/stdio/freopen.c @@ -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. */ diff --git a/newlib/libc/stdio64/freopen64.c b/newlib/libc/stdio64/freopen64.c index 1f691f645..8acb957da 100644 --- a/newlib/libc/stdio64/freopen64.c +++ b/newlib/libc/stdio64/freopen64.c @@ -146,14 +146,15 @@ _DEFUN (_freopen64_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. */ |