Commit 3f3cc098 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Win32: fallback to normal output if WriteConsoleW() fails

This fixes console logs on Wine for me.
parent 8fe05711
...@@ -74,18 +74,15 @@ int utf8_vfprintf( FILE *stream, const char *fmt, va_list ap ) ...@@ -74,18 +74,15 @@ int utf8_vfprintf( FILE *stream, const char *fmt, va_list ap )
{ {
HANDLE h = (HANDLE)((uintptr_t)_get_osfhandle (fd)); HANDLE h = (HANDLE)((uintptr_t)_get_osfhandle (fd));
DWORD out; DWORD out;
/* XXX: It is not clear whether WriteConsole() wants the number of /* XXX: It is not clear whether WriteConsole() wants the number of
* Unicode characters or the size of the wchar_t array. */ * 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); free (wide);
if (ok)
goto out;
} }
else
res = -1;
} }
else
# endif # endif
{
char *ansi = ToANSI (str); char *ansi = ToANSI (str);
if (ansi != NULL) if (ansi != NULL)
{ {
...@@ -94,7 +91,7 @@ int utf8_vfprintf( FILE *stream, const char *fmt, va_list ap ) ...@@ -94,7 +91,7 @@ int utf8_vfprintf( FILE *stream, const char *fmt, va_list ap )
} }
else else
res = -1; res = -1;
} out:
free (str); free (str);
return res; return res;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment