diff options
author | László Németh <nemeth@numbertext.org> | 2014-05-22 12:27:44 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2014-05-23 01:06:50 +0200 |
commit | 6d06aa8ba83b7629603cd86cf14a63c432ce268f (patch) | |
tree | b5dee722f6f43f1acb20af35534b37d20df8fee7 /external/mythes/mythes-fdo48017-wfopen.patch | |
parent | 7818974103fcdf16e03354f62a4165eedea4427c (diff) |
fdo#48017 WIN32 long path support in Hyphen and MyThes
Change-Id: Ifb068efb553ed24a7caf65dbab28726bdeced0e6
Diffstat (limited to 'external/mythes/mythes-fdo48017-wfopen.patch')
-rw-r--r-- | external/mythes/mythes-fdo48017-wfopen.patch | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/external/mythes/mythes-fdo48017-wfopen.patch b/external/mythes/mythes-fdo48017-wfopen.patch new file mode 100644 index 000000000000..1621b1d35641 --- /dev/null +++ b/external/mythes/mythes-fdo48017-wfopen.patch @@ -0,0 +1,72 @@ +diff -u mythes/mythes.cxx build/mythes/mythes.cxx +--- mythes/mythes.cxx 2014-05-22 00:27:38.508588487 +0200 ++++ build/mythes/mythes.cxx 2014-05-22 10:07:06.107547417 +0200 +@@ -8,6 +8,11 @@ + + #include "mythes.hxx" + ++#ifdef _WIN32 ++#include <windows.h> ++#include <wchar.h> ++#endif ++ + MyThes::MyThes(const char* idxpath, const char * datpath) + { + nw = 0; +@@ -35,7 +40,7 @@ + { + + // open the index file +- FILE * pifile = fopen(idxpath,"r"); ++ FILE * pifile = myfopen(idxpath,"r"); + if (!pifile) { + return 0; + } +@@ -90,7 +95,7 @@ + fclose(pifile); + + /* next open the data file */ +- pdfile = fopen(datpath,"r"); ++ pdfile = myfopen(datpath,"r"); + if (!pdfile) { + return 0; + } +@@ -370,3 +375,17 @@ + return -1; + } + ++FILE * MyThes::myfopen(const char * path, const char * mode) { ++#ifdef _WIN32 ++#define WIN32_LONG_PATH_PREFIX "\\\\?\\" ++ if (strncmp(path, WIN32_LONG_PATH_PREFIX, 4) == 0) { ++ int len = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0); ++ wchar_t *buff = (wchar_t *) malloc(len * sizeof(wchar_t)); ++ MultiByteToWideChar(CP_UTF8, 0, path, -1, buff, len); ++ FILE * f = _wfopen(buff, (strcmp(mode, "r") == 0) ? L"r" : L"rb"); ++ free(buff); ++ return f; ++ } ++#endif ++ return fopen(path, mode); ++} +diff -u mythes/mythes.hxx build/mythes/mythes.hxx +--- mythes/mythes.hxx 2010-03-04 12:56:23.000000000 +0100 ++++ build/mythes/mythes.hxx 2014-05-22 10:11:14.363543731 +0200 +@@ -30,6 +30,7 @@ + MyThes & operator = (const MyThes &); + + public: ++ // use UTF-8 encoded paths in WIN32 environment + MyThes(const char* idxpath, const char* datpath); + ~MyThes(); + +@@ -66,6 +67,9 @@ + // return index of char in string + int mystr_indexOfChar(const char * d, int c); + ++ // fopen or _wfopen ++ FILE * myfopen(const char * path, const char * mode); ++ + }; + + #endif |