summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2013-08-12 22:48:04 +0300
committerEli Zaretskii <eliz@gnu.org>2013-08-12 22:48:04 +0300
commitaa942e2bf4545365d7fb7e9d787e4a21642fbf4c (patch)
tree0cb260daad1d96ecd644cef40e8872921729c317
parent7d8e68fed31cd980eeeb34caf4d10ca5de37cf3b (diff)
downloademacs-aa942e2bf4545365d7fb7e9d787e4a21642fbf4c.tar.gz
Fix zlib support on MS-Windows.
configure.ac (HAVE_ZLIB): Don't use -lz on MinGW. src/decompress.c <zlib_initialized> [WINDOWSNT]: New static variable. (Fzlib_decompress_region) [WINDOWSNT]: Call init_zlib_functions if not yet initialized.
-rw-r--r--ChangeLog4
-rw-r--r--configure.ac4
-rw-r--r--src/ChangeLog6
-rw-r--r--src/decompress.c13
4 files changed, 24 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index f579c5226f1..c0b7d967113 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-08-12 Eli Zaretskii <eliz@gnu.org>
+
+ * configure.ac (HAVE_ZLIB): Don't use -lz on MinGW.
+
2013-08-12 Paul Eggert <eggert@cs.ucla.edu>
Minor zlib configuration tweaks.
diff --git a/configure.ac b/configure.ac
index b6c7dacd997..20054fd6d2f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2955,6 +2955,10 @@ if test "${with_zlib}" != "no"; then
fi
if test "${HAVE_ZLIB}" = "yes"; then
AC_DEFINE([HAVE_ZLIB], 1, [Define to 1 if you have the zlib library (-lz).])
+ ### mingw32 doesn't use -lz, since it loads the library dynamically.
+ if test "${opsys}" = "mingw32"; then
+ LIBZ=
+ fi
fi
AC_SUBST(LIBZ)
diff --git a/src/ChangeLog b/src/ChangeLog
index 88e1fdc4e66..04c89b63fa4 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2013-08-12 Eli Zaretskii <eliz@gnu.org>
+
+ * decompress.c <zlib_initialized> [WINDOWSNT]: New static variable.
+ (Fzlib_decompress_region) [WINDOWSNT]: Call init_zlib_functions if
+ not yet initialized.
+
2013-08-12 Lars Magne Ingebrigtsen <larsi@gnus.org>
* decompress.c (Fzlib_decompress_region): Support zlib
diff --git a/src/decompress.c b/src/decompress.c
index b3ad4f7676a..a09033ab8c3 100644
--- a/src/decompress.c
+++ b/src/decompress.c
@@ -38,7 +38,7 @@ static Lisp_Object Qzlib_dll;
/* Macro for loading zlib functions from the library. */
#define LOAD_ZLIB_FN(lib,func) { \
fn_##func = (void *) GetProcAddress (lib, #func); \
- if (!fn_##func) return 0; \
+ if (!fn_##func) return false; \
}
DEF_ZLIB_FN (int, inflateInit2_,
@@ -50,6 +50,8 @@ DEF_ZLIB_FN (int, inflate,
DEF_ZLIB_FN (int, inflateEnd,
(z_streamp strm));
+static bool zlib_initialized;
+
static bool
init_zlib_functions (void)
{
@@ -58,13 +60,13 @@ init_zlib_functions (void)
if (!library)
{
message1 ("zlib library not found");
- return 0;
+ return false;
}
LOAD_ZLIB_FN (library, inflateInit2_);
LOAD_ZLIB_FN (library, inflate);
LOAD_ZLIB_FN (library, inflateEnd);
- return 1;
+ return true;
}
#define fn_inflateInit2(strm, windowBits) \
@@ -139,6 +141,11 @@ This function can be called only in unibyte buffers. */)
if (! NILP (BVAR (current_buffer, enable_multibyte_characters)))
error ("This function can be called only in unibyte buffers");
+#ifdef WINDOWSNT
+ if (!zlib_initialized)
+ zlib_initialized = init_zlib_functions ();
+#endif
+
/* This is a unibyte buffer, so character positions and bytes are
the same. */
istart = XINT (start);