maint: remove lots of obsolete #if...HAVE_* checks
authorJim Meyering <meyering@redhat.com>
Sun, 20 Dec 2009 18:41:39 +0000 (19:41 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 30 Dec 2009 16:33:55 +0000 (17:33 +0100)
Remove many always-true cpp tests like #ifdef HAVE_UNISTD_H,
 #ifdef HAVE_FCNTL_H and #ifdef SSIZE_MAX.
* gzip.c: As above.
* gzip.h: Likewise.
* inflate.c: Likewise.
* tailor.h: Likewise.
* unlzw.c: Likewise.
* util.c: Likewise.
* zip.c: Likewise.

gzip.c
gzip.h
inflate.c
tailor.h
unlzw.c
util.c
zip.c

diff --git a/gzip.c b/gzip.c
index cdaaab31085f4f166325e49b3c911c723017a5a9..4ecfdaf2e889e1e49796e9e0005ca6e2b1f61ad7 100644 (file)
--- a/gzip.c
+++ b/gzip.c
@@ -74,23 +74,11 @@ static char const *const license_msg[] = {
 
                /* configuration */
 
-#ifdef HAVE_FCNTL_H
-#  include <fcntl.h>
-#endif
-
-#ifdef HAVE_LIMITS_H
-#  include <limits.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#  include <unistd.h>
-#endif
-
-#if defined STDC_HEADERS || defined HAVE_STDLIB_H
-#  include <stdlib.h>
-#else
-   extern int errno;
-#endif
+#include <fcntl.h>
+#include <limits.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
 
 #ifndef NO_DIR
 # define NO_DIR 0
diff --git a/gzip.h b/gzip.h
index 7addad970b05feb3d53f6489adf94994e9fd5b37..92b4087740642d62fbd986b43a951bc54fc08764 100644 (file)
--- a/gzip.h
+++ b/gzip.h
 #include <stdio.h>
 #include <sys/types.h> /* for off_t */
 #include <time.h>
-#if defined HAVE_STRING_H || defined STDC_HEADERS
-#  include <string.h>
-#  if !defined STDC_HEADERS && defined HAVE_MEMORY_H && !defined __GNUC__
-#    include <memory.h>
-#  endif
-#  define memzero(s, n)     memset ((voidp)(s), 0, (n))
-#else
-#  include <strings.h>
-#  define strchr            index
-#  define strrchr           rindex
-#  define memcpy(d, s, n)   bcopy((s), (d), (n))
-#  define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
-#  define memzero(s, n)     bzero((s), (n))
-#endif
+#include <string.h>
+#define memzero(s, n) memset ((voidp)(s), 0, (n))
 
 #ifndef RETSIGTYPE
 #  define RETSIGTYPE void
index b72c187ee38315c604b236357bee2d33f030f299..8167f20adff867a4d88a1576545ac475010c8796 100644 (file)
--- a/inflate.c
+++ b/inflate.c
 #include <config.h>
 #include "tailor.h"
 
-#if defined STDC_HEADERS || defined HAVE_STDLIB_H
-#  include <stdlib.h>
-#endif
+#include <stdlib.h>
 
 #include "gzip.h"
 #define slide window
index 3cb16ee50ac7a650d93c7d99eea96827dd9275c4..cd3be11f130b400c4a17b1df64ef2deadbbdb33b 100644 (file)
--- a/tailor.h
+++ b/tailor.h
 #endif
 
 #if defined(ATARI) || defined(atarist)
-#  ifndef STDC_HEADERS
-#    define STDC_HEADERS
-#    define HAVE_UNISTD_H
-#    define HAVE_DIRENT_H
-#  endif
 #  define ASMV
 #  define OS_CODE  0x05
 #  ifdef TOSFS
diff --git a/unlzw.c b/unlzw.c
index 5cf95b530f517c5ed256d3eaa71ef424bab30c4b..fb9ff76dc92281d0fcf7c65095db3ef54aa28cb6 100644 (file)
--- a/unlzw.c
+++ b/unlzw.c
 #include <config.h>
 #include "tailor.h"
 
-#ifdef HAVE_UNISTD_H
-#  include <unistd.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#  include <fcntl.h>
-#endif
+#include <unistd.h>
+#include <fcntl.h>
 
 #include "gzip.h"
 #include "lzw.h"
diff --git a/util.c b/util.c
index d0d7774d9fbf4e624cf96bbe1c7bf09a2cbbc423..83ddac25a40b46726ea2a7cf81893edcf7ddb28c 100644 (file)
--- a/util.c
+++ b/util.c
 
 #include "tailor.h"
 
-#ifdef HAVE_LIMITS_H
-#  include <limits.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#  include <unistd.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#  include <fcntl.h>
-#endif
-
-#if defined STDC_HEADERS || defined HAVE_STDLIB_H
-#  include <stdlib.h>
-#else
-   extern int errno;
-#endif
+#include <limits.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <errno.h>
 
 #include "gzip.h"
 #include "crypt.h"
@@ -146,10 +136,8 @@ read_buffer (fd, buf, cnt)
      voidp buf;
      unsigned int cnt;
 {
-#ifdef SSIZE_MAX
-  if (SSIZE_MAX < cnt)
-    cnt = SSIZE_MAX;
-#endif
+  if (INT_MAX < cnt)
+    cnt = INT_MAX;
   return read (fd, buf, cnt);
 }
 
@@ -160,10 +148,8 @@ write_buffer (fd, buf, cnt)
      voidp buf;
      unsigned int cnt;
 {
-#ifdef SSIZE_MAX
-  if (SSIZE_MAX < cnt)
-    cnt = SSIZE_MAX;
-#endif
+  if (INT_MAX < cnt)
+    cnt = INT_MAX;
   return write (fd, buf, cnt);
 }
 
@@ -297,59 +283,6 @@ void make_simple_name(name)
     } while (p != name);
 }
 
-
-#if !defined HAVE_STRING_H && !defined STDC_HEADERS
-
-/* Provide missing strspn and strcspn functions. */
-
-#  ifndef __STDC__
-#    define const
-#  endif
-
-int strspn  OF((const char *s, const char *accept));
-int strcspn OF((const char *s, const char *reject));
-
-/* ========================================================================
- * Return the length of the maximum initial segment
- * of s which contains only characters in accept.
- */
-int strspn(s, accept)
-    const char *s;
-    const char *accept;
-{
-    register const char *p;
-    register const char *a;
-    register int count = 0;
-
-    for (p = s; *p != '\0'; ++p) {
-       for (a = accept; *a != '\0'; ++a) {
-           if (*p == *a) break;
-       }
-       if (*a == '\0') return count;
-       ++count;
-    }
-    return count;
-}
-
-/* ========================================================================
- * Return the length of the maximum inital segment of s
- * which contains no characters from reject.
- */
-int strcspn(s, reject)
-    const char *s;
-    const char *reject;
-{
-    register int count = 0;
-
-    while (*s != '\0') {
-       if (strchr(reject, *s++) != NULL) return count;
-       ++count;
-    }
-    return count;
-}
-
-#endif
-
 /* ========================================================================
  * Add an environment variable (if any) before argv, and update argc.
  * Return the expanded environment variable to be freed later, or NULL
diff --git a/zip.c b/zip.c
index 9dd167b73139561c73956f089be37e0065a1d462..c0d96ae6e2abd17c9bc9e279c69fb477f4f5aba8 100644 (file)
--- a/zip.c
+++ b/zip.c
 #include "gzip.h"
 #include "crypt.h"
 
-#ifdef HAVE_UNISTD_H
-#  include <unistd.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#  include <fcntl.h>
-#endif
+#include <unistd.h>
+#include <fcntl.h>
 
 local ulg crc;       /* crc on uncompressed file data */
 off_t header_bytes;   /* number of bytes in gzip header */