From 88baa583b93db6e7d88b0f0d6a0b7da8edaeaa62 Mon Sep 17 00:00:00 2001 From: Matt Oliver Date: Sun, 10 May 2020 01:55:09 +1000 Subject: [PATCH] Prevent invalid inclusions when HAVE_* is set to 0. When including zconf.h from an external project that already has HAVE_UNISTD_H declared to a non-empty define (in this case =0), the inclusion of unistd.h is incorrectly applied. This breaks inclusion of zlib in several projects on windows and other platforms without unistd.h. This patch changes behaviour so that HAVE_UNISTD_H is checked to see if it is defined as blank or not equal to '0' before inclusion of the header. --- zconf.h.cmakein | 12 ++++++++++-- zconf.h.in | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/zconf.h.cmakein b/zconf.h.cmakein index a7f24cce..a1b359bc 100644 --- a/zconf.h.cmakein +++ b/zconf.h.cmakein @@ -434,11 +434,19 @@ typedef uLong FAR uLongf; #endif #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H +# if ~(~HAVE_UNISTD_H + 0) == 0 && ~(~HAVE_UNISTD_H + 1) == 1 +# define Z_HAVE_UNISTD_H +# elif HAVE_UNISTD_H != 0 +# define Z_HAVE_UNISTD_H +# endif #endif #ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_STDARG_H +# if ~(~HAVE_STDARG_H + 0) == 0 && ~(~HAVE_STDARG_H + 1) == 1 +# define Z_HAVE_STDARG_H +# elif HAVE_STDARG_H != 0 +# define Z_HAVE_STDARG_H +# endif #endif #ifdef STDC diff --git a/zconf.h.in b/zconf.h.in index 5e1d68a0..32f53c8c 100644 --- a/zconf.h.in +++ b/zconf.h.in @@ -432,11 +432,19 @@ typedef uLong FAR uLongf; #endif #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H +# if ~(~HAVE_UNISTD_H + 0) == 0 && ~(~HAVE_UNISTD_H + 1) == 1 +# define Z_HAVE_UNISTD_H +# elif HAVE_UNISTD_H != 0 +# define Z_HAVE_UNISTD_H +# endif #endif #ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_STDARG_H +# if ~(~HAVE_STDARG_H + 0) == 0 && ~(~HAVE_STDARG_H + 1) == 1 +# define Z_HAVE_STDARG_H +# elif HAVE_STDARG_H != 0 +# define Z_HAVE_STDARG_H +# endif #endif #ifdef STDC