diff options
author | Rich Felker <dalias@aerifal.cx> | 2018-08-28 19:22:13 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2018-08-28 20:01:25 -0400 |
commit | b152d575fdde1b4173afb4cade55f35b6b2e9128 (patch) | |
tree | cc94ef2a9e107e2bc4a741eb901462d2d5973b20 /src | |
parent | f66022dda8d18e6732626c7806f6c4d32023d574 (diff) | |
download | musl-b152d575fdde1b4173afb4cade55f35b6b2e9128.tar.gz musl-b152d575fdde1b4173afb4cade55f35b6b2e9128.tar.bz2 musl-b152d575fdde1b4173afb4cade55f35b6b2e9128.tar.xz musl-b152d575fdde1b4173afb4cade55f35b6b2e9128.zip |
set stream orientations in open_[w]memstream
fundamentally there is no good reason these functions need to set an
orientation (morally it should be possible to write a wchar_t[] memory
stream using byte functions, or a char[] memory stream using wide
functions), but it's a part of the specification that they do. aside
from being able to inspect the orientation with fwide, failure to set
the orientation in open_wmemstream is observable if the locale changes
between open_wmemstream and the first operation on the stream; this is
because the encoding rule (locale) for the stream is required to be
bound at the time the stream becomes wide-oriented.
for open_wmemstream, call fwide to avoid duplicating the logic for
binding the encoding rule. for open_memstream it suffices just to set
the mode field in the FILE struct.
Diffstat (limited to 'src')
-rw-r--r-- | src/stdio/open_memstream.c | 1 | ||||
-rw-r--r-- | src/stdio/open_wmemstream.c | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/src/stdio/open_memstream.c b/src/stdio/open_memstream.c index ee834234..40f5ad60 100644 --- a/src/stdio/open_memstream.c +++ b/src/stdio/open_memstream.c @@ -89,6 +89,7 @@ FILE *open_memstream(char **bufp, size_t *sizep) f->f.write = ms_write; f->f.seek = ms_seek; f->f.close = ms_close; + f->f.mode = -1; if (!libc.threaded) f->f.lock = -1; diff --git a/src/stdio/open_wmemstream.c b/src/stdio/open_wmemstream.c index cb693ea7..a7c3a645 100644 --- a/src/stdio/open_wmemstream.c +++ b/src/stdio/open_wmemstream.c @@ -94,5 +94,7 @@ FILE *open_wmemstream(wchar_t **bufp, size_t *sizep) if (!libc.threaded) f->f.lock = -1; + fwide(&f->f, 1); + return __ofl_add(&f->f); } |