From 903878dbde81d011063366928701a202b580f281 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Mon, 16 Feb 2009 00:45:51 +0100 Subject: [PATCH] zic(8) & libc/stdtime: Reduce #ifdefs a bit. --- lib/libc/stdtime/localtime.c | 12 ---- lib/libc/stdtime/private.h | 108 ------------------------------ lib/libc/stdtime/strftime.c | 15 ----- usr.sbin/zic/private.h | 124 ----------------------------------- usr.sbin/zic/zdump/Makefile | 4 +- usr.sbin/zic/zic.c | 2 - usr.sbin/zic/zic/Makefile | 5 +- 7 files changed, 4 insertions(+), 266 deletions(-) diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c index 38b0c2ecf9..73af632626 100644 --- a/lib/libc/stdtime/localtime.c +++ b/lib/libc/stdtime/localtime.c @@ -1448,16 +1448,12 @@ gmtime_r(const time_t * timep, struct tm * tmp) return gmtsub(timep, 0L, tmp); } -#ifdef STD_INSPIRED - struct tm * offtime(const time_t * const timep, const long offset) { return gmtsub(timep, offset, &tm); } -#endif /* defined STD_INSPIRED */ - /* ** Return the number of leap years through the end of the given year ** where, to make the math easy, the answer for year zero is defined as zero. @@ -1977,8 +1973,6 @@ mktime(struct tm * const tmp) return(mktime_return_value); } -#ifdef STD_INSPIRED - time_t timelocal(struct tm * const tmp) { @@ -2000,8 +1994,6 @@ timeoff(struct tm * const tmp, const long offset) return time1(tmp, gmtsub, offset); } -#endif /* defined STD_INSPIRED */ - #ifdef CMUCS /* @@ -2025,8 +2017,6 @@ gtime(struct tm * const tmp) ** XXX--is the below the right way to conditionalize?? */ -#ifdef STD_INSPIRED - /* ** IEEE Std 1003.1-1988 (POSIX) legislates that 536457599 ** shall correspond to "Wed Dec 31 23:59:59 UTC 1986", which @@ -2091,5 +2081,3 @@ posix2time(time_t t) } return x; } - -#endif /* defined STD_INSPIRED */ diff --git a/lib/libc/stdtime/private.h b/lib/libc/stdtime/private.h index bc487c32e5..9618dba476 100644 --- a/lib/libc/stdtime/private.h +++ b/lib/libc/stdtime/private.h @@ -16,12 +16,7 @@ #ifndef TM_GMTOFF #define TM_GMTOFF tm_gmtoff #define TM_ZONE tm_zone -#define STD_INSPIRED 1 #define PCTS 1 -#define HAVE_LONG_DOUBLE 1 -#define HAVE_STRERROR 1 -#define HAVE_UNISTD_H 1 -#define LOCALE_HOME _PATH_LOCALE #define TZDIR "/usr/share/zoneinfo" #endif /* ndef TM_GMTOFF */ @@ -35,56 +30,6 @@ #define GRANDPARENTED "Local time zone must be set--see zic manual page" -/* -** Defaults for preprocessor symbols. -** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'. -*/ - -#ifndef HAVE_ADJTIME -#define HAVE_ADJTIME 1 -#endif /* !defined HAVE_ADJTIME */ - -#ifndef HAVE_GETTEXT -#define HAVE_GETTEXT 0 -#endif /* !defined HAVE_GETTEXT */ - -#ifndef HAVE_INCOMPATIBLE_CTIME_R -#define HAVE_INCOMPATIBLE_CTIME_R 0 -#endif /* !defined INCOMPATIBLE_CTIME_R */ - -#ifndef HAVE_SETTIMEOFDAY -#define HAVE_SETTIMEOFDAY 3 -#endif /* !defined HAVE_SETTIMEOFDAY */ - -#ifndef HAVE_SYMLINK -#define HAVE_SYMLINK 1 -#endif /* !defined HAVE_SYMLINK */ - -#ifndef HAVE_SYS_STAT_H -#define HAVE_SYS_STAT_H 1 -#endif /* !defined HAVE_SYS_STAT_H */ - -#ifndef HAVE_SYS_WAIT_H -#define HAVE_SYS_WAIT_H 1 -#endif /* !defined HAVE_SYS_WAIT_H */ - -#ifndef HAVE_UNISTD_H -#define HAVE_UNISTD_H 1 -#endif /* !defined HAVE_UNISTD_H */ - -#ifndef HAVE_UTMPX_H -#define HAVE_UTMPX_H 0 -#endif /* !defined HAVE_UTMPX_H */ - -#ifndef LOCALE_HOME -#define LOCALE_HOME "/usr/lib/locale" -#endif /* !defined LOCALE_HOME */ - -#if HAVE_INCOMPATIBLE_CTIME_R -#define asctime_r _incompatible_asctime_r -#define ctime_r _incompatible_ctime_r -#endif /* HAVE_INCOMPATIBLE_CTIME_R */ - /* ** Nested includes */ @@ -97,13 +42,7 @@ #include "time.h" #include "stdlib.h" -#if HAVE_GETTEXT -#include "libintl.h" -#endif /* HAVE_GETTEXT */ - -#if HAVE_SYS_WAIT_H #include /* for WIFEXITED and WEXITSTATUS */ -#endif /* HAVE_SYS_WAIT_H */ #ifndef WIFEXITED #define WIFEXITED(status) (((status) & 0xff) == 0) @@ -112,9 +51,7 @@ #define WEXITSTATUS(status) (((status) >> 8) & 0xff) #endif /* !defined WEXITSTATUS */ -#if HAVE_UNISTD_H #include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */ -#endif /* HAVE_UNISTD_H */ #ifndef F_OK #define F_OK 0 @@ -126,41 +63,7 @@ /* Unlike 's isdigit, this also works if c < 0 | c > UCHAR_MAX. */ #define is_digit(c) ((unsigned)(c) - '0' <= 9) -/* -** Define HAVE_STDINT_H's default value here, rather than at the -** start, since __GLIBC__'s value depends on previously-included -** files. -** (glibc 2.1 and later have stdint.h, even with pre-C99 compilers.) -*/ -#ifndef HAVE_STDINT_H -#define HAVE_STDINT_H \ - (199901 <= __STDC_VERSION__ || \ - 2 < (__GLIBC__ + (0 < __GLIBC_MINOR__))) -#endif /* !defined HAVE_STDINT_H */ - -#if HAVE_STDINT_H #include "stdint.h" -#endif /* !HAVE_STDINT_H */ - -#ifndef INT_FAST64_MAX -/* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */ -#if defined LLONG_MAX || defined __LONG_LONG_MAX__ -typedef long long int_fast64_t; -#else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */ -#if (LONG_MAX >> 31) < 0xffffffff -Please use a compiler that supports a 64-bit integer type (or wider); -you may need to compile with "-DHAVE_STDINT_H". -#endif /* (LONG_MAX >> 31) < 0xffffffff */ -typedef long int_fast64_t; -#endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */ -#endif /* !defined INT_FAST64_MAX */ - -#ifndef INT32_MAX -#define INT32_MAX 0x7fffffff -#endif /* !defined INT32_MAX */ -#ifndef INT32_MIN -#define INT32_MIN (-1 - INT32_MAX) -#endif /* !defined INT32_MIN */ /* ** Workarounds for compilers/systems. @@ -261,24 +164,13 @@ const char * scheck(const char * string, const char * format); */ #ifndef _ -#if HAVE_GETTEXT -#define _(msgid) gettext(msgid) -#else /* !(HAVE_GETTEXT) */ #define _(msgid) msgid -#endif /* !(HAVE_GETTEXT) */ #endif /* !defined _ */ #ifndef TZ_DOMAIN #define TZ_DOMAIN "tz" #endif /* !defined TZ_DOMAIN */ -#if HAVE_INCOMPATIBLE_CTIME_R -#undef asctime_r -#undef ctime_r -char *asctime_r(struct tm const *, char *); -char *ctime_r(time_t const *, char *); -#endif /* HAVE_INCOMPATIBLE_CTIME_R */ - #ifndef YEARSPERREPEAT #define YEARSPERREPEAT 400 /* years before a Gregorian repeat */ #endif /* !defined YEARSPERREPEAT */ diff --git a/lib/libc/stdtime/strftime.c b/lib/libc/stdtime/strftime.c index 455dbd3a4f..e64e04aadb 100644 --- a/lib/libc/stdtime/strftime.c +++ b/lib/libc/stdtime/strftime.c @@ -477,20 +477,6 @@ label: ** determinable, so output nothing if the ** appropriate variables are not available. */ -#ifndef STD_INSPIRED - if (t->tm_isdst == 0) -#ifdef USG_COMPAT - diff = -timezone; -#else /* !defined USG_COMPAT */ - continue; -#endif /* !defined USG_COMPAT */ - else -#ifdef ALTZONE - diff = -altzone; -#else /* !defined ALTZONE */ - continue; -#endif /* !defined ALTZONE */ -#else /* defined STD_INSPIRED */ { struct tm tmp; time_t lct, gct; @@ -518,7 +504,6 @@ label: /* LINTED difference will fit int */ diff = (intmax_t)gct - (intmax_t)lct; } -#endif /* defined STD_INSPIRED */ #endif /* !defined TM_GMTOFF */ if (diff < 0) { sign = "-"; diff --git a/usr.sbin/zic/private.h b/usr.sbin/zic/private.h index 58b2354b92..35858bf3ab 100644 --- a/usr.sbin/zic/private.h +++ b/usr.sbin/zic/private.h @@ -16,12 +16,7 @@ #ifndef TM_GMTOFF #define TM_GMTOFF tm_gmtoff #define TM_ZONE tm_zone -#define STD_INSPIRED 1 #define PCTS 1 -#define HAVE_LONG_DOUBLE 1 -#define HAVE_STRERROR 1 -#define HAVE_UNISTD_H 1 -#define LOCALE_HOME _PATH_LOCALE #define TZDIR "/usr/share/zoneinfo" #endif /* ndef TM_GMTOFF */ @@ -35,56 +30,6 @@ #define GRANDPARENTED "Local time zone must be set--see zic manual page" -/* -** Defaults for preprocessor symbols. -** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'. -*/ - -#ifndef HAVE_ADJTIME -#define HAVE_ADJTIME 1 -#endif /* !defined HAVE_ADJTIME */ - -#ifndef HAVE_GETTEXT -#define HAVE_GETTEXT 0 -#endif /* !defined HAVE_GETTEXT */ - -#ifndef HAVE_INCOMPATIBLE_CTIME_R -#define HAVE_INCOMPATIBLE_CTIME_R 0 -#endif /* !defined INCOMPATIBLE_CTIME_R */ - -#ifndef HAVE_SETTIMEOFDAY -#define HAVE_SETTIMEOFDAY 3 -#endif /* !defined HAVE_SETTIMEOFDAY */ - -#ifndef HAVE_SYMLINK -#define HAVE_SYMLINK 1 -#endif /* !defined HAVE_SYMLINK */ - -#ifndef HAVE_SYS_STAT_H -#define HAVE_SYS_STAT_H 1 -#endif /* !defined HAVE_SYS_STAT_H */ - -#ifndef HAVE_SYS_WAIT_H -#define HAVE_SYS_WAIT_H 1 -#endif /* !defined HAVE_SYS_WAIT_H */ - -#ifndef HAVE_UNISTD_H -#define HAVE_UNISTD_H 1 -#endif /* !defined HAVE_UNISTD_H */ - -#ifndef HAVE_UTMPX_H -#define HAVE_UTMPX_H 0 -#endif /* !defined HAVE_UTMPX_H */ - -#ifndef LOCALE_HOME -#define LOCALE_HOME "/usr/lib/locale" -#endif /* !defined LOCALE_HOME */ - -#if HAVE_INCOMPATIBLE_CTIME_R -#define asctime_r _incompatible_asctime_r -#define ctime_r _incompatible_ctime_r -#endif /* HAVE_INCOMPATIBLE_CTIME_R */ - /* ** Nested includes */ @@ -97,13 +42,7 @@ #include "time.h" #include "stdlib.h" -#if HAVE_GETTEXT -#include "libintl.h" -#endif /* HAVE_GETTEXT */ - -#if HAVE_SYS_WAIT_H #include /* for WIFEXITED and WEXITSTATUS */ -#endif /* HAVE_SYS_WAIT_H */ #ifndef WIFEXITED #define WIFEXITED(status) (((status) & 0xff) == 0) @@ -112,9 +51,7 @@ #define WEXITSTATUS(status) (((status) >> 8) & 0xff) #endif /* !defined WEXITSTATUS */ -#if HAVE_UNISTD_H #include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */ -#endif /* HAVE_UNISTD_H */ #ifndef F_OK #define F_OK 0 @@ -126,41 +63,7 @@ /* Unlike 's isdigit, this also works if c < 0 | c > UCHAR_MAX. */ #define is_digit(c) ((unsigned)(c) - '0' <= 9) -/* -** Define HAVE_STDINT_H's default value here, rather than at the -** start, since __GLIBC__'s value depends on previously-included -** files. -** (glibc 2.1 and later have stdint.h, even with pre-C99 compilers.) -*/ -#ifndef HAVE_STDINT_H -#define HAVE_STDINT_H \ - (199901 <= __STDC_VERSION__ || \ - 2 < (__GLIBC__ + (0 < __GLIBC_MINOR__))) -#endif /* !defined HAVE_STDINT_H */ - -#if HAVE_STDINT_H #include "stdint.h" -#endif /* !HAVE_STDINT_H */ - -#ifndef INT_FAST64_MAX -/* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */ -#if defined LLONG_MAX || defined __LONG_LONG_MAX__ -typedef long long int_fast64_t; -#else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */ -#if (LONG_MAX >> 31) < 0xffffffff -Please use a compiler that supports a 64-bit integer type (or wider); -you may need to compile with "-DHAVE_STDINT_H". -#endif /* (LONG_MAX >> 31) < 0xffffffff */ -typedef long int_fast64_t; -#endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */ -#endif /* !defined INT_FAST64_MAX */ - -#ifndef INT32_MAX -#define INT32_MAX 0x7fffffff -#endif /* !defined INT32_MAX */ -#ifndef INT32_MIN -#define INT32_MIN (-1 - INT32_MAX) -#endif /* !defined INT32_MIN */ /* ** Workarounds for compilers/systems. @@ -261,44 +164,17 @@ const char * scheck(const char * string, const char * format); */ #ifndef _ -#if HAVE_GETTEXT -#define _(msgid) gettext(msgid) -#else /* !(HAVE_GETTEXT) */ #define _(msgid) msgid -#endif /* !(HAVE_GETTEXT) */ #endif /* !defined _ */ #ifndef TZ_DOMAIN #define TZ_DOMAIN "tz" #endif /* !defined TZ_DOMAIN */ -#if HAVE_INCOMPATIBLE_CTIME_R -#undef asctime_r -#undef ctime_r -char *asctime_r(struct tm const *, char *); -char *ctime_r(time_t const *, char *); -#endif /* HAVE_INCOMPATIBLE_CTIME_R */ - #ifndef YEARSPERREPEAT #define YEARSPERREPEAT 400 /* years before a Gregorian repeat */ #endif /* !defined YEARSPERREPEAT */ -/* -** The Gregorian year averages 365.2425 days, which is 31556952 seconds. -*/ - -#ifndef AVGSECSPERYEAR -#define AVGSECSPERYEAR 31556952L -#endif /* !defined AVGSECSPERYEAR */ - -#ifndef SECSPERREPEAT -#define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR) -#endif /* !defined SECSPERREPEAT */ - -#ifndef SECSPERREPEAT_BITS -#define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */ -#endif /* !defined SECSPERREPEAT_BITS */ - /* ** UNIX was a registered trademark of The Open Group in 2003. */ diff --git a/usr.sbin/zic/zdump/Makefile b/usr.sbin/zic/zdump/Makefile index e21d791150..9bc7f3df68 100644 --- a/usr.sbin/zic/zdump/Makefile +++ b/usr.sbin/zic/zdump/Makefile @@ -8,7 +8,7 @@ PROG= zdump SRCS= zdump.c ialloc.c scheck.c MAN= ${.CURDIR}/../zdump.8 CFLAGS+= -I${.CURDIR}/.. -I${.CURDIR}/../../../lib/libc/stdtime -CFLAGS+= -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -DSTD_INSPIRED -DPCTS -CFLAGS+= -DHAVE_LONG_DOUBLE -DTZDIR=\"/usr/share/zoneinfo\" -Demkdir=mkdir +CFLAGS+= -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -DPCTS +CFLAGS+= -DTZDIR=\"/usr/share/zoneinfo\" -Demkdir=mkdir .include diff --git a/usr.sbin/zic/zic.c b/usr.sbin/zic/zic.c index 855758ca0f..00b1102294 100644 --- a/usr.sbin/zic/zic.c +++ b/usr.sbin/zic/zic.c @@ -608,7 +608,6 @@ dolink(const char * const fromfield, const char * const tofield) exit(EXIT_FAILURE); result = link(fromname, toname); -#if HAVE_SYMLINK if (result != 0 && access(fromname, F_OK) == 0 && !itsdir(fromname)) { @@ -628,7 +627,6 @@ dolink(const char * const fromfield, const char * const tofield) warning(_("hard link failed, symbolic link used")); ifree(symlinkcontents); } -#endif /* HAVE_SYMLINK */ if (result != 0) { err(EXIT_FAILURE, _("can't link from %s to %s"), fromname, toname); diff --git a/usr.sbin/zic/zic/Makefile b/usr.sbin/zic/zic/Makefile index 0133efd807..0561f0363c 100644 --- a/usr.sbin/zic/zic/Makefile +++ b/usr.sbin/zic/zic/Makefile @@ -8,8 +8,7 @@ PROG= zic SRCS= zic.c ialloc.c scheck.c MAN= ${.CURDIR}/../zic.8 CFLAGS+= -I${.CURDIR}/.. -I${.CURDIR}/../../../lib/libc/stdtime -CFLAGS+= -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -DSTD_INSPIRED -DPCTS -CFLAGS+= -DHAVE_LONG_DOUBLE -DTZDIR=\"/usr/share/zoneinfo\" -Demkdir=mkdir -CFLAGS+= -DHAVE_STRERROR -DHAVE_UNISTD_H +CFLAGS+= -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -DPCTS +CFLAGS+= -DTZDIR=\"/usr/share/zoneinfo\" -Demkdir=mkdir .include -- 2.41.0