Bump version to 24.04.3.4
[LibreOffice.git] / external / mythes / mythes-fdo48017-wfopen.patch
blob82d69ad6626e3f02fd6907315a66be274035d230
1 diff -u mythes/mythes.cxx build/mythes/mythes.cxx
2 --- mythes/mythes.cxx 2014-05-22 00:27:38.508588487 +0200
3 +++ build/mythes/mythes.cxx 2014-05-22 10:07:06.107547417 +0200
4 @@ -8,6 +8,11 @@
6 #include "mythes.hxx"
8 +#ifdef _WIN32
9 +#include <windows.h>
10 +#include <wchar.h>
11 +#endif
13 MyThes::MyThes(const char* idxpath, const char * datpath)
15 nw = 0;
16 @@ -35,7 +40,7 @@
19 // open the index file
20 - FILE * pifile = fopen(idxpath,"r");
21 + FILE * pifile = myfopen(idxpath,"r");
22 if (!pifile) {
23 return 0;
25 @@ -90,7 +95,7 @@
26 fclose(pifile);
28 /* next open the data file */
29 - pdfile = fopen(datpath,"r");
30 + pdfile = myfopen(datpath,"r");
31 if (!pdfile) {
32 return 0;
34 @@ -373,3 +378,22 @@
35 return -1;
38 +FILE * MyThes::myfopen(const char * path, const char * mode) {
39 +#ifdef _WIN32
40 +#define WIN32_LONG_PATH_PREFIX "\\\\?\\"
41 + if (strncmp(path, WIN32_LONG_PATH_PREFIX, 4) == 0) {
42 + int len = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0);
43 + wchar_t *buff = (wchar_t *) malloc(len * sizeof(wchar_t));
44 + wchar_t *buff2 = (wchar_t *) malloc(len * sizeof(wchar_t));
45 + FILE * f = NULL;
46 + MultiByteToWideChar(CP_UTF8, 0, path, -1, buff, len);
47 + if (_wfullpath( buff2, buff, len ) != NULL) {
48 + f = _wfopen(buff2, (strcmp(mode, "r") == 0) ? L"r" : L"rb");
49 + }
50 + free(buff);
51 + free(buff2);
52 + return f;
53 + }
54 +#endif
55 + return fopen(path, mode);
57 diff -u mythes/mythes.hxx build/mythes/mythes.hxx
58 --- mythes/mythes.hxx 2010-03-04 12:56:23.000000000 +0100
59 +++ build/mythes/mythes.hxx 2014-05-22 10:11:14.363543731 +0200
60 @@ -30,6 +30,7 @@
61 MyThes & operator = (const MyThes &);
63 public:
64 + // use UTF-8 encoded paths in WIN32 environment
65 MyThes(const char* idxpath, const char* datpath);
66 ~MyThes();
68 @@ -66,6 +67,9 @@
69 // return index of char in string
70 int mystr_indexOfChar(const char * d, int c);
72 + // fopen or _wfopen
73 + FILE * myfopen(const char * path, const char * mode);
77 #endif