zlib 1.2.4.1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7eefa49..a64fe0b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,7 +20,7 @@
 #
 # Check to see if we have large file support
 #
-set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE)
+set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
 # We add these other definitions here because CheckTypeSize.cmake
 # in CMake 2.4.x does not automatically do so and we want
 # compatibility with CMake 2.4.x.
@@ -35,7 +35,7 @@
 endif()
 check_type_size(off64_t OFF64_T)
 if(HAVE_OFF64_T)
-   add_definitions(-D_LARGEFILE64_SOURCE)
+   add_definitions(-D_LARGEFILE64_SOURCE=1)
 endif()
 set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
 
@@ -52,13 +52,6 @@
 #
 check_include_file(unistd.h Z_HAVE_UNISTD_H)
 
-#
-# Check for errno.h
-check_include_file(errno.h HAVE_ERRNO_H)
-if(NOT HAVE_ERRNO_H)
-   add_definitions(-DNO_ERRNO_H)
-endif()
-
 if(MSVC)
     set(CMAKE_DEBUG_POSTFIX "d")
     add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
diff --git a/ChangeLog b/ChangeLog
index 6d046ee..9817f59 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,30 @@
 
                 ChangeLog file for zlib
 
+Changes in 1.2.4.1 (28 Mar 2010)
+- Remove the use of [a-z] constructs for sed in configure [gentoo 310225]
+- Remove $(SHAREDLIB) from LIBS in Makefile.in [Creech]
+- Restore "for debugging" comment on sprintf() in gzlib.c
+- Remove fdopen for MVS from gzguts.h
+- Put new README-WIN32.txt in win32 [Rowe]
+- Add check for shell to configure and invoke another shell if needed
+- Fix big fat stinking bug in gzseek() on uncompressed files
+- Remove vestigial F_OPEN64 define in zutil.h
+- Set and check the value of _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE
+- Avoid errors on non-LFS systems when applications define LFS macros
+- Set EXE to ".exe" in configure for MINGW [Kahle]
+- Match crc32() in crc32.c exactly to the prototype in zlib.h [Sherrill]
+- Add prefix for cross-compilation in win32/makefile.gcc [Bar-Lev]
+- Add DLL install in win32/makefile.gcc [Bar-Lev]
+- Allow Linux* or linux* from uname in configure [Bar-Lev]
+- Allow ldconfig to be redefined in configure and Makefile.in [Bar-Lev]
+- Add cross-compilation prefixes to configure [Bar-Lev]
+- Match type exactly in gz_load() invocation in gzread.c
+- Match type exactly of zcalloc() in zutil.c to zlib.h alloc_func
+- Provide prototypes for *64 functions when building zlib without LFS
+- Don't use -lc when linking shared library on MinGW
+- Remove errno.h check in configure and vestigial errno code in zutil.h
+
 Changes in 1.2.4 (14 Mar 2010)
 - Fix VER3 extraction in configure for no fourth subversion
 - Update zlib.3, add docs to Makefile.in to make .pdf out of it
diff --git a/Makefile.in b/Makefile.in
index 5a2300a..a79f739 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -32,12 +32,14 @@
 
 STATICLIB=libz.a
 SHAREDLIB=libz.so
-SHAREDLIBV=libz.so.1.2.4
+SHAREDLIBV=libz.so.1.2.4.1
 SHAREDLIBM=libz.so.1
-LIBS=$(STATICLIB) $(SHAREDLIB) $(SHAREDLIBV)
+LIBS=$(STATICLIB) $(SHAREDLIBV)
 
 AR=ar rc
 RANLIB=ranlib
+LDCONFIG=ldconfig
+LDSHAREDLIBC=-lc
 TAR=tar
 SHELL=/bin/sh
 EXE=
@@ -134,7 +136,7 @@
 	-@mv objs/$*.o $@
 
 $(SHAREDLIBV): $(PIC_OBJS)
-	$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) -lc
+	$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC)
 	rm -f $(SHAREDLIB) $(SHAREDLIBM)
 	ln -s $@ $(SHAREDLIB)
 	ln -s $@ $(SHAREDLIBM)
@@ -171,7 +173,7 @@
 	  rm -f $(SHAREDLIB) $(SHAREDLIBM); \
 	  ln -s $(SHAREDLIBV) $(SHAREDLIB); \
 	  ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
-	  (ldconfig || true)  >/dev/null 2>&1; \
+	  ($(LDCONFIG) || true)  >/dev/null 2>&1; \
 	fi
 	cp zlib.3 $(DESTDIR)$(man3dir)
 	chmod 644 $(DESTDIR)$(man3dir)/zlib.3
diff --git a/README b/README
index f24aeee..a330267 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
 ZLIB DATA COMPRESSION LIBRARY
 
-zlib 1.2.4 is a general purpose data compression library.  All the code is
+zlib 1.2.4.1 is a general purpose data compression library.  All the code is
 thread safe.  The data format used by the zlib library is described by RFCs
 (Request for Comments) 1950 to 1952 in the files
 http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
@@ -30,7 +30,7 @@
 issue of Dr.  Dobb's Journal; a copy of the article is available at
 http://marknelson.us/1997/01/01/zlib-engine/ .
 
-The changes made in version 1.2.4 are documented in the file ChangeLog.
+The changes made in version 1.2.4.1 are documented in the file ChangeLog.
 
 Unsupported third party contributions are provided in directory contrib/ .
 
diff --git a/configure b/configure
index 672fd37..8a36129 100755
--- a/configure
+++ b/configure
@@ -13,15 +13,40 @@
 # If you have problems, try without defining CC and CFLAGS before reporting
 # an error.
 
+# make sure we are running under a compatible shell (stolen from ffmpeg and libnfo)
+if test "0$ZLIB_CONFIGURE_EXEC" -lt 1; then
+  unset foo
+  (: ${foo%%bar}) 2>/dev/null && ! (: ${foo?}) 2>/dev/null
+  if test "$?" -ne 0; then
+    ZLIB_CONFIGURE_EXEC=1
+    export ZLIB_CONFIGURE_EXEC
+    type "bash" > /dev/null 2>&1 && exec bash "$0" "$@"
+    type "ksh" > /dev/null 2>&1 && exec ksh "$0" "$@"
+    if test -x /usr/xpg4/bin/sh; then
+      exec /usr/xpg4/bin/sh "$0" "$@"
+    fi
+#    echo "No compatible shell script interpreter found."
+#    exit 1
+# we could give up here, but go ahead and give their old sh a try
+  fi
+fi
+
+if [ -n "${CHOST}" ]; then
+    uname="$(echo "${CHOST}" | sed 's/.*-.*-\(.*\)-.*/\1/')"
+    CROSS_PREFIX="${CHOST}-"
+fi
+
 STATICLIB=libz.a
 LDFLAGS="${LDFLAGS} -L. ${STATICLIB}"
 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
 VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h`
 VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
 VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
-AR=${AR-"ar"}
+AR=${AR-"${CROSS_PREFIX}ar"}
 AR_RC="${AR} rc"
-RANLIB=${RANLIB-"ranlib"}
+RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
+LDCONFIG=${LDCONFIG-"ldconfig"}
+LDSHAREDLIBC="${LDSHAREDLIBC-"-lc"}"
 prefix=${prefix-/usr/local}
 exec_prefix=${exec_prefix-'${prefix}'}
 libdir=${libdir-'${exec_prefix}/lib'}
@@ -43,11 +68,11 @@
       echo '  configure [--zprefix] [--prefix=PREFIX]  [--eprefix=EXPREFIX]'
       echo '    [--static] [--64] [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
         exit 0 ;;
-    -p*=* | --prefix=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift ;;
-    -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift ;;
-    -l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift ;;
-    -i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift ;;
-    -u*=* | --uname=*) uname=`echo $1 | sed 's/[-a-z_]*=//'`;shift ;;
+    -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
+    -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
+    -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
+    -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
+    -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
     -p* | --prefix) prefix="$2"; shift; shift ;;
     -e* | --eprefix) exec_prefix="$2"; shift; shift ;;
     -l* | --libdir) libdir="$2"; shift; shift ;;
@@ -69,7 +94,7 @@
 EOF
 
 test -z "$CC" && echo Checking for gcc...
-cc=${CC-gcc}
+cc=${CC-${CROSS_PREFIX}gcc}
 cflags=${CFLAGS-"-O3"}
 # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
 case "$cc" in
@@ -91,9 +116,12 @@
     uname=`(uname -s || echo unknown) 2>/dev/null`
   fi
   case "$uname" in
-  Linux | linux | GNU | GNU/* | *BSD | DragonFly) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
-  CYGWIN* | Cygwin* | cygwin* | OS/2* )
-             EXE='.exe' ;;
+  Linux* | linux* | GNU | GNU/* | *BSD | DragonFly) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
+  CYGWIN* | Cygwin* | cygwin* | OS/2*)
+        EXE='.exe' ;;
+  MINGW*)
+        LDSHAREDLIBC=""
+        EXE='.exe' ;;
   QNX*)  # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
          # (alain.bonnefoy@icbt.com)
                  LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
@@ -474,18 +502,6 @@
   fi
 fi
 
-cat >$test.c <<EOF
-#include <errno.h>
-int main() { return 0; }
-EOF
-if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
-  echo "Checking for errno.h... Yes."
-else
-  echo "Checking for errno.h... No."
-  CFLAGS="$CFLAGS -DNO_ERRNO_H"
-  SFLAGS="$SFLAGS -DNO_ERRNO_H"
-fi
-
 CPP=${CPP-"$CC -E"}
 case $CFLAGS in
   *ASMV*)
@@ -513,6 +529,8 @@
 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
 /^AR *=/s#=.*#=$AR_RC#
 /^RANLIB *=/s#=.*#=$RANLIB#
+/^LDCONFIG *=/s#=.*#=$LDCONFIG#
+/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
 /^EXE *=/s#=.*#=$EXE#
 /^prefix *=/s#=.*#=$prefix#
 /^exec_prefix *=/s#=.*#=$exec_prefix#
diff --git a/contrib/delphi/ZLib.pas b/contrib/delphi/ZLib.pas
index 179f9a9..03450e7 100644
--- a/contrib/delphi/ZLib.pas
+++ b/contrib/delphi/ZLib.pas
@@ -152,7 +152,7 @@
   const OutBuf: Pointer; BufSize: Integer);
 
 const
-  zlib_version = '1.2.4';
+  zlib_version = '1.2.4.1';
 
 type
   EZlibError = class(Exception);
diff --git a/contrib/dotzlib/DotZLib/UnitTests.cs b/contrib/dotzlib/DotZLib/UnitTests.cs
index 42c4588..82c749e 100644
--- a/contrib/dotzlib/DotZLib/UnitTests.cs
+++ b/contrib/dotzlib/DotZLib/UnitTests.cs
@@ -156,7 +156,7 @@
         public void Info_Version()

         {

             Info info = new Info();

-            Assert.AreEqual("1.2.4", Info.Version);

+            Assert.AreEqual("1.2.4.1", Info.Version);

             Assert.AreEqual(32, info.SizeOfUInt);

             Assert.AreEqual(32, info.SizeOfULong);

             Assert.AreEqual(32, info.SizeOfPointer);

diff --git a/contrib/infback9/inftree9.c b/contrib/infback9/inftree9.c
index 510bba6..e898893 100644
--- a/contrib/infback9/inftree9.c
+++ b/contrib/infback9/inftree9.c
@@ -9,7 +9,7 @@
 #define MAXBITS 15
 
 const char inflate9_copyright[] =
-   " inflate9 1.2.4 Copyright 1995-2010 Mark Adler ";
+   " inflate9 1.2.4.1 Copyright 1995-2010 Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
   in the documentation of your product. If for some reason you cannot
@@ -64,7 +64,7 @@
     static const unsigned short lext[31] = { /* Length codes 257..285 extra */
         128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
         130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
-        133, 133, 133, 133, 144, 64, 195};
+        133, 133, 133, 133, 144, 67, 206};
     static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
         1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
         65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
diff --git a/contrib/pascal/zlibpas.pas b/contrib/pascal/zlibpas.pas
index dc7d37d..9772f11 100644
--- a/contrib/pascal/zlibpas.pas
+++ b/contrib/pascal/zlibpas.pas
@@ -10,7 +10,7 @@
 interface
 
 const
-  ZLIB_VERSION = '1.2.4';
+  ZLIB_VERSION = '1.2.4.1';
 
 type
   alloc_func = function(opaque: Pointer; items, size: Integer): Pointer;
diff --git a/contrib/vstudio/vc10/zlib.rc b/contrib/vstudio/vc10/zlib.rc
index 23802d8..d6b9991 100644
--- a/contrib/vstudio/vc10/zlib.rc
+++ b/contrib/vstudio/vc10/zlib.rc
@@ -2,8 +2,8 @@
 

 #define IDR_VERSION1  1

 IDR_VERSION1	VERSIONINFO	MOVEABLE IMPURE LOADONCALL DISCARDABLE

-  FILEVERSION	 1,2,4,0

-  PRODUCTVERSION 1,2,4,0

+  FILEVERSION	 1,2,4,1

+  PRODUCTVERSION 1,2,4,1

   FILEFLAGSMASK	VS_FFI_FILEFLAGSMASK

   FILEFLAGS	0

   FILEOS	VOS_DOS_WINDOWS32

@@ -17,7 +17,7 @@
 

     BEGIN

       VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"

-      VALUE "FileVersion",	"1.2.4.0\0"

+      VALUE "FileVersion",	"1.2.4.1\0"

       VALUE "InternalName",	"zlib\0"

       VALUE "OriginalFilename",	"zlib.dll\0"

       VALUE "ProductName",	"ZLib.DLL\0"

diff --git a/contrib/vstudio/vc9/zlib.rc b/contrib/vstudio/vc9/zlib.rc
index 23802d8..d6b9991 100644
--- a/contrib/vstudio/vc9/zlib.rc
+++ b/contrib/vstudio/vc9/zlib.rc
@@ -2,8 +2,8 @@
 

 #define IDR_VERSION1  1

 IDR_VERSION1	VERSIONINFO	MOVEABLE IMPURE LOADONCALL DISCARDABLE

-  FILEVERSION	 1,2,4,0

-  PRODUCTVERSION 1,2,4,0

+  FILEVERSION	 1,2,4,1

+  PRODUCTVERSION 1,2,4,1

   FILEFLAGSMASK	VS_FFI_FILEFLAGSMASK

   FILEFLAGS	0

   FILEOS	VOS_DOS_WINDOWS32

@@ -17,7 +17,7 @@
 

     BEGIN

       VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"

-      VALUE "FileVersion",	"1.2.4.0\0"

+      VALUE "FileVersion",	"1.2.4.1\0"

       VALUE "InternalName",	"zlib\0"

       VALUE "OriginalFilename",	"zlib.dll\0"

       VALUE "ProductName",	"ZLib.DLL\0"

diff --git a/crc32.c b/crc32.c
index 1acc7ed..6b81fb4 100644
--- a/crc32.c
+++ b/crc32.c
@@ -221,7 +221,7 @@
 unsigned long ZEXPORT crc32(crc, buf, len)
     unsigned long crc;
     const unsigned char FAR *buf;
-    unsigned len;
+    uInt len;
 {
     if (buf == Z_NULL) return 0UL;
 
diff --git a/deflate.c b/deflate.c
index fcd698c..b7fb9fc 100644
--- a/deflate.c
+++ b/deflate.c
@@ -52,7 +52,7 @@
 #include "deflate.h"
 
 const char deflate_copyright[] =
-   " deflate 1.2.4 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
+   " deflate 1.2.4.1 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
   in the documentation of your product. If for some reason you cannot
diff --git a/gzguts.h b/gzguts.h
index 0e7ed43..53857e0 100644
--- a/gzguts.h
+++ b/gzguts.h
@@ -3,9 +3,9 @@
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
-#ifdef _LARGEFILE64_SOURCE
+#if _LARGEFILE64_SOURCE == 1
 #  ifndef _LARGEFILE_SOURCE
-#    define _LARGEFILE_SOURCE
+#    define _LARGEFILE_SOURCE 1
 #  endif
 #  ifdef _FILE_OFFSET_BITS
 #    undef _FILE_OFFSET_BITS
@@ -44,7 +44,7 @@
 #endif
 
 /* get errno and strerror definition */
-#if defined UNDER_CE && defined NO_ERRNO_H
+#if defined UNDER_CE
 #  include <windows.h>
 #  define zstrerror() gz_strwinerror((DWORD)GetLastError())
 #else
@@ -56,13 +56,7 @@
 #  endif
 #endif
 
-/* MVS fdopen() */
-#ifdef __MVS__
-  #pragma map (fdopen , "\174\174FDOPEN")
-   FILE *fdopen(int, const char *);
-#endif
-
-#ifdef _LARGEFILE64_SOURCE
+#if _LARGEFILE64_SOURCE == 1
 #  define z_off64_t off64_t
 #else
 #  define z_off64_t z_off_t
@@ -117,7 +111,7 @@
 
 /* shared functions */
 ZEXTERN void ZEXPORT gz_error OF((gz_statep, int, const char *));
-#if defined UNDER_CE && defined NO_ERRNO_H
+#if defined UNDER_CE
 ZEXTERN char ZEXPORT *gz_strwinerror OF((DWORD error));
 #endif
 
diff --git a/gzlib.c b/gzlib.c
index 6fdb08a..15999ae 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -5,7 +5,7 @@
 
 #include "gzguts.h"
 
-#ifdef _LARGEFILE64_SOURCE
+#if _LARGEFILE64_SOURCE == 1 && _LFS64_LARGEFILE == 1
 #  define LSEEK lseek64
 #else
 #  define LSEEK lseek
@@ -15,7 +15,7 @@
 local void gz_reset OF((gz_statep));
 local gzFile gz_open OF((const char *, int, const char *));
 
-#if defined UNDER_CE && defined NO_ERRNO_H
+#if defined UNDER_CE
 
 /* Map the Windows error number in ERROR to a locale-dependent error message
    string and return a pointer to it.  Typically, the values for ERROR come
@@ -65,7 +65,7 @@
     return buf;
 }
 
-#endif /* UNDER_CE && NO_ERRNO_H */
+#endif /* UNDER_CE */
 
 /* Reset gzip file state */
 local void gz_reset(state)
@@ -217,7 +217,7 @@
 
     if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL)
         return NULL;
-    sprintf(path, "<fd:%d>", fd);
+    sprintf(path, "<fd:%d>", fd);   /* for debugging */
     gz = gz_open(path, fd, mode);
     free(path);
     return gz;
@@ -305,7 +305,7 @@
     /* if within raw area while reading, just go there */
     if (state->mode == GZ_READ && state->how == COPY &&
         state->pos + offset >= state->raw) {
-        ret = LSEEK(state->fd, offset, SEEK_CUR);
+        ret = LSEEK(state->fd, offset - state->have, SEEK_CUR);
         if (ret == -1)
             return -1;
         state->have = 0;
diff --git a/gzread.c b/gzread.c
index 434ef02..548201a 100644
--- a/gzread.c
+++ b/gzread.c
@@ -55,7 +55,8 @@
     if (state->err != Z_OK)
         return -1;
     if (state->eof == 0) {
-        if (gz_load(state, state->in, state->size, &(strm->avail_in)) == -1)
+        if (gz_load(state, state->in, state->size,
+                (unsigned *)&(strm->avail_in)) == -1)
             return -1;
         strm->next_in = state->in;
     }
diff --git a/inftrees.c b/inftrees.c
index ccf7fa9..90de8b8 100644
--- a/inftrees.c
+++ b/inftrees.c
@@ -9,7 +9,7 @@
 #define MAXBITS 15
 
 const char inflate_copyright[] =
-   " inflate 1.2.4 Copyright 1995-2010 Mark Adler ";
+   " inflate 1.2.4.1 Copyright 1995-2010 Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
   in the documentation of your product. If for some reason you cannot
@@ -62,7 +62,7 @@
         35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
     static const unsigned short lext[31] = { /* Length codes 257..285 extra */
         16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
-        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 64, 195};
+        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 67, 206};
     static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
         1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
         257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
diff --git a/minigzip.c b/minigzip.c
index 84d823b..9677fa0 100644
--- a/minigzip.c
+++ b/minigzip.c
@@ -54,7 +54,7 @@
   extern int unlink OF((const char *));
 #endif
 
-#if defined(UNDER_CE) && defined(NO_ERRNO_H)
+#if defined(UNDER_CE)
 #  include <windows.h>
 #  define perror(s) pwinerror(s)
 
@@ -116,7 +116,7 @@
         fprintf(stderr, "%s\n", strwinerror(GetLastError ()));
 }
 
-#endif /* UNDER_CE && NO_ERRNO_H */
+#endif /* UNDER_CE */
 
 #ifndef GZ_SUFFIX
 #  define GZ_SUFFIX ".gz"
diff --git a/qnx/package.qpg b/qnx/package.qpg
index 470d2d5..bf3433a 100644
--- a/qnx/package.qpg
+++ b/qnx/package.qpg
@@ -25,10 +25,10 @@
       <QPG:Files>
          <QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/>
          <QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
-         <QPG:Add file="../libz.so.1.2.4" install="/opt/lib/" user="root:bin" permission="644"/>
-         <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.4"/>
-         <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.4"/>
-         <QPG:Add file="../libz.so.1.2.4" install="/opt/lib/" component="slib"/>
+         <QPG:Add file="../libz.so.1.2.4.1" install="/opt/lib/" user="root:bin" permission="644"/>
+         <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.4.1"/>
+         <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.4.1"/>
+         <QPG:Add file="../libz.so.1.2.4.1" install="/opt/lib/" component="slib"/>
       </QPG:Files>
 
       <QPG:PackageFilter>
@@ -63,7 +63,7 @@
             </QPM:ProductDescription>
 
             <QPM:ReleaseDescription>
-               <QPM:ReleaseVersion>1.2.4</QPM:ReleaseVersion>
+               <QPM:ReleaseVersion>1.2.4.1</QPM:ReleaseVersion>
                <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
                <QPM:ReleaseStability>Stable</QPM:ReleaseStability>
                <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>
diff --git a/treebuild.xml b/treebuild.xml
index 91ee891..e30532e 100644
--- a/treebuild.xml
+++ b/treebuild.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" ?>
-<package name="zlib" version="1.2.4">
-    <library name="zlib" dlversion="1.2.4" dlname="z">
+<package name="zlib" version="1.2.4.1">
+    <library name="zlib" dlversion="1.2.4.1" dlname="z">
 	<property name="description"> zip compression library </property>
 	<property name="include-target-dir" value="$(@PACKAGE/install-includedir)" />
 
diff --git a/win32/Makefile.gcc b/win32/Makefile.gcc
index abe3d5a..0e16190 100644
--- a/win32/Makefile.gcc
+++ b/win32/Makefile.gcc
@@ -30,7 +30,8 @@
 #LOC = -DASMV
 #LOC = -DDEBUG -g
 
-CC = gcc
+PREFIX =
+CC = $(PREFIX)gcc
 CFLAGS = $(LOC) -O3 -Wall
 
 AS = $(CC)
@@ -39,13 +40,13 @@
 LD = $(CC)
 LDFLAGS = $(LOC) -s
 
-AR = ar
+AR = $(PREFIX)ar
 ARFLAGS = rcs
 
-RC = windres
+RC = $(PREFIX)windres
 RCFLAGS = --define GCC_WINDRES
 
-STRIP = strip
+STRIP = $(PREFIX)strip
 
 CP = cp -fp
 # If GNU install is available, replace $(CP) with install.
@@ -106,8 +107,8 @@
 .PHONY: install uninstall clean
 
 install: zlib.h zconf.h $(LIB)
-	-@if not exist $(INCLUDE_PATH)/nul mkdir $(INCLUDE_PATH)
-	-@if not exist $(LIBRARY_PATH)/nul mkdir $(LIBRARY_PATH)
+	-@mkdir -p $(INCLUDE_PATH)
+	-@mkdir -p $(LIBRARY_PATH)
 	-$(INSTALL) zlib.h $(INCLUDE_PATH)
 	-$(INSTALL) zconf.h $(INCLUDE_PATH)
 	-$(INSTALL) $(STATICLIB) $(LIBRARY_PATH)
diff --git a/win32/README-WIN32.txt b/win32/README-WIN32.txt
new file mode 100644
index 0000000..35062cd
--- /dev/null
+++ b/win32/README-WIN32.txt
@@ -0,0 +1,103 @@
+ZLIB DATA COMPRESSION LIBRARY
+
+zlib 1.2.4 is a general purpose data compression library.  All the code is
+thread safe.  The data format used by the zlib library is described by RFCs
+(Request for Comments) 1950 to 1952 in the files
+http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
+and rfc1952.txt (gzip format).
+
+All functions of the compression library are documented in the file zlib.h
+(volunteer to write man pages welcome, contact zlib@gzip.org).  Two compiled
+examples are distributed in this package, example and minigzip.  The example_d
+and minigzip_d flavors validate that the zlib1.dll file is working correctly.
+
+Questions about zlib should be sent to <zlib@gzip.org>.  The zlib home page
+is http://zlib.net/ .  Before reporting a problem, please check this site to
+verify that you have the latest version of zlib; otherwise get the latest
+version and check whether the problem still exists or not.
+
+PLEASE read DLL_FAQ.txt, and the the zlib FAQ http://zlib.net/zlib_faq.html
+before asking for help.
+
+
+Manifest:
+
+The package zlib-1.2.4-win32-x86.zip contains the following files:
+
+  README-WIN32.txt This document
+  ChangeLog        Changes since previous zlib packages
+  DLL_FAQ.txt      Frequently asked questions about zlib1.dll
+  zlib.3.pdf       Documentation of this library in Adobe Acrobat format
+
+  example.exe      A statically-bound example (using zlib.lib, not the dll)
+  example.pdb      Symbolic information for debugging example.exe
+
+  example_d.exe    A zlib1.dll bound example (using zdll.lib)
+  example_d.pdb    Symbolic information for debugging example_d.exe
+
+  minigzip.exe     A statically-bound test program (using zlib.lib, not the dll)
+  minigzip.pdb     Symbolic information for debugging minigzip.exe
+
+  minigzip_d.exe   A zlib1.dll bound test program (using zdll.lib)
+  minigzip_d.pdb   Symbolic information for debugging minigzip_d.exe
+
+  zlib.h           Install these files into the compilers' INCLUDE path to
+  zconf.h          compile programs which use zlib.lib or zdll.lib
+
+  zdll.lib         Install these files into the compilers' LIB path if linking
+  zdll.exp         a compiled program to the zlib1.dll binary
+
+  zlib.lib         Install these files into the compilers' LIB path if linking
+  zlib.pdb         a compiled program to the zlib1.dll binary (zlib.pdb ensures
+                   that the resulting program may be debugged)
+
+  zlib1.dll        Install this binary shared library into the system PATH, or
+                   the program's runtime directory (where the .exe resides)
+  zlib1.pdb        Install in the same directory as zlib1.dll, in order to debug
+                   an application crash using WinDbg or similar tools.
+
+All .pdb files above are entirely optional, but are very useful to a developer
+attempting to diagnose program misbehavior or a crash.  Many additional
+important files for developers can be found in the zlib124.zip source package
+available from http://zlib.net/ - review that package's README file for details.
+
+
+Acknowledgments:
+
+The deflate format used by zlib was defined by Phil Katz.  The deflate and
+zlib specifications were written by L.  Peter Deutsch.  Thanks to all the
+people who reported problems and suggested various improvements in zlib; they
+are too numerous to cite here.
+
+
+Copyright notice:
+
+  (C) 1995-2010 Jean-loup Gailly and Mark Adler
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+  Jean-loup Gailly        Mark Adler
+  jloup@gzip.org          madler@alumni.caltech.edu
+
+If you use the zlib library in a product, we would appreciate *not* receiving
+lengthy legal documents to sign.  The sources are provided for free but without
+warranty of any kind.  The library has been entirely written by Jean-loup
+Gailly and Mark Adler; it does not include third-party code.
+
+If you redistribute modified sources, we would appreciate that you include in
+the file ChangeLog history information documenting your changes.  Please read
+the FAQ for more information on the distribution of modified source versions.
diff --git a/zconf.h b/zconf.h
index 5888024..6ad8a04 100644
--- a/zconf.h
+++ b/zconf.h
@@ -364,7 +364,7 @@
 #  define Z_HAVE_UNISTD_H
 #endif
 
-#ifdef Z_HAVE_UNISTD_H
+#if defined(Z_HAVE_UNISTD_H) || _LARGEFILE64_SOURCE == 1
 #  include <sys/types.h>    /* for off_t */
 #  include <unistd.h>       /* for SEEK_* and off_t */
 #  ifdef VMS
@@ -375,15 +375,12 @@
 #  endif
 #endif
 
-#ifdef _LARGEFILE64_SOURCE
-#  include <sys/types.h>
-#endif
-
 #ifndef SEEK_SET
 #  define SEEK_SET        0       /* Seek from beginning of file.  */
 #  define SEEK_CUR        1       /* Seek from current position.  */
 #  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
 #endif
+
 #ifndef z_off_t
 #  define z_off_t long
 #endif
diff --git a/zconf.h.cmakein b/zconf.h.cmakein
index eec8ab0..fcd5710 100644
--- a/zconf.h.cmakein
+++ b/zconf.h.cmakein
@@ -366,7 +366,7 @@
 #  define Z_HAVE_UNISTD_H
 #endif
 
-#ifdef Z_HAVE_UNISTD_H
+#if defined(Z_HAVE_UNISTD_H) || _LARGEFILE64_SOURCE == 1
 #  include <sys/types.h>    /* for off_t */
 #  include <unistd.h>       /* for SEEK_* and off_t */
 #  ifdef VMS
@@ -377,15 +377,12 @@
 #  endif
 #endif
 
-#ifdef _LARGEFILE64_SOURCE
-#  include <sys/types.h>
-#endif
-
 #ifndef SEEK_SET
 #  define SEEK_SET        0       /* Seek from beginning of file.  */
 #  define SEEK_CUR        1       /* Seek from current position.  */
 #  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
 #endif
+
 #ifndef z_off_t
 #  define z_off_t long
 #endif
diff --git a/zconf.h.in b/zconf.h.in
index 5888024..6ad8a04 100644
--- a/zconf.h.in
+++ b/zconf.h.in
@@ -364,7 +364,7 @@
 #  define Z_HAVE_UNISTD_H
 #endif
 
-#ifdef Z_HAVE_UNISTD_H
+#if defined(Z_HAVE_UNISTD_H) || _LARGEFILE64_SOURCE == 1
 #  include <sys/types.h>    /* for off_t */
 #  include <unistd.h>       /* for SEEK_* and off_t */
 #  ifdef VMS
@@ -375,15 +375,12 @@
 #  endif
 #endif
 
-#ifdef _LARGEFILE64_SOURCE
-#  include <sys/types.h>
-#endif
-
 #ifndef SEEK_SET
 #  define SEEK_SET        0       /* Seek from beginning of file.  */
 #  define SEEK_CUR        1       /* Seek from current position.  */
 #  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
 #endif
+
 #ifndef z_off_t
 #  define z_off_t long
 #endif
diff --git a/zlib.3 b/zlib.3
index 52999c7..2c1679d 100644
--- a/zlib.3
+++ b/zlib.3
@@ -1,4 +1,4 @@
-.TH ZLIB 3 "14 March 2010"
+.TH ZLIB 3 "28 Mar 2010"
 .SH NAME
 zlib \- compression/decompression library
 .SH SYNOPSIS
@@ -125,7 +125,7 @@
 Send questions and/or comments to zlib@gzip.org,
 or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
 .SH AUTHORS
-Version 1.2.4
+Version 1.2.4.1
 Copyright (C) 1995-2010 Jean-loup Gailly (jloup@gzip.org)
 and Mark Adler (madler@alumni.caltech.edu).
 .LP
diff --git a/zlib.3.pdf b/zlib.3.pdf
index 05ed2d0..0d63b20 100644
--- a/zlib.3.pdf
+++ b/zlib.3.pdf
Binary files differ
diff --git a/zlib.h b/zlib.h
index f5785be..1fcf630 100644
--- a/zlib.h
+++ b/zlib.h
@@ -1,5 +1,5 @@
 /* zlib.h -- interface of the 'zlib' general purpose compression library
-  version 1.2.4, Mar 14th, 2010
+  version 1.2.4.1, March 28th, 2010
 
   Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
 
@@ -37,12 +37,12 @@
 extern "C" {
 #endif
 
-#define ZLIB_VERSION "1.2.4"
-#define ZLIB_VERNUM 0x1240
+#define ZLIB_VERSION "1.2.4.1"
+#define ZLIB_VERNUM 0x1241
 #define ZLIB_VER_MAJOR 1
 #define ZLIB_VER_MINOR 2
 #define ZLIB_VER_REVISION 4
-#define ZLIB_VER_SUBREVISION 0
+#define ZLIB_VER_SUBREVISION 1
 
 /*
     The 'zlib' compression library provides in-memory compression and
@@ -1556,7 +1556,7 @@
         inflateBackInit_((strm), (windowBits), (window), \
                                             ZLIB_VERSION, sizeof(z_stream))
 
-#ifdef _LARGEFILE64_SOURCE
+#if _LARGEFILE64_SOURCE == 1 && _LFS64_LARGEFILE == 1
    ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
    ZEXTERN off64_t ZEXPORT gzseek64 OF((gzFile, off64_t, int));
    ZEXTERN off64_t ZEXPORT gztell64 OF((gzFile));
@@ -1565,14 +1565,14 @@
    ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, off64_t));
 #endif
 
-#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS == 64
+#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS == 64 && _LFS64_LARGEFILE == 1
 #  define gzopen gzopen64
 #  define gzseek gzseek64
 #  define gztell gztell64
 #  define gzoffset gzoffset64
 #  define adler32_combine adler32_combine64
 #  define crc32_combine crc32_combine64
-#  ifndef _LARGEFILE64_SOURCE
+#  if _LARGEFILE64_SOURCE != 1
      ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
      ZEXTERN off_t ZEXPORT gzseek64 OF((gzFile, off_t, int));
      ZEXTERN off_t ZEXPORT gztell64 OF((gzFile));
diff --git a/zutil.c b/zutil.c
index 98a55a8..6ba16f6 100644
--- a/zutil.c
+++ b/zutil.c
@@ -272,7 +272,7 @@
 #  define _hfree   hfree
 #endif
 
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
+voidpf zcalloc (voidpf opaque, uInt items, uInt size)
 {
     if (opaque) opaque = 0; /* to make compiler happy */
     return _halloc((long)items, size);
diff --git a/zutil.h b/zutil.h
index 025035d..b21a19c 100644
--- a/zutil.h
+++ b/zutil.h
@@ -24,19 +24,6 @@
 #  include <stdlib.h>
 #endif
 
-#if defined(UNDER_CE) && defined(NO_ERRNO_H)
-#  define zseterrno(ERR) SetLastError((DWORD)(ERR))
-#  define zerrno() ((int)GetLastError())
-#else
-#  ifdef NO_ERRNO_H
-     extern int errno;
-#  else
-#    include <errno.h>
-#  endif
-#  define zseterrno(ERR) do { errno = (ERR); } while (0)
-#  define zerrno() errno
-#endif
-
 #ifndef local
 #  define local static
 #endif
@@ -167,12 +154,22 @@
   #pragma warn -8066
 #endif
 
-#ifdef _LARGEFILE64_SOURCE
+#if _LARGEFILE64_SOURCE == 1 && _LFS64_LARGEFILE == 1
 #  define z_off64_t off64_t
 #else
 #  define z_off64_t z_off_t
 #endif
 
+/* provide prototypes for these when building zlib without LFS */
+#if _LARGEFILE64_SOURCE != 1 || _LFS64_LARGEFILE != 1
+    ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+    ZEXTERN off_t ZEXPORT gzseek64 OF((gzFile, off_t, int));
+    ZEXTERN off_t ZEXPORT gztell64 OF((gzFile));
+    ZEXTERN off_t ZEXPORT gzoffset64 OF((gzFile));
+    ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, off_t));
+    ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, off_t));
+#endif
+
         /* common defaults */
 
 #ifndef OS_CODE
@@ -183,12 +180,6 @@
 #  define F_OPEN(name, mode) fopen((name), (mode))
 #endif
 
-#ifdef _LARGEFILE64_SOURCE
-#  define F_OPEN64(name, mode) fopen64((name), (mode))
-#else
-#  define F_OPEN64(name, mode) fopen((name), (mode))
-#endif
-
          /* functions */
 
 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)