[vlc-commits] Win32: fallback to normal output if WriteConsoleW() fails

Rémi Denis-Courmont git at videolan.org
Mon May 14 17:35:53 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon May 14 18:35:16 2012 +0300| [3f3cc09865475e9d5adce2795676e7147a0a43ab] | committer: Rémi Denis-Courmont

Win32: fallback to normal output if WriteConsoleW() fails

This fixes console logs on Wine for me.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3f3cc09865475e9d5adce2795676e7147a0a43ab
---

 src/text/unicode.c |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/src/text/unicode.c b/src/text/unicode.c
index c6b0669..23e41c5 100644
--- a/src/text/unicode.c
+++ b/src/text/unicode.c
@@ -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



More information about the vlc-commits mailing list