From d1a42af5b78f32734d0ac36aac7942fbb9c7cf66 Mon Sep 17 00:00:00 2001 From: Colin Finck Date: Wed, 2 Jul 2008 16:07:01 +0000 Subject: [PATCH] Simplify the code for fputwc, when the file is opened in text mode. I verified this behaviour with a test app under Windows XP SP2. This is also the code used by the fputwc function of our previous msvcrt. svn path=/trunk/; revision=34266 --- reactos/lib/sdk/crt/stdio/file.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/reactos/lib/sdk/crt/stdio/file.c b/reactos/lib/sdk/crt/stdio/file.c index 2429a5c73c7..6b99e9379fe 100644 --- a/reactos/lib/sdk/crt/stdio/file.c +++ b/reactos/lib/sdk/crt/stdio/file.c @@ -2475,24 +2475,20 @@ size_t CDECL fwrite(const void *ptr, size_t size, size_t nmemb, FILE* file) */ wint_t CDECL fputwc(wint_t wc, FILE* file) { - wchar_t mwc=wc; - char mbchar[10]; // MB_CUR_MAX_CONST - int mb_return; - if (file->_flag & _IOBINARY) { + wchar_t mwc = wc; + if (fwrite( &mwc, sizeof(mwc), 1, file) != 1) return WEOF; } else { - /* Convert to multibyte in text mode */ - mb_return = wctomb(mbchar, mwc); - if (mb_return == -1) return WEOF; + /* Convert the character to ANSI */ + char c = (unsigned char)wc; - /* Output all characters */ - if (fwrite( mbchar, 1, mb_return, file) != 1) - return WEOF; + if (fwrite( &c, sizeof(c), 1, file) != 1) + return WEOF; } return wc; -- 2.17.1