]> git.sesse.net Git - vlc/commitdiff
Win32: fallback to normal output if WriteConsoleW() fails
authorRémi Denis-Courmont <remi@remlab.net>
Mon, 14 May 2012 15:35:16 +0000 (18:35 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 14 May 2012 15:35:16 +0000 (18:35 +0300)
This fixes console logs on Wine for me.

src/text/unicode.c

index c6b066993f86bd33fb30ed4dc1685e1b77ca9c86..23e41c51d37d20dc85ab1fb6d2faefd672ebb24e 100644 (file)
@@ -74,27 +74,24 @@ int utf8_vfprintf( FILE *stream, const char *fmt, va_list ap )
         {
             HANDLE h = (HANDLE)((uintptr_t)_get_osfhandle (fd));
             DWORD out;
-
             /* XXX: It is not clear whether WriteConsole() wants the number of
              * Unicode characters or the size of the wchar_t array. */
-            WriteConsoleW (h, wide, wcslen (wide), &out, NULL);
+            BOOL ok = WriteConsoleW (h, wide, wcslen (wide), &out, NULL);
             free (wide);
+            if (ok)
+                goto out;
         }
-        else
-            res = -1;
     }
-    else
 # endif
+    char *ansi = ToANSI (str);
+    if (ansi != NULL)
     {
-        char *ansi = ToANSI (str);
-        if (ansi != NULL)
-        {
-            fputs (ansi, stream);
-            free (ansi);
-        }
-        else
-            res = -1;
+        fputs (ansi, stream);
+        free (ansi);
     }
+    else
+        res = -1;
+out:
     free (str);
     return res;
 #endif