Salome HOME
initial commit : transfert of salome configuration files from internal git base
[tools/sat_salome.git] / products / patches / hdf5-1.10.3.win_unicode_new.patch
1 diff -Naur hdf5-1.10.3_SRC_orig/src/H5FDwindows.c hdf5-1.10.3_SRC_modif/src/H5FDwindows.c
2 --- hdf5-1.10.3_SRC_orig/src/H5FDwindows.c      2018-08-10 00:36:32.000000000 +0300
3 +++ hdf5-1.10.3_SRC_modif/src/H5FDwindows.c     2020-05-08 16:55:38.043834500 +0300
4 @@ -24,6 +24,27 @@
5  
6  #ifdef H5_HAVE_WINDOWS
7  
8 +int _win_open(const char *name, int oflag,...)
9 +{
10 +    int fd = -1;
11 +    int pmode = 0;
12 +    /* Get the mode, if O_CREAT was specified */
13 +    if(oflag & O_CREAT) {
14 +        va_list vl;
15 +
16 +        HDva_start(vl, oflag);
17 +        pmode = HDva_arg(vl, int);
18 +        HDva_end(vl);
19 +    }
20 +    int size_needed = MultiByteToWideChar(CP_UTF8, 0, name, strlen(name), NULL, 0);
21 +    wchar_t* wname = (wchar_t*)malloc( sizeof(wchar_t)*(size_needed + 1) );
22 +    MultiByteToWideChar( CP_UTF8, 0, name, strlen(name), wname, size_needed );
23 +    wname[size_needed] = '\0';
24 +    fd=_wopen(wname, oflag, pmode);
25 +    free(wname);
26 +    return fd;
27 +}
28 +
29  \f
30  /*-------------------------------------------------------------------------
31   * Function:    H5Pset_fapl_windows
32 diff -Naur hdf5-1.10.3_SRC_orig/src/H5win32defs.h hdf5-1.10.3_SRC_modif/src/H5win32defs.h
33 --- hdf5-1.10.3_SRC_orig/src/H5win32defs.h      2018-08-10 00:36:32.000000000 +0300
34 +++ hdf5-1.10.3_SRC_modif/src/H5win32defs.h     2020-05-08 16:53:04.239497600 +0300
35 @@ -54,7 +54,9 @@
36   * Also note that the variadic macro is using a VC++ extension
37   * where the comma is dropped if nothing is passed to the ellipsis.
38   */
39 -#define HDopen(S,F,...)       _open(S, F | _O_BINARY, __VA_ARGS__)
40 +//#define HDopen(S,F,...)       _open(S, F | _O_BINARY, __VA_ARGS__)
41 +H5_DLL int _win_open(const char *name, int oflag,...);
42 +#define HDopen(S,F,...)       _win_open(S, F | _O_BINARY, __VA_ARGS__)
43  #define HDread(F,M,Z)       _read(F,M,Z)
44  #define HDrmdir(S)          _rmdir(S)
45  #define HDsetvbuf(F,S,M,Z)  setvbuf(F,S,M,(Z>1?Z:2))