diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2015-12-08 18:44:23 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2015-12-08 18:44:23 +0100 |
commit | 414e7948118bb3b7071e7c8cbddcf371e0d48e38 (patch) | |
tree | b66300de097cb4c8e82f961f53dcf384dfa45e45 | |
parent | 6c3a5d263f3cdfb6703434439bdc84c3a1e29159 (diff) | |
download | newlib-414e7948118bb3b7071e7c8cbddcf371e0d48e38.zip newlib-414e7948118bb3b7071e7c8cbddcf371e0d48e38.tar.gz newlib-414e7948118bb3b7071e7c8cbddcf371e0d48e38.tar.bz2 |
Fix re-initialization of FILE flags and mbstate in freopen
* libc/stdio/freopen.c (_freopen_r): Only reset __SWID bit per SUSv4.
* libc/stdio64/freopen64.c (_freopen64_r): Add missing resetting of
flag values and _mbstate.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | newlib/ChangeLog | 6 | ||||
-rw-r--r-- | newlib/libc/stdio/freopen.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdio64/freopen64.c | 3 |
3 files changed, 10 insertions, 1 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 1aff1c6..c49f109 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,9 @@ +2015-12-08 Corinna Vinschen <corinna@vinschen.de> + + * libc/stdio/freopen.c (_freopen_r): Only reset __SWID bit per SUSv4. + * libc/stdio64/freopen64.c (_freopen64_r): Add missing resetting of + flag values and _mbstate. + 2015-12-07 Nick Withers <nick.withers@anu.edu.au> * libc/sys/arm/sys/param.h (NBBY): Define if not already defined. diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c index a696a9d..235ffba 100644 --- a/newlib/libc/stdio/freopen.c +++ b/newlib/libc/stdio/freopen.c @@ -209,7 +209,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), FREELB (ptr, fp); fp->_lb._size = 0; fp->_flags &= ~__SORD; - fp->_flags2 = 0; + fp->_flags2 &= ~__SWID; memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); if (f < 0) diff --git a/newlib/libc/stdio64/freopen64.c b/newlib/libc/stdio64/freopen64.c index dfe36ea..a183fb8 100644 --- a/newlib/libc/stdio64/freopen64.c +++ b/newlib/libc/stdio64/freopen64.c @@ -208,6 +208,9 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp), if (HASLB (fp)) FREELB (ptr, fp); fp->_lb._size = 0; + fp->_flags &= ~__SORD; + fp->_flags2 &= ~__SWID; + memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); if (f < 0) { /* did not get it after all */ |