More fixes for gzopen_w().

Also need to #include <stddef.h> for zlib.h, and need to workaround
the inability to use wide characters in constructed error messages
with zlib's interface.
This commit is contained in:
Mark Adler 2012-03-18 09:29:44 -07:00
parent a1af6e96e3
commit 8e16df2c3f
4 changed files with 15 additions and 2 deletions

View File

@ -185,12 +185,13 @@ local gzFile gz_open(path, fd, mode)
} }
/* save the path name for error messages */ /* save the path name for error messages */
state->path = malloc(strlen(path) + 1); # define WPATH "<widepath>"
state->path = malloc(strlen(fd == -2 ? WPATH : (path) + 1);
if (state->path == NULL) { if (state->path == NULL) {
free(state); free(state);
return NULL; return NULL;
} }
strcpy(state->path, path); strcpy(state->path, fd == -2 ? WPATH : path);
/* compute the flags for open() */ /* compute the flags for open() */
oflag = oflag =

View File

@ -402,6 +402,10 @@ typedef uLong FAR uLongf;
# endif # endif
#endif #endif
#ifdef _WIN32
# include <stddef.h> /* for wchar_t */
#endif
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
* though the former does not conform to the LFS document), but considering * though the former does not conform to the LFS document), but considering

View File

@ -404,6 +404,10 @@ typedef uLong FAR uLongf;
# endif # endif
#endif #endif
#ifdef _WIN32
# include <stddef.h> /* for wchar_t */
#endif
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
* though the former does not conform to the LFS document), but considering * though the former does not conform to the LFS document), but considering

View File

@ -402,6 +402,10 @@ typedef uLong FAR uLongf;
# endif # endif
#endif #endif
#ifdef _WIN32
# include <stddef.h> /* for wchar_t */
#endif
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
* though the former does not conform to the LFS document), but considering * though the former does not conform to the LFS document), but considering