musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/stdio/freopen.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2022年08月17日 18:34:07 -0400
committerRich Felker <dalias@aerifal.cx>2022年08月17日 18:34:07 -0400
commit37e18b7bf307fa4a8c745feebfcba54a0ba74f30 (patch)
tree79a850217e80e1e6570cdf685b41b2d8c3c20252 /src/stdio/freopen.c
parentbf99258564fd5b58974d93201ab61506eb8cb03e (diff)
downloadmusl-37e18b7bf307fa4a8c745feebfcba54a0ba74f30.tar.gz
freopen: reset stream orientation (byte/wide) and encoding rule
this is a requirement of the C language (orientation) and POSIX (encoding rule) that was somehow overlooked. we rely on the fact that the buffer pointers have been reset by fflush, so that any future stdio operations on the stream will go through the same code paths they would on a newly-opened file without an orientation set, thereby setting the orientation as they should.
Diffstat (limited to 'src/stdio/freopen.c')
-rw-r--r--src/stdio/freopen.c 2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c
index 615d4b47..96bfbb42 100644
--- a/src/stdio/freopen.c
+++ b/src/stdio/freopen.c
@@ -40,6 +40,8 @@ FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *re
fclose(f2);
}
+ f->mode = 0;
+ f->locale = 0;
FUNLOCK(f);
return f;
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月14日 20:00:13 +0000

AltStyle によって変換されたページ (->オリジナル) /