uwp-library-console.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. diff --git a/src/share/win_utf8_io/win_utf8_io.c b/src/share/win_utf8_io/win_utf8_io.c
  2. index 65b5699..af6d0f4 100644
  3. --- a/src/share/win_utf8_io/win_utf8_io.c
  4. +++ b/src/share/win_utf8_io/win_utf8_io.c
  5. @@ -115,7 +115,11 @@ int get_utf8_argv(int *argc, char ***argv)
  6. char **utf8argv;
  7. int ret, i;
  8. +#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
  9. + if ((handle = LoadPackagedLibrary("msvcrt.dll", 0)) == NULL) return 1;
  10. +#else
  11. if ((handle = LoadLibraryW(L"msvcrt.dll")) == NULL) return 1;
  12. +#endif
  13. if ((wgetmainargs = (wgetmainargs_t)GetProcAddress(handle, "__wgetmainargs")) == NULL) {
  14. FreeLibrary(handle);
  15. return 1;
  16. @@ -192,6 +196,9 @@ size_t strlen_utf8(const char *str)
  17. /* get the console width in characters */
  18. int win_get_console_width(void)
  19. {
  20. +#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
  21. + return 80;
  22. +#else
  23. int width = 80;
  24. #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  25. CONSOLE_SCREEN_BUFFER_INFO csbi;
  26. @@ -201,6 +208,7 @@ int win_get_console_width(void)
  27. width = csbi.dwSize.X;
  28. #endif // WINAPI_PARTITION_DESKTOP
  29. return width;
  30. +#endif
  31. }
  32. /* print functions */
  33. @@ -211,6 +219,11 @@ static int wprint_console(FILE *stream, const wchar_t *text, size_t len)
  34. DWORD out;
  35. int ret;
  36. +#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
  37. + // disabled for UWP as there's no alternative:
  38. + // https://docs.microsoft.com/en-us/uwp/win32-and-com/alternatives-to-windows-apis-uwp
  39. +#else
  40. +
  41. do {
  42. if (stream == stdout) {
  43. HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
  44. @@ -229,6 +242,7 @@ static int wprint_console(FILE *stream, const wchar_t *text, size_t len)
  45. return out;
  46. }
  47. } while(0);
  48. +#endif
  49. ret = fputws(text, stream);
  50. if (ret < 0)