Compile the gzopen_w() function when __CYGWIN__ defined.

This commit is contained in:
Mark Adler 2015-08-01 17:38:56 -07:00
parent 2fc6d66797
commit b4ce6caf09
3 changed files with 9 additions and 5 deletions

View File

@ -39,6 +39,10 @@
# include <io.h>
#endif
#if defined(_WIN32) || defined(__CYGWIN__)
# define WIDECHAR
#endif
#ifdef WINAPI_FAMILY
# define open _open
# define read _read

View File

@ -188,7 +188,7 @@ local gzFile gz_open(path, fd, mode)
}
/* save the path name for error messages */
#ifdef _WIN32
#ifdef WIDECHAR
if (fd == -2) {
len = wcstombs(NULL, path, 0);
if (len == (size_t)-1)
@ -202,7 +202,7 @@ local gzFile gz_open(path, fd, mode)
free(state);
return NULL;
}
#ifdef _WIN32
#ifdef WIDECHAR
if (fd == -2)
if (len)
wcstombs(state->path, path, len + 1);
@ -239,7 +239,7 @@ local gzFile gz_open(path, fd, mode)
/* open the file with the appropriate flags (or just use fd) */
state->fd = fd > -1 ? fd : (
#ifdef _WIN32
#ifdef WIDECHAR
fd == -2 ? _wopen(path, oflag, 0666) :
#endif
open((const char *)path, oflag, 0666));
@ -303,7 +303,7 @@ gzFile ZEXPORT gzdopen(fd, mode)
}
/* -- see zlib.h -- */
#ifdef _WIN32
#ifdef WIDECHAR
gzFile ZEXPORT gzopen_w(path, mode)
const wchar_t *path;
const char *mode;

2
zlib.h
View File

@ -1757,7 +1757,7 @@ ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
#if defined(_WIN32) && !defined(Z_SOLO)
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
const char *mode));
#endif