Skip to content

Commit

Permalink
Contribs: improve flac support on WinRT
Browse files Browse the repository at this point in the history
  • Loading branch information
jbkempf committed May 16, 2016
1 parent 1ed47b2 commit 6b6f0b7
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions contrib/src/flac/console_write.patch
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
--- flac/src/share/win_utf8_io/win_utf8_io.c.orig 2016-05-13 11:27:58.508525189 +0200
+++ flac/src/share/win_utf8_io/win_utf8_io.c 2016-05-13 12:16:51.951811662 +0200
@@ -162,33 +162,14 @@
/* get the console width in characters */
--- flac.orig/src/share/win_utf8_io/win_utf8_io.c 2016-05-16 14:52:36.408520025 +0200
+++ flac/src/share/win_utf8_io/win_utf8_io.c 2016-05-16 14:57:07.880507930 +0200
@@ -42,6 +42,7 @@
#include <stdarg.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h> /* for WideCharToMultiByte and MultiByteToWideChar */
+#include <winapifamily.h>

#include "share/win_utf8_io.h"

@@ -163,16 +164,22 @@
int win_get_console_width(void)
{
- int width = 80;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
- if (GetConsoleScreenBufferInfo(hOut, &csbi) != 0) width = csbi.dwSize.X;
- return width;
+ return 80;
int width = 80;
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
CONSOLE_SCREEN_BUFFER_INFO csbi;
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (GetConsoleScreenBufferInfo(hOut, &csbi) != 0) width = csbi.dwSize.X;
+#endif
return width;
}

/* print functions */
-
int print_console(FILE *stream, const wchar_t *text, size_t len)
{
- static HANDLE hOut;
- static HANDLE hErr;
- DWORD out;
- hOut = GetStdHandle(STD_OUTPUT_HANDLE);
- hErr = GetStdHandle(STD_ERROR_HANDLE);
- if (stream == stdout && hOut != INVALID_HANDLE_VALUE && GetFileType(hOut) == FILE_TYPE_CHAR) {
- if (WriteConsoleW(hOut, text, len, &out, NULL) == 0) return -1;
- return out;
- } else if (stream == stderr && hErr != INVALID_HANDLE_VALUE && GetFileType(hErr) == FILE_TYPE_CHAR) {
- if (WriteConsoleW(hErr, text, len, &out, NULL) == 0) return -1;
- return out;
- } else {
- int ret = fputws(text, stream);
- if (ret < 0) return ret;
- return len;
- }
+ (void)stream, (void)text;
+ return len;
+#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+ (void)stream;
+ OutputDebugStringW(text);
+ return len;
+#else
static HANDLE hOut;
static HANDLE hErr;
DWORD out;
@@ -189,6 +196,7 @@
if (ret < 0) return ret;
return len;
}
+#endif
}

int printf_utf8(const char *format, ...)

0 comments on commit 6b6f0b7

Please sign in to comment.