summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure185
-rw-r--r--crc32.c2
-rw-r--r--deflate.h2
-rw-r--r--gzguts.h30
-rw-r--r--gzlib.c14
-rw-r--r--gzwrite.c97
-rw-r--r--test/example.c12
-rw-r--r--test/minigzip.c23
-rw-r--r--trees.c6
-rw-r--r--zconf.h64
-rw-r--r--zconf.h.cmakein60
-rw-r--r--zconf.h.in60
-rw-r--r--zlib.h11
-rw-r--r--zutil.c67
-rw-r--r--zutil.h35
15 files changed, 65 insertions, 603 deletions
diff --git a/configure b/configure
index 6556df6937..4c15f72965 100755
--- a/configure
+++ b/configure
@@ -551,193 +551,26 @@ fi
echo >> configure.log
-# conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
-# (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
-# return value. The most secure result is vsnprintf() with a return value. snprintf() with a
-# return value is secure as well, but then gzprintf() will be limited to 20 arguments.
+# Check for ANSI C compliant compiler
cat > $test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
#include "zconf.h"
int main()
{
-#ifndef STDC
- choke me
-#endif
+#ifdef STDC
return 0;
+#endif
+ return 1;
}
EOF
if try $CC -c $CFLAGS $test.c; then
- echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
-
- echo >> configure.log
- cat > $test.c <<EOF
-#include <stdio.h>
-#include <stdarg.h>
-int mytest(const char *fmt, ...)
-{
- char buf[20];
- va_list ap;
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- return 0;
-}
-int main()
-{
- return (mytest("Hello%d\n", 1));
-}
-EOF
- if try $CC $CFLAGS -o $test $test.c; then
- echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
-
- echo >> configure.log
- cat >$test.c <<EOF
-#include <stdio.h>
-#include <stdarg.h>
-int mytest(const char *fmt, ...)
-{
- int n;
- char buf[20];
- va_list ap;
- va_start(ap, fmt);
- n = vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- return n;
-}
-int main()
-{
- return (mytest("Hello%d\n", 1));
-}
-EOF
-
- if try $CC -c $CFLAGS $test.c; then
- echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
- else
- CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
- SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
- echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
- echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
- echo " can build but will be open to possible string-format security" | tee -a configure.log
- echo " vulnerabilities." | tee -a configure.log
- fi
- else
- CFLAGS="$CFLAGS -DNO_vsnprintf"
- SFLAGS="$SFLAGS -DNO_vsnprintf"
- echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
- echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
- echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
- echo " vulnerabilities." | tee -a configure.log
-
- echo >> configure.log
- cat >$test.c <<EOF
-#include <stdio.h>
-#include <stdarg.h>
-int mytest(const char *fmt, ...)
-{
- int n;
- char buf[20];
- va_list ap;
- va_start(ap, fmt);
- n = vsprintf(buf, fmt, ap);
- va_end(ap);
- return n;
-}
-int main()
-{
- return (mytest("Hello%d\n", 1));
-}
-EOF
-
- if try $CC -c $CFLAGS $test.c; then
- echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
- else
- CFLAGS="$CFLAGS -DHAS_vsprintf_void"
- SFLAGS="$SFLAGS -DHAS_vsprintf_void"
- echo "Checking for return value of vsprintf()... No." | tee -a configure.log
- echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
- echo " can build but will be open to possible string-format security" | tee -a configure.log
- echo " vulnerabilities." | tee -a configure.log
- fi
- fi
+ echo "Checking for ANSI C compliant compiler... Yes." | tee -a configure.log
+ :
else
- echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
-
- echo >> configure.log
- cat >$test.c <<EOF
-#include <stdio.h>
-int mytest()
-{
- char buf[20];
- snprintf(buf, sizeof(buf), "%s", "foo");
- return 0;
-}
-int main()
-{
- return (mytest());
-}
-EOF
-
- if try $CC $CFLAGS -o $test $test.c; then
- echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
-
- echo >> configure.log
- cat >$test.c <<EOF
-#include <stdio.h>
-int mytest()
-{
- char buf[20];
- return snprintf(buf, sizeof(buf), "%s", "foo");
-}
-int main()
-{
- return (mytest());
-}
-EOF
-
- if try $CC -c $CFLAGS $test.c; then
- echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
- else
- CFLAGS="$CFLAGS -DHAS_snprintf_void"
- SFLAGS="$SFLAGS -DHAS_snprintf_void"
- echo "Checking for return value of snprintf()... No." | tee -a configure.log
- echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
- echo " can build but will be open to possible string-format security" | tee -a configure.log
- echo " vulnerabilities." | tee -a configure.log
- fi
- else
- CFLAGS="$CFLAGS -DNO_snprintf"
- SFLAGS="$SFLAGS -DNO_snprintf"
- echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
- echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
- echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
- echo " vulnerabilities." | tee -a configure.log
-
- echo >> configure.log
- cat >$test.c <<EOF
-#include <stdio.h>
-int mytest()
-{
- char buf[20];
- return sprintf(buf, "%s", "foo");
-}
-int main()
-{
- return (mytest());
-}
-EOF
-
- if try $CC -c $CFLAGS $test.c; then
- echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
- else
- CFLAGS="$CFLAGS -DHAS_sprintf_void"
- SFLAGS="$SFLAGS -DHAS_sprintf_void"
- echo "Checking for return value of sprintf()... No." | tee -a configure.log
- echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
- echo " can build but will be open to possible string-format security" | tee -a configure.log
- echo " vulnerabilities." | tee -a configure.log
- fi
- fi
+ echo "Checking for ANSI C compliant compiler... No." | tee -a configure.log
+ echo "Error: ANSI C compatible compiler needed, cannot continue." | tee -a configure.log
+ leave 1
fi
# see if we can hide zlib internal symbols that are linked between separate source files
diff --git a/crc32.c b/crc32.c
index 79c6c19500..23d815663e 100644
--- a/crc32.c
+++ b/crc32.c
@@ -28,7 +28,7 @@
# endif /* !DYNAMIC_CRC_TABLE */
#endif /* MAKECRCH */
-#include "zutil.h" /* for STDC definitions */
+#include "zutil.h"
#define local static
diff --git a/deflate.h b/deflate.h
index 027a075ab8..6a3ed97653 100644
--- a/deflate.h
+++ b/deflate.h
@@ -351,7 +351,7 @@ void ZLIB_INTERNAL bi_windup OF((deflate_state *s));
#ifndef DEBUG
/* Inline versions of _tr_tally for speed: */
-#if defined(GEN_TREES_H) || !defined(STDC)
+#if defined(GEN_TREES_H)
extern uch ZLIB_INTERNAL _length_code[];
extern uch ZLIB_INTERNAL _dist_code[];
#else
diff --git a/gzguts.h b/gzguts.h
index 63e5daaece..6303d5aa09 100644
--- a/gzguts.h
+++ b/gzguts.h
@@ -20,11 +20,9 @@
#include <stdio.h>
#include "zlib.h"
-#ifdef STDC
-# include <string.h>
-# include <stdlib.h>
-# include <limits.h>
-#endif
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
#include <fcntl.h>
#ifdef _WIN32
@@ -46,19 +44,11 @@
# define NO_GZCOMPRESS
#endif
-#if defined(STDC99) || defined(__CYGWIN__)
-# ifndef HAVE_VSNPRINTF
-# define HAVE_VSNPRINTF
-# endif
-#endif
-
-#ifndef HAVE_VSNPRINTF
-# 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
+#if !defined(STDC99) && !defined(__CYGWIN__) && defined(WIN32)
+# if !defined(vsnprintf)
+# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
+# define vsnprintf _vsnprintf
# endif
# endif
#endif
@@ -76,12 +66,6 @@
#endif
/* compile with -Dlocal if your debugger can't find static symbols */
-/* gz* functions always use library allocation functions */
-#ifndef STDC
- extern voidp malloc OF((uInt size));
- extern void free OF((voidpf ptr));
-#endif
-
/* get errno and strerror definition */
#if defined UNDER_CE
# include <windows.h>
diff --git a/gzlib.c b/gzlib.c
index fae202ef89..68ed4a6001 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -210,11 +210,7 @@ local gzFile gz_open(path, fd, mode)
*(state->path) = 0;
else
#endif
-#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
snprintf(state->path, len + 1, "%s", (const char *)path);
-#else
- strcpy(state->path, path);
-#endif
/* compute the flags for open() */
oflag =
@@ -290,11 +286,7 @@ gzFile ZEXPORT gzdopen(fd, mode)
if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
return NULL;
-#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd); /* for debugging */
-#else
- sprintf(path, "<fd:%d>", fd); /* for debugging */
-#endif
gz = gz_open(path, fd, mode);
free(path);
return gz;
@@ -603,14 +595,8 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
state->err = Z_MEM_ERROR;
return;
}
-#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
"%s%s%s", state->path, ": ", msg);
-#else
- strcpy(state->msg, state->path);
- strcat(state->msg, ": ");
- strcat(state->msg, msg);
-#endif
return;
}
diff --git a/gzwrite.c b/gzwrite.c
index aa767fbf63..2cbf1e4971 100644
--- a/gzwrite.c
+++ b/gzwrite.c
@@ -303,7 +303,6 @@ int ZEXPORT gzputs(file, str)
return ret == 0 && len != 0 ? -1 : ret;
}
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
#include <stdarg.h>
/* -- see zlib.h -- */
@@ -341,22 +340,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
/* do the printf() into the input buffer, put length in len */
size = (int)(state->size);
state->in[size - 1] = 0;
-#ifdef NO_vsnprintf
-# ifdef HAS_vsprintf_void
- (void)vsprintf((char *)(state->in), format, va);
- for (len = 0; len < size; len++)
- if (state->in[len] == 0) break;
-# else
- len = vsprintf((char *)(state->in), format, va);
-# endif
-#else
-# ifdef HAS_vsnprintf_void
- (void)vsnprintf((char *)(state->in), size, format, va);
- len = strlen((char *)(state->in));
-# else
len = vsnprintf((char *)(state->in), size, format, va);
-# endif
-#endif
/* check that printf() results fit in buffer */
if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
@@ -380,87 +364,6 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
return ret;
}
-#else /* !STDC && !Z_HAVE_STDARG_H */
-
-/* -- see zlib.h -- */
-int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
- a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
- gzFile file;
- const char *format;
- int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
- a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
-{
- int size, len;
- gz_statep state;
- z_streamp strm;
-
- /* get internal structure */
- if (file == NULL)
- return -1;
- state = (gz_statep)file;
- strm = &(state->strm);
-
- /* check that can really pass pointer in ints */
- if (sizeof(int) != sizeof(void *))
- return 0;
-
- /* check that we're writing and that there's no error */
- if (state->mode != GZ_WRITE || state->err != Z_OK)
- return 0;
-
- /* make sure we have some buffer space */
- if (state->size == 0 && gz_init(state) == -1)
- return 0;
-
- /* check for seek request */
- if (state->seek) {
- state->seek = 0;
- if (gz_zero(state, state->skip) == -1)
- return 0;
- }
-
- /* consume whatever's left in the input buffer */
- if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
- return 0;
-
- /* do the printf() into the input buffer, put length in len */
- size = (int)(state->size);
- state->in[size - 1] = 0;
-#ifdef NO_snprintf
-# ifdef HAS_sprintf_void
- sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
- for (len = 0; len < size; len++)
- if (state->in[len] == 0) break;
-# else
- len = sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-# endif
-#else
-# ifdef HAS_snprintf_void
- snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
- len = strlen((char *)(state->in));
-# else
- len = snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6,
- a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
- a19, a20);
-# endif
-#endif
-
- /* check that printf() results fit in buffer */
- if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
- return 0;
-
- /* update buffer and position, defer compression until needed */
- strm->avail_in = (unsigned)len;
- strm->next_in = state->in;
- state->x.pos += len;
- return len;
-}
-
-#endif
-
/* -- see zlib.h -- */
int ZEXPORT gzflush(file, flush)
gzFile file;
diff --git a/test/example.c b/test/example.c
index 138a699bd5..e9353da1b5 100644
--- a/test/example.c
+++ b/test/example.c
@@ -8,16 +8,10 @@
#include "zlib.h"
#include <stdio.h>
-#ifdef STDC
-# include <string.h>
-# include <stdlib.h>
-#endif
+#include <string.h>
+#include <stdlib.h>
-#if defined(VMS) || defined(RISCOS)
-# define TESTFILE "foo-gz"
-#else
-# define TESTFILE "foo.gz"
-#endif
+#define TESTFILE "foo.gz"
#define CHECK_ERR(err, msg) { \
if (err != Z_OK) { \
diff --git a/test/minigzip.c b/test/minigzip.c
index a3640bfab2..f92aad7280 100644
--- a/test/minigzip.c
+++ b/test/minigzip.c
@@ -17,10 +17,8 @@
#include "zlib.h"
#include <stdio.h>
-#ifdef STDC
-# include <string.h>
-# include <stdlib.h>
-#endif
+#include <string.h>
+#include <stdlib.h>
#ifdef USE_MMAP
# include <sys/types.h>
@@ -462,12 +460,7 @@ void file_compress(file, mode)
exit(1);
}
-#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
snprintf(outfile, sizeof(outfile), "%s%s", file, GZ_SUFFIX);
-#else
- strcpy(outfile, file);
- strcat(outfile, GZ_SUFFIX);
-#endif
in = fopen(file, "rb");
if (in == NULL) {
@@ -502,11 +495,7 @@ void file_uncompress(file)
exit(1);
}
-#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
snprintf(buf, sizeof(buf), "%s", file);
-#else
- strcpy(buf, file);
-#endif
if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) {
infile = file;
@@ -515,11 +504,7 @@ void file_uncompress(file)
} else {
outfile = file;
infile = buf;
-#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
snprintf(buf + len, sizeof(buf) - len, "%s", GZ_SUFFIX);
-#else
- strcat(infile, GZ_SUFFIX);
-#endif
}
in = gzopen(infile, "rb");
if (in == NULL) {
@@ -557,11 +542,7 @@ int main(argc, argv)
gzFile file;
char *bname, outmode[20];
-#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
snprintf(outmode, sizeof(outmode), "%s", "wb6 ");
-#else
- strcpy(outmode, "wb6 ");
-#endif
prog = argv[0];
bname = strrchr(argv[0], '/');
diff --git a/trees.c b/trees.c
index 9197c49f6f..69c092c0ab 100644
--- a/trees.c
+++ b/trees.c
@@ -77,7 +77,7 @@ local const uch bl_order[BL_CODES]
#define DIST_CODE_LEN 512 /* see definition of array dist_code below */
-#if defined(GEN_TREES_H) || !defined(STDC)
+#if defined(GEN_TREES_H)
/* non ANSI compilers may not accept trees.h */
ZLIB_INTERNAL ct_data static_ltree[L_CODES+2];
@@ -160,7 +160,7 @@ local void gen_trees_header OF((void));
*/
local void tr_static_init()
{
-#if defined(GEN_TREES_H) || !defined(STDC)
+#if defined(GEN_TREES_H)
static int static_init_done = 0;
int n; /* iterates over tree elements */
int bits; /* bit counter */
@@ -237,7 +237,7 @@ local void tr_static_init()
# ifdef GEN_TREES_H
gen_trees_header();
# endif
-#endif /* defined(GEN_TREES_H) || !defined(STDC) */
+#endif /* defined(GEN_TREES_H) */
}
/* ===========================================================================
diff --git a/zconf.h b/zconf.h
index 3d6fc37fc6..e1b73601ac 100644
--- a/zconf.h
+++ b/zconf.h
@@ -161,34 +161,17 @@
# endif
#endif
+#ifndef STDC
+# define STDC
+#endif
+
#ifdef __STDC_VERSION__
-# ifndef STDC
-# define STDC
-# endif
# if __STDC_VERSION__ >= 199901L
# ifndef STDC99
# define STDC99
# endif
# endif
#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(WINDOWS) || defined(WIN32))
-# define STDC
-#endif
-#if !defined(STDC) && defined(__HOS_AIX__)
-# define STDC
-#endif
-
-#ifndef STDC
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-# define const /* note: need a more gentle solution here */
-# endif
-#endif
#if defined(ZLIB_CONST) && !defined(z_const)
# define z_const const
@@ -231,19 +214,11 @@
/* Type declarations */
#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
+# define OF(args) args
#endif
#ifndef Z_ARG /* function prototypes for stdarg */
-# if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# define Z_ARG(args) args
-# else
-# define Z_ARG(args) ()
-# endif
+# define Z_ARG(args) args
#endif
#if defined(WINDOWS) || defined(WIN32)
@@ -306,17 +281,11 @@ typedef int intf;
typedef uInt uIntf;
typedef uLong uLongf;
-#ifdef STDC
- typedef void const *voidpc;
- typedef void *voidpf;
- typedef void *voidp;
-#else
- typedef Byte const *voidpc;
- typedef Byte *voidpf;
- typedef Byte *voidp;
-#endif
+typedef void const *voidpc;
+typedef void *voidpf;
+typedef void *voidp;
-#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
+#if !defined(Z_U4) && !defined(Z_SOLO)
# include <limits.h>
# if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned
@@ -341,16 +310,9 @@ typedef uLong uLongf;
# define Z_HAVE_STDARG_H
#endif
-#ifdef STDC
-# ifndef Z_SOLO
-# include <sys/types.h> /* for off_t */
-# endif
-#endif
-
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# ifndef Z_SOLO
-# include <stdarg.h> /* for va_list */
-# endif
+#ifndef Z_SOLO
+# include <sys/types.h> /* for off_t */
+# include <stdarg.h> /* for va_list */
#endif
#ifdef _WIN32
diff --git a/zconf.h.cmakein b/zconf.h.cmakein
index 0bd76d8e81..c1e9354658 100644
--- a/zconf.h.cmakein
+++ b/zconf.h.cmakein
@@ -164,33 +164,12 @@
#endif
#ifdef __STDC_VERSION__
-# ifndef STDC
-# define STDC
-# endif
# if __STDC_VERSION__ >= 199901L
# ifndef STDC99
# define STDC99
# endif
# endif
#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(WINDOWS) || defined(WIN32))
-# define STDC
-#endif
-#if !defined(STDC) && defined(__HOS_AIX__)
-# define STDC
-#endif
-
-#ifndef STDC
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-# define const /* note: need a more gentle solution here */
-# endif
-#endif
#if defined(ZLIB_CONST) && !defined(z_const)
# define z_const const
@@ -233,19 +212,11 @@
/* Type declarations */
#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
+# define OF(args) args
#endif
#ifndef Z_ARG /* function prototypes for stdarg */
-# if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# define Z_ARG(args) args
-# else
-# define Z_ARG(args) ()
-# endif
+# define Z_ARG(args) args
#endif
#if defined(WINDOWS) || defined(WIN32)
@@ -308,17 +279,11 @@ typedef int intf;
typedef uInt uIntf;
typedef uLong uLongf;
-#ifdef STDC
- typedef void const *voidpc;
- typedef void *voidpf;
- typedef void *voidp;
-#else
- typedef Byte const *voidpc;
- typedef Byte *voidpf;
- typedef Byte *voidp;
-#endif
+typedef void const *voidpc;
+typedef void *voidpf;
+typedef void *voidp;
-#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
+#if !defined(Z_U4) && !defined(Z_SOLO)
# include <limits.h>
# if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned
@@ -343,16 +308,9 @@ typedef uLong uLongf;
# define Z_HAVE_STDARG_H
#endif
-#ifdef STDC
-# ifndef Z_SOLO
-# include <sys/types.h> /* for off_t */
-# endif
-#endif
-
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# ifndef Z_SOLO
-# include <stdarg.h> /* for va_list */
-# endif
+#ifndef Z_SOLO
+# include <sys/types.h> /* for off_t */
+# include <stdarg.h> /* for va_list */
#endif
#ifdef _WIN32
diff --git a/zconf.h.in b/zconf.h.in
index 3d6fc37fc6..4454668115 100644
--- a/zconf.h.in
+++ b/zconf.h.in
@@ -162,33 +162,12 @@
#endif
#ifdef __STDC_VERSION__
-# ifndef STDC
-# define STDC
-# endif
# if __STDC_VERSION__ >= 199901L
# ifndef STDC99
# define STDC99
# endif
# endif
#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(WINDOWS) || defined(WIN32))
-# define STDC
-#endif
-#if !defined(STDC) && defined(__HOS_AIX__)
-# define STDC
-#endif
-
-#ifndef STDC
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-# define const /* note: need a more gentle solution here */
-# endif
-#endif
#if defined(ZLIB_CONST) && !defined(z_const)
# define z_const const
@@ -231,19 +210,11 @@
/* Type declarations */
#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
+# define OF(args) args
#endif
#ifndef Z_ARG /* function prototypes for stdarg */
-# if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# define Z_ARG(args) args
-# else
-# define Z_ARG(args) ()
-# endif
+# define Z_ARG(args) args
#endif
#if defined(WINDOWS) || defined(WIN32)
@@ -306,17 +277,11 @@ typedef int intf;
typedef uInt uIntf;
typedef uLong uLongf;
-#ifdef STDC
- typedef void const *voidpc;
- typedef void *voidpf;
- typedef void *voidp;
-#else
- typedef Byte const *voidpc;
- typedef Byte *voidpf;
- typedef Byte *voidp;
-#endif
+typedef void const *voidpc;
+typedef void *voidpf;
+typedef void *voidp;
-#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
+#if !defined(Z_U4) && !defined(Z_SOLO)
# include <limits.h>
# if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned
@@ -341,16 +306,9 @@ typedef uLong uLongf;
# define Z_HAVE_STDARG_H
#endif
-#ifdef STDC
-# ifndef Z_SOLO
-# include <sys/types.h> /* for off_t */
-# endif
-#endif
-
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# ifndef Z_SOLO
-# include <stdarg.h> /* for va_list */
-# endif
+#ifndef Z_SOLO
+# include <sys/types.h> /* for off_t */
+# include <stdarg.h> /* for va_list */
#endif
#ifdef _WIN32
diff --git a/zlib.h b/zlib.h
index c580db3b3a..7936482137 100644
--- a/zlib.h
+++ b/zlib.h
@@ -1741,15 +1741,10 @@ ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
#if defined(_WIN32) && !defined(Z_SOLO)
-ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
- const char *mode));
+ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, const char *mode));
#endif
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# ifndef Z_SOLO
-ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file,
- const char *format,
- va_list va));
-# endif
+#ifndef Z_SOLO
+ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, const char *format, va_list va));
#endif
#ifdef __cplusplus
diff --git a/zutil.c b/zutil.c
index 35940c7f34..cdbd7a5e2b 100644
--- a/zutil.c
+++ b/zutil.c
@@ -88,30 +88,6 @@ 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;
}
@@ -147,53 +123,10 @@ const char * ZEXPORT zError(err)
int errno = 0;
#endif
-#ifndef HAVE_MEMCPY
-
-void ZLIB_INTERNAL zmemcpy(dest, source, len)
- Bytef* dest;
- const Bytef* source;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = *source++; /* ??? to be unrolled */
- } while (--len != 0);
-}
-
-int ZLIB_INTERNAL zmemcmp(s1, s2, len)
- const Bytef* s1;
- const Bytef* s2;
- uInt len;
-{
- uInt j;
-
- for (j = 0; j < len; j++) {
- if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
- }
- return 0;
-}
-
-void ZLIB_INTERNAL zmemzero(dest, len)
- Bytef* dest;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = 0; /* ??? to be unrolled */
- } while (--len != 0);
-}
-#endif
-
#ifndef Z_SOLO
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
-#ifndef STDC
-extern voidp malloc OF((uInt size));
-extern voidp calloc OF((uInt items, uInt size));
-extern void free OF((voidpf ptr));
-#endif
-
voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
voidpf opaque;
unsigned items;
diff --git a/zutil.h b/zutil.h
index 62ff87fa18..8b9516d3c0 100644
--- a/zutil.h
+++ b/zutil.h
@@ -21,7 +21,7 @@
#include "zlib.h"
-#if defined(STDC) && !defined(Z_SOLO)
+#ifndef Z_SOLO
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
# include <stddef.h>
# endif
@@ -140,34 +140,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* functions */
-#if defined(pyr) || defined(Z_SOLO)
-# define NO_MEMCPY
-#endif
-#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
- /* Use our own functions for small and medium model with MSC <= 5.0.
- * You may have to use the same strategy for Borland C (untested).
- * The __SC__ check is for Symantec.
- */
-# define NO_MEMCPY
-#endif
-#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
-# define HAVE_MEMCPY
-#endif
-#ifdef HAVE_MEMCPY
-# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
-# define zmemcpy _fmemcpy
-# define zmemcmp _fmemcmp
-# define zmemzero(dest, len) _fmemset(dest, 0, len)
-# else
-# define zmemcpy memcpy
-# define zmemcmp memcmp
-# define zmemzero(dest, len) memset(dest, 0, len)
-# endif
-#else
- void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
- int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
- void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
-#endif
+#define zmemcpy memcpy
+#define zmemcmp memcmp
+#define zmemzero(dest, len) memset(dest, 0, len)
/* Diagnostic functions */
#ifdef DEBUG
@@ -223,7 +198,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define ZSWAP32(q) _bswap(q)
#else
-#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
+# define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
#endif /* ZSWAP32 */