]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Remove workarounds for non-ANSI-C compatible compilers (Part 1)
authorhansr <hk-git@circlestorm.org>
Sun, 12 Oct 2014 10:38:06 +0000 (12:38 +0200)
committerhansr <hk-git@circlestorm.org>
Sun, 12 Oct 2014 10:38:06 +0000 (12:38 +0200)
15 files changed:
configure
crc32.c
deflate.h
gzguts.h
gzlib.c
gzwrite.c
test/example.c
test/minigzip.c
trees.c
zconf.h
zconf.h.cmakein
zconf.h.in
zlib.h
zutil.c
zutil.h

index 6556df693751d29f6461ad0938fddf7ba0899593..4c15f7296514acff23e06ef6773eb73bff0931cc 100755 (executable)
--- 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 79c6c19500416cafc92b74a04d6a4153b9f7c561..23d815663eb0af8f61afed124f0a0d079662e2b8 100644 (file)
--- 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
 
index 027a075ab817a1f08ee7ddc9a101663247b46fbb..6a3ed97653ddc5d665d9d5ddc5139e9e548808c1 100644 (file)
--- 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
index 63e5daaece441fd037f5623329df315e2cad60e1..6303d5aa09e762511a62ad22acc85118e09967fb 100644 (file)
--- a/gzguts.h
+++ b/gzguts.h
 
 #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
 #  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
 #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 fae202ef8905a3c99e4b71d756a45d55f9b1c163..68ed4a600196ecfd513392df1af127e43accd6a9 100644 (file)
--- 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;
 }
 
index aa767fbf63ec7ddd2f5863d05c03f647303a101f..2cbf1e497115c93fc16911beedf2b77bb2cf167f 100644 (file)
--- 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;
index 138a699bd53e60250b3eed61e631175ef0452630..e9353da1b5e653457d9fe06034959f5f4fcf748e 100644 (file)
@@ -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) { \
index a3640bfab29fe3e3a6a47a3aebd2e92bdec7899c..f92aad72808ccb51f8133fc2e5b4de495a4aa9ea 100644 (file)
 #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 9197c49f6fc7b2574ecd4205580049253ff4d56b..69c092c0abd8a7417487365d618ce1e3836cc27a 100644 (file)
--- 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 3d6fc37fc6327da78c64a7507d9f9c8e50f44cd6..e1b73601acc2d60ec5575631766fd29beb755da7 100644 (file)
--- a/zconf.h
+++ b/zconf.h
 #  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
                         /* 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
index 0bd76d8e814a0b2ec2b49a4dcd3df0c47dcbe183..c1e93546582a8fe428a50db38aec0add0f3ac208 100644 (file)
 #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
                         /* 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
index 3d6fc37fc6327da78c64a7507d9f9c8e50f44cd6..44546681153243bc83f873d2b70a4cd7bf89132b 100644 (file)
 #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
                         /* 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 c580db3b3a539539aca5eb5f56de2c0370ad0603..7936482137ded0f3b6211e4d4eaf79bb2d132846 100644 (file)
--- 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 35940c7f34674862d7f401a24736524141d52ec9..cdbd7a5e2bae814b09f171709a469ced9fc23873 100644 (file)
--- a/zutil.c
+++ b/zutil.c
@@ -87,30 +87,6 @@ uLong ZEXPORT zlibCompileFlags()
 #endif
 #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 62ff87fa18644f48c59bdf972c743308e4e298ad..8b9516d3c02eff97fd06cae09af4d75590642290 100644 (file)
--- 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 */