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.
This commit is contained in:
Mark Adler 2011-10-02 11:15:00 -07:00
parent 0956bd23dd
commit 00c836e325
14 changed files with 111 additions and 91 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -31,9 +31,48 @@
# define NO_GZCOMPRESS
#endif
#ifdef _MSC_VER
# include <io.h>
# 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 <io.h>
# 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

View File

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

View File

@ -42,7 +42,6 @@ EXPORTS
gzputs
gzgets
gzputc
gzgetc
gzungetc
gzflush
gzseek
@ -78,3 +77,5 @@ EXPORTS
inflateSyncPoint
get_crc_table
inflateUndermine
gzgetc_
gzflags

10
zconf.h
View File

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

View File

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

View File

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

1
zlib.h
View File

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

View File

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

26
zutil.c
View File

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

35
zutil.h
View File

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