[ros-diffs] [cfinck] 34266: 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.

cfinck at svn.reactos.org cfinck at svn.reactos.org
Wed Jul 2 18:07:02 CEST 2008


Author: cfinck
Date: Wed Jul  2 11:07:01 2008
New Revision: 34266

URL: http://svn.reactos.org/svn/reactos?rev=34266&view=rev
Log:
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.

Modified:
    trunk/reactos/lib/sdk/crt/stdio/file.c

Modified: trunk/reactos/lib/sdk/crt/stdio/file.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdio/file.c?rev=34266&r1=34265&r2=34266&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdio/file.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/stdio/file.c [iso-8859-1] Wed Jul  2 11:07:01 2008
@@ -2475,24 +2475,20 @@
  */
 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;
-
-    /* Output all characters */
-    if (fwrite( mbchar, 1, mb_return, file) != 1)
-        return WEOF;
+    /* Convert the character to ANSI */
+    char c = (unsigned char)wc;
+
+    if (fwrite( &c, sizeof(c), 1, file) != 1)
+      return WEOF;
   }
 
   return wc;



More information about the Ros-diffs mailing list