summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/vswprintf.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2004-04-07 09:55:05 +0000
committertjr <tjr@FreeBSD.org>2004-04-07 09:55:05 +0000
commit1c584f59a55cb440f0487854db33b28a08898f82 (patch)
tree12c84b3433d9dfe7221d8772b9282c58a3f99811 /lib/libc/stdio/vswprintf.c
parent226e976dd71faa4ff636611c2de2ce44dcce5ba9 (diff)
downloadFreeBSD-src-1c584f59a55cb440f0487854db33b28a08898f82.zip
FreeBSD-src-1c584f59a55cb440f0487854db33b28a08898f82.tar.gz
Prepare to handle trivial state-dependent encodings. Full support for
state-dependent encodings with locking shifts will come later if there is demand for it.
Diffstat (limited to 'lib/libc/stdio/vswprintf.c')
-rw-r--r--lib/libc/stdio/vswprintf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/stdio/vswprintf.c b/lib/libc/stdio/vswprintf.c
index a9fdaf3..77e289d 100644
--- a/lib/libc/stdio/vswprintf.c
+++ b/lib/libc/stdio/vswprintf.c
@@ -43,6 +43,8 @@ int
vswprintf(wchar_t * __restrict s, size_t n, const wchar_t * __restrict fmt,
__va_list ap)
{
+ static const mbstate_t initial;
+ mbstate_t mbs;
FILE f;
struct __sFILEX ext;
char *mbp;
@@ -76,7 +78,8 @@ vswprintf(wchar_t * __restrict s, size_t n, const wchar_t * __restrict fmt,
* XXX Undo the conversion from wide characters to multibyte that
* fputwc() did in __vfwprintf().
*/
- if (mbsrtowcs(s, (const char **)&mbp, n, NULL) == (size_t)-1) {
+ mbs = initial;
+ if (mbsrtowcs(s, (const char **)&mbp, n, &mbs) == (size_t)-1) {
free(f._bf._base);
errno = EILSEQ;
return (-1);
OpenPOWER on IntegriCloud