diff options
| author | past-due <30942300+past-due@users.noreply.github.com> | 2020-02-03 18:14:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-03 15:14:03 -0800 |
| commit | 85bf9d9d792e379e973d66c8af9f39d65d1d6d42 (patch) | |
| tree | 915f6e29f732dcfe27ea03c379123941681cbc21 | |
| parent | e62d1361288e83eba786395b60361ab35ba83800 (diff) | |
| download | vcpkg-85bf9d9d792e379e973d66c8af9f39d65d1d6d42.tar.gz vcpkg-85bf9d9d792e379e973d66c8af9f39d65d1d6d42.zip | |
[gettext] Fix Unicode path support on Windows (#9855)
| -rw-r--r-- | ports/gettext/0003-Fix-win-unicode-paths.patch | 60 | ||||
| -rw-r--r-- | ports/gettext/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | ports/gettext/CONTROL | 2 | ||||
| -rw-r--r-- | ports/gettext/portfile.cmake | 1 |
4 files changed, 63 insertions, 2 deletions
diff --git a/ports/gettext/0003-Fix-win-unicode-paths.patch b/ports/gettext/0003-Fix-win-unicode-paths.patch new file mode 100644 index 000000000..f86c52c86 --- /dev/null +++ b/ports/gettext/0003-Fix-win-unicode-paths.patch @@ -0,0 +1,60 @@ +diff --git "a/gettext-runtime/intl/loadmsgcat.c" "b/gettext-runtime/intl/loadmsgcat.c" +index 63351523..c078de3f 100644 +--- a/gettext-runtime/intl/loadmsgcat.c ++++ b/gettext-runtime/intl/loadmsgcat.c +@@ -477,6 +477,55 @@ char *alloca (); + # define munmap(addr, len) __munmap (addr, len) + #endif + ++#ifdef _WIN32 ++/* Provide wrapper of "open" for Windows that supports UTF-8 filenames. */ ++# ifndef WIN32_LEAN_AND_MEAN ++# define WIN32_LEAN_AND_MEAN ++# endif ++# ifndef WIN32_EXTRA_LEAN ++# define WIN32_EXTRA_LEAN ++# endif ++# undef NOMINMAX ++# define NOMINMAX ++# include <Windows.h> // For: MultiByteToWideChar ++# include <io.h> ++# include <wchar.h> ++ ++int _open_utf8_windows_wrapper( ++ const char *filename, ++ int flags ++) ++{ ++ int wstr_len = -1; ++ wchar_t* pUtf16FileName = NULL; ++ int fh = -1; ++ ++ // on Windows, convert the filename from UTF-8 to UTF-16 ++ wstr_len = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0); ++ if (wstr_len <= 0) ++ { ++ // MultiByteToWideChar failed ++ errno = ENOENT; ++ return -1; ++ } ++ pUtf16FileName = malloc(wstr_len * sizeof(wchar_t)); ++ if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, pUtf16FileName, wstr_len) == 0) ++ { ++ // MultiByteToWideChar failed ++ free(pUtf16FileName); ++ errno = ENOENT; ++ return -1; ++ } ++ ++ // and call _wopen ++ fh = _wopen(pUtf16FileName, flags); ++ ++ free(pUtf16FileName); ++ return fh; ++} ++# define open(name, flags) _open_utf8_windows_wrapper(name, flags) ++#endif // #ifdef _WIN32 ++ + /* For those losing systems which don't have `alloca' we have to add + some additional code emulating it. */ + #ifdef HAVE_ALLOCA diff --git a/ports/gettext/CMakeLists.txt b/ports/gettext/CMakeLists.txt index 1bc2087b7..57d5a14e5 100644 --- a/ports/gettext/CMakeLists.txt +++ b/ports/gettext/CMakeLists.txt @@ -120,7 +120,7 @@ if(NOT WIN32) target_link_libraries(libintl PRIVATE Threads::Threads)
endif()
if (WIN32)
- target_link_libraries(libintl PRIVATE Advapi32.lib)
+ target_link_libraries(libintl PRIVATE kernel32.lib Advapi32.lib)
endif()
install(TARGETS libintl
diff --git a/ports/gettext/CONTROL b/ports/gettext/CONTROL index bb4b113f1..5cfa7b0d7 100644 --- a/ports/gettext/CONTROL +++ b/ports/gettext/CONTROL @@ -1,5 +1,5 @@ Source: gettext -Version: 0.19-13 +Version: 0.19-14 Homepage: https://www.gnu.org/software/gettext/ Description: The GNU gettext utilities are a set of tools that provides a framework to help other GNU packages produce multi-lingual messages. Provides libintl. Build-Depends: libiconv diff --git a/ports/gettext/portfile.cmake b/ports/gettext/portfile.cmake index 38ada752c..988c2f439 100644 --- a/ports/gettext/portfile.cmake +++ b/ports/gettext/portfile.cmake @@ -25,6 +25,7 @@ vcpkg_extract_source_archive_ex( PATCHES 0001-Fix-macro-definitions.patch 0002-Fix-uwp-build.patch + 0003-Fix-win-unicode-paths.patch ) file(COPY |
