mirror of
https://github.com/reactos/reactos.git
synced 2025-07-26 22:53:52 +00:00
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
This commit is contained in:
parent
9bd1f760d5
commit
d1a42af5b7
1 changed files with 6 additions and 10 deletions
|
@ -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)
|
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)
|
if (file->_flag & _IOBINARY)
|
||||||
{
|
{
|
||||||
|
wchar_t mwc = wc;
|
||||||
|
|
||||||
if (fwrite( &mwc, sizeof(mwc), 1, file) != 1)
|
if (fwrite( &mwc, sizeof(mwc), 1, file) != 1)
|
||||||
return WEOF;
|
return WEOF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Convert to multibyte in text mode */
|
/* Convert the character to ANSI */
|
||||||
mb_return = wctomb(mbchar, mwc);
|
char c = (unsigned char)wc;
|
||||||
if (mb_return == -1) return WEOF;
|
|
||||||
|
|
||||||
/* Output all characters */
|
if (fwrite( &c, sizeof(c), 1, file) != 1)
|
||||||
if (fwrite( mbchar, 1, mb_return, file) != 1)
|
return WEOF;
|
||||||
return WEOF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return wc;
|
return wc;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue