Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / external / hyphen / hyphen-fdo48017-wfopen.patch
blob815eeda79a3750fa7b68ddc60448e1c9bf137fe0
1 diff -u hyphen/hyphen.c build/hyphen/hyphen.c
2 --- hyphen/hyphen.c 2014-05-22 00:28:13.164587974 +0200
3 +++ build/hyphen/hyphen.c 2015-05-22 11:08:55.000000000 +0200
4 @@ -44,6 +44,11 @@
5 #include <unistd.h> /* for exit */
6 #endif
8 +#ifdef _WIN32
9 +#include <windows.h>
10 +#include <wchar.h>
11 +#endif
13 #define noVERBOSE
15 /* calculate hyphenmin values with long ligature length (2 or 3 characters
16 @@ -371,12 +376,32 @@
20 +FILE * hnj_fopen(const char * path, const char * mode) {
21 +#ifdef _WIN32
22 +#define WIN32_LONG_PATH_PREFIX "\\\\?\\"
23 + if (strncmp(path, WIN32_LONG_PATH_PREFIX, 4) == 0) {
24 + int len = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0);
25 + wchar_t *buff = (wchar_t *) malloc(len * sizeof(wchar_t));
26 + wchar_t *buff2 = (wchar_t *) malloc(len * sizeof(wchar_t));
27 + FILE * f = NULL;
28 + MultiByteToWideChar(CP_UTF8, 0, path, -1, buff, len);
29 + if (_wfullpath( buff2, buff, len ) != NULL) {
30 + f = _wfopen(buff2, (strcmp(mode, "r") == 0) ? L"r" : L"rb");
31 + }
32 + free(buff);
33 + free(buff2);
34 + return f;
35 + }
36 +#endif
37 + return fopen(path, mode);
40 HyphenDict *
41 hnj_hyphen_load (const char *fn)
43 HyphenDict *result;
44 FILE *f;
45 - f = fopen (fn, "r");
46 + f = hnj_fopen (fn, "r");
47 if (f == NULL)
48 return NULL;