More fixes for gzopen_w().
authorMark Adler <madler@alumni.caltech.edu>
Sun, 18 Mar 2012 16:29:44 +0000 (09:29 -0700)
committerMark Adler <madler@alumni.caltech.edu>
Sun, 18 Mar 2012 16:29:44 +0000 (09:29 -0700)
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.

gzlib.c
zconf.h
zconf.h.cmakein
zconf.h.in

diff --git a/gzlib.c b/gzlib.c
index b99c26c7b53ea63a566ea1ac4fc361dfed45d259..e31533b7496d366091ecf4f7bf5fc273fc101c01 100644 (file)
--- a/gzlib.c
+++ b/gzlib.c
@@ -185,12 +185,13 @@ local gzFile gz_open(path, fd, mode)
     }
 
     /* 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) {
         free(state);
         return NULL;
     }
-    strcpy(state->path, path);
+    strcpy(state->path, fd == -2 ? WPATH : path);
 
     /* compute the flags for open() */
     oflag =
diff --git a/zconf.h b/zconf.h
index f9a5fa7d67c5e7e004a8d36f757306e52f16ce90..8c6f945e385df018d4e4dcfcc9c21936d158f486 100644 (file)
--- a/zconf.h
+++ b/zconf.h
@@ -402,6 +402,10 @@ typedef uLong FAR uLongf;
 #  endif
 #endif
 
+#ifdef _WIN32
+#  include <stddef.h>           /* for wchar_t */
+#endif
+
 /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
  * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
  * though the former does not conform to the LFS document), but considering
index 66368adf9d5cee80ba6d034321b0699e29d42e79..4ade48745f86416cd9511df4a01e705dcd0e536d 100644 (file)
@@ -404,6 +404,10 @@ typedef uLong FAR uLongf;
 #  endif
 #endif
 
+#ifdef _WIN32
+#  include <stddef.h>           /* for wchar_t */
+#endif
+
 /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
  * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
  * though the former does not conform to the LFS document), but considering
index f9a5fa7d67c5e7e004a8d36f757306e52f16ce90..8c6f945e385df018d4e4dcfcc9c21936d158f486 100644 (file)
@@ -402,6 +402,10 @@ typedef uLong FAR uLongf;
 #  endif
 #endif
 
+#ifdef _WIN32
+#  include <stddef.h>           /* for wchar_t */
+#endif
+
 /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
  * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
  * though the former does not conform to the LFS document), but considering