From 00c836e325a07419f5d855e2f275500a37cb27d2 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Sun, 2 Oct 2011 11:15:00 -0700 Subject: [PATCH] Merge vestigial vsnprintf determination from zutil.h to gzguts.h. This also moves some of the same from zconf.h to gzguts.h. A new function, gzflags(), was created to pass the compilation flags related to vsnprintf usage back to zlibCompileFlags() in zutil.c. In the process, various compiler configuration files were updated to include gzflags(), as well as the new gzgetc_() function added when the gzgetc() macro was introduced in a previous patch. --- as400/bndsrc | 3 ++- as400/zlib.inc | 13 ++++++++++ contrib/vstudio/vc10/zlibvc.def | 5 +++- contrib/vstudio/vc9/zlibvc.def | 5 +++- gzguts.h | 45 ++++++++++++++++++++++++++++++--- gzwrite.c | 31 +++++++++++++++++++++++ win32/zlib.def | 3 ++- zconf.h | 10 ++------ zconf.h.cmakein | 10 ++------ zconf.h.in | 10 ++------ zlib.h | 1 + zlib.map | 5 ++++ zutil.c | 26 +------------------ zutil.h | 35 ------------------------- 14 files changed, 111 insertions(+), 91 deletions(-) diff --git a/as400/bndsrc b/as400/bndsrc index 06c3f43..dad2bc9 100644 --- a/as400/bndsrc +++ b/as400/bndsrc @@ -52,7 +52,6 @@ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB') EXPORT SYMBOL("gzputs") EXPORT SYMBOL("gzgets") EXPORT SYMBOL("gzputc") - EXPORT SYMBOL("gzgetc") EXPORT SYMBOL("gzflush") EXPORT SYMBOL("gzseek") EXPORT SYMBOL("gzrewind") @@ -170,6 +169,8 @@ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB') /********************************************************************/ EXPORT SYMBOL("gzclose_w") + EXPORT SYMBOL("gzgetc_") + EXPORT SYMBOL("gzflags") /********************************************************************/ /* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */ diff --git a/as400/zlib.inc b/as400/zlib.inc index 71b0e56..41ff616 100644 --- a/as400/zlib.inc +++ b/as400/zlib.inc @@ -182,6 +182,17 @@ D buf 32767 options(*varsize) Read buffer D len 10i 0 value Buffer length * + D gzputc PR 10i 0 extproc('gzputc') + D file value like(gzFile) File pointer + D c 10I 0 value Character to write + * + D gzgetc_ PR 10i 0 extproc('gzgetc_') + D file value like(gzFile) File pointer + * + D gzungetc PR 10i 0 extproc('gzungetc') + D c 10I 0 value Character to push + D file value like(gzFile) File pointer + * D gzflush PR 10i 0 extproc('gzflush') D file value like(gzFile) File pointer D flush 10I 0 value Type of flush @@ -420,4 +431,6 @@ D strm like(z_stream) Expansion stream D arg 10I 0 value Error code * + D gzflags PR 10U 0 extproc('gzflags') + * /endif diff --git a/contrib/vstudio/vc10/zlibvc.def b/contrib/vstudio/vc10/zlibvc.def index ad8b4af..0d6dc38 100644 --- a/contrib/vstudio/vc10/zlibvc.def +++ b/contrib/vstudio/vc10/zlibvc.def @@ -33,7 +33,6 @@ EXPORTS zlibVersion @27 gzprintf @28 gzputc @29 - gzgetc @30 gzseek @31 gzrewind @32 gztell @33 @@ -129,3 +128,7 @@ EXPORTS inflatePrime @158 inflateReset2 @159 inflateUndermine @160 + +; zlib1 v1.2.6 added: + gzgetc_ @30 + gzflags @162 diff --git a/contrib/vstudio/vc9/zlibvc.def b/contrib/vstudio/vc9/zlibvc.def index ad8b4af..0d6dc38 100644 --- a/contrib/vstudio/vc9/zlibvc.def +++ b/contrib/vstudio/vc9/zlibvc.def @@ -33,7 +33,6 @@ EXPORTS zlibVersion @27 gzprintf @28 gzputc @29 - gzgetc @30 gzseek @31 gzrewind @32 gztell @33 @@ -129,3 +128,7 @@ EXPORTS inflatePrime @158 inflateReset2 @159 inflateUndermine @160 + +; zlib1 v1.2.6 added: + gzgetc_ @30 + gzflags @162 diff --git a/gzguts.h b/gzguts.h index c226a09..8193451 100644 --- a/gzguts.h +++ b/gzguts.h @@ -31,9 +31,48 @@ # define NO_GZCOMPRESS #endif -#ifdef _MSC_VER -# include -# define vsnprintf _vsnprintf +#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif + +#if defined(__CYGWIN__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif + +#ifndef HAVE_VSNPRINTF +# ifdef MSDOS +/* vsnprintf may exist on some MS-DOS compilers (DJGPP?), + but for now we just assume it doesn't. */ +# define NO_vsnprintf +# endif +# ifdef __TURBOC__ +# define NO_vsnprintf +# endif +# ifdef WIN32 +/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ +# if !defined(vsnprintf) && !defined(NO_vsnprintf) +# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) +# include +# define vsnprintf _vsnprintf +# endif +# endif +# endif +# ifdef __SASC +# define NO_vsnprintf +# endif +# ifdef VMS +# define NO_vsnprintf +# endif +# ifdef __OS400__ +# define NO_vsnprintf +# endif +# ifdef __MVS__ +# define NO_vsnprintf +# endif #endif #ifndef local diff --git a/gzwrite.c b/gzwrite.c index 8eeca4e..1d28807 100644 --- a/gzwrite.c +++ b/gzwrite.c @@ -536,3 +536,34 @@ int ZEXPORT gzclose_w(file) free(state); return ret; } + +/* used by zlibVersion() to get the vsnprintf story from the horse's mouth */ +unsigned long ZEXPORT gzflags() +{ + unsigned long flags = 0; +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifdef NO_vsnprintf + flags += 1L << 25; +# ifdef HAS_vsprintf_void + flags += 1L << 26; +# endif +# else +# ifdef HAS_vsnprintf_void + flags += 1L << 26; +# endif +# endif +#else + flags += 1L << 24; +# ifdef NO_snprintf + flags += 1L << 25; +# ifdef HAS_sprintf_void + flags += 1L << 26; +# endif +# else +# ifdef HAS_snprintf_void + flags += 1L << 26; +# endif +# endif +#endif + return flags; +} diff --git a/win32/zlib.def b/win32/zlib.def index eee109f..93ea8bf 100644 --- a/win32/zlib.def +++ b/win32/zlib.def @@ -42,7 +42,6 @@ EXPORTS gzputs gzgets gzputc - gzgetc gzungetc gzflush gzseek @@ -78,3 +77,5 @@ EXPORTS inflateSyncPoint get_crc_table inflateUndermine + gzgetc_ + gzflags diff --git a/zconf.h b/zconf.h index c8c2aaa..bcb7615 100644 --- a/zconf.h +++ b/zconf.h @@ -61,8 +61,10 @@ # define gzdopen z_gzdopen # define gzeof z_gzeof # define gzerror z_gzerror +# define gzflags z_gzflags # define gzflush z_gzflush # define gzgetc z_gzgetc +# define gzgetc_ z_gzgetc_ # define gzgets z_gzgets # define gzoffset z_gzoffset # define gzoffset64 z_gzoffset64 @@ -422,14 +424,6 @@ typedef uLong FAR uLongf; #endif #endif -#if defined(__OS400__) -# define NO_vsnprintf -#endif - -#if defined(__MVS__) -# define NO_vsnprintf -#endif - /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) #pragma map(deflateInit_,"DEIN") diff --git a/zconf.h.cmakein b/zconf.h.cmakein index 0a36a72..29680aa 100644 --- a/zconf.h.cmakein +++ b/zconf.h.cmakein @@ -63,8 +63,10 @@ # define gzdopen z_gzdopen # define gzeof z_gzeof # define gzerror z_gzerror +# define gzflags z_gzflags # define gzflush z_gzflush # define gzgetc z_gzgetc +# define gzgetc_ z_gzgetc_ # define gzgets z_gzgets # define gzoffset z_gzoffset # define gzoffset64 z_gzoffset64 @@ -424,14 +426,6 @@ typedef uLong FAR uLongf; #endif #endif -#if defined(__OS400__) -# define NO_vsnprintf -#endif - -#if defined(__MVS__) -# define NO_vsnprintf -#endif - /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) #pragma map(deflateInit_,"DEIN") diff --git a/zconf.h.in b/zconf.h.in index c8c2aaa..bcb7615 100644 --- a/zconf.h.in +++ b/zconf.h.in @@ -61,8 +61,10 @@ # define gzdopen z_gzdopen # define gzeof z_gzeof # define gzerror z_gzerror +# define gzflags z_gzflags # define gzflush z_gzflush # define gzgetc z_gzgetc +# define gzgetc_ z_gzgetc_ # define gzgets z_gzgets # define gzoffset z_gzoffset # define gzoffset64 z_gzoffset64 @@ -422,14 +424,6 @@ typedef uLong FAR uLongf; #endif #endif -#if defined(__OS400__) -# define NO_vsnprintf -#endif - -#if defined(__MVS__) -# define NO_vsnprintf -#endif - /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) #pragma map(deflateInit_,"DEIN") diff --git a/zlib.h b/zlib.h index 16b20ce..371af26 100644 --- a/zlib.h +++ b/zlib.h @@ -1660,6 +1660,7 @@ ZEXTERN const char * ZEXPORT zError OF((int)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); +ZEXTERN unsigned long ZEXPORT gzflags OF((void)); #ifdef __cplusplus } diff --git a/zlib.map b/zlib.map index f65a125..627133d 100644 --- a/zlib.map +++ b/zlib.map @@ -70,3 +70,8 @@ ZLIB_1.2.3.5 { ZLIB_1.2.5.1 { deflatePending; } ZLIB_1.2.3.5; + +ZLIB_1.2.5.2 { + gzflags; + gzgetc_; +} ZLIB_1.2.5.1; diff --git a/zutil.c b/zutil.c index 2ccee81..8f697cc 100644 --- a/zutil.c +++ b/zutil.c @@ -85,31 +85,7 @@ uLong ZEXPORT zlibCompileFlags() #ifdef FASTEST flags += 1L << 21; #endif -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifdef NO_vsnprintf - flags += 1L << 25; -# ifdef HAS_vsprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_vsnprintf_void - flags += 1L << 26; -# endif -# endif -#else - flags += 1L << 24; -# ifdef NO_snprintf - flags += 1L << 25; -# ifdef HAS_sprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_snprintf_void - flags += 1L << 26; -# endif -# endif -#endif - return flags; + return flags + gzflags(); } #ifdef DEBUG diff --git a/zutil.h b/zutil.h index c199b20..86d64bc 100644 --- a/zutil.h +++ b/zutil.h @@ -177,41 +177,6 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* functions */ -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#if defined(__CYGWIN__) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#ifndef HAVE_VSNPRINTF -# ifdef MSDOS - /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ -# define NO_vsnprintf -# endif -# ifdef __TURBOC__ -# define NO_vsnprintf -# endif -# ifdef WIN32 - /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -# if !defined(vsnprintf) && !defined(NO_vsnprintf) -# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) -# define vsnprintf _vsnprintf -# endif -# endif -# endif -# ifdef __SASC -# define NO_vsnprintf -# endif -#endif -#ifdef VMS -# define NO_vsnprintf -#endif - #if defined(pyr) # define NO_MEMCPY #endif