diff options
author | Jim Meyering <meyering@redhat.com> | 2009-12-20 19:41:39 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-12-30 17:33:55 +0100 |
commit | 9375a72a92bb905d0935f296057148df0562def4 (patch) | |
tree | eb7ee6b1ce781f098c1f80411ec29e6f693fd880 /util.c | |
parent | a5ca1651a1b564b59a104236d9552d9ae75faf3e (diff) | |
download | gzip-9375a72a92bb905d0935f296057148df0562def4.tar.gz |
maint: remove lots of obsolete #if...HAVE_* checks
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.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 85 |
1 files changed, 9 insertions, 76 deletions
@@ -24,21 +24,11 @@ #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 |