Skip to content

Commit

Permalink
Merge vestigial vsnprintf determination from zutil.h to gzguts.h.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
madler committed Oct 2, 2011
1 parent 0956bd2 commit 00c836e
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 91 deletions.
3 changes: 2 additions & 1 deletion as400/bndsrc
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 */
Expand Down
13 changes: 13 additions & 0 deletions as400/zlib.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
5 changes: 4 additions & 1 deletion contrib/vstudio/vc10/zlibvc.def
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ EXPORTS
zlibVersion @27
gzprintf @28
gzputc @29
gzgetc @30
gzseek @31
gzrewind @32
gztell @33
Expand Down Expand Up @@ -129,3 +128,7 @@ EXPORTS
inflatePrime @158
inflateReset2 @159
inflateUndermine @160

; zlib1 v1.2.6 added:
gzgetc_ @30
gzflags @162
5 changes: 4 additions & 1 deletion contrib/vstudio/vc9/zlibvc.def
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ EXPORTS
zlibVersion @27
gzprintf @28
gzputc @29
gzgetc @30
gzseek @31
gzrewind @32
gztell @33
Expand Down Expand Up @@ -129,3 +128,7 @@ EXPORTS
inflatePrime @158
inflateReset2 @159
inflateUndermine @160

; zlib1 v1.2.6 added:
gzgetc_ @30
gzflags @162
45 changes: 42 additions & 3 deletions gzguts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions gzwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 2 additions & 1 deletion win32/zlib.def
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ EXPORTS
gzputs
gzgets
gzputc
gzgetc
gzungetc
gzflush
gzseek
Expand Down Expand Up @@ -78,3 +77,5 @@ EXPORTS
inflateSyncPoint
get_crc_table
inflateUndermine
gzgetc_
gzflags
10 changes: 2 additions & 8 deletions zconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
10 changes: 2 additions & 8 deletions zconf.h.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
10 changes: 2 additions & 8 deletions zconf.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions zlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions zlib.map
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 1 addition & 25 deletions zutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 0 additions & 35 deletions zutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 00c836e

Please sign in to comment.