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.
This commit is contained in:
Matt Oliver 2020-05-10 01:55:09 +10:00
parent d71dc66fa8
commit 88baa583b9
2 changed files with 20 additions and 4 deletions

View File

@ -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

View File

@ -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