diff -ru tzcode2007h-less-P-macro/Makefile tzcode2007-pre-i/Makefile --- tzcode2007h-less-P-macro/Makefile 2007-08-20 07:47:41.000000000 -0700 +++ tzcode2007-pre-i/Makefile 2007-11-13 15:08:32.930145602 -0800 @@ -86,7 +86,6 @@ LDLIBS= # Add the following to the end of the "CFLAGS=" line as needed. -# -Dconst= if `const' does not work (SunOS 4.x cc, OSF1 V5.0 cc) # -DHAVE_ADJTIME=0 if `adjtime' does not exist (SVR0?) # -DHAVE_GETTEXT=1 if `gettext' works (GNU, Linux, Solaris); also see LDLIBS # -DHAVE_INCOMPATIBLE_CTIME_R=1 if your system's time.h declares @@ -96,7 +95,6 @@ # -DHAVE_SETTIMEOFDAY=2 if settimeofday uses 2nd arg (4.3BSD) # -DHAVE_SETTIMEOFDAY=3 if settimeofday ignores 2nd arg (4.4BSD) # -DHAVE_STDINT_H=1 if you have a pre-C99 compiler with "stdint.h" -# -DHAVE_STRERROR=0 if your system lacks the strerror function # -DHAVE_SYMLINK=0 if your system lacks the symlink function # -DHAVE_SYS_STAT_H=0 if your compiler lacks a "sys/stat.h" # -DHAVE_SYS_WAIT_H=0 if your compiler lacks a "sys/wait.h" diff -ru tzcode2007h-less-P-macro/asctime.c tzcode2007-pre-i/asctime.c --- tzcode2007h-less-P-macro/asctime.c 2007-08-20 07:47:41.000000000 -0700 +++ tzcode2007-pre-i/asctime.c 2007-11-13 15:12:39.016169245 -0800 @@ -21,12 +21,6 @@ #include "tzfile.h" /* -** Some systems only handle "%.2d"; others only handle "%02d"; -** "%02.2d" makes (most) everybody happy. -** At least some versions of gcc warn about the %02.2d; -** we conditionalize below to avoid the warning. -*/ -/* ** All years associated with 32-bit time_t values are exactly four digits long; ** some years associated with 64-bit time_t values are not. ** Vintage programs are coded for years that are always four digits long @@ -38,22 +32,15 @@ ** The ISO C 1999 and POSIX 1003.1-2004 standards prohibit padding the year, ** but many implementations pad anyway; most likely the standards are buggy. */ -#ifdef __GNUC__ #define ASCTIME_FMT "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n" -#else /* !defined __GNUC__ */ -#define ASCTIME_FMT "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %-4s\n" -#endif /* !defined __GNUC__ */ + /* ** For years that are more than four digits we put extra spaces before the year ** so that code trying to overwrite the newline won't end up overwriting ** a digit within a year and truncating the year (operating on the assumption ** that no output is better than wrong output). */ -#ifdef __GNUC__ #define ASCTIME_FMT_B "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %s\n" -#else /* !defined __GNUC__ */ -#define ASCTIME_FMT_B "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %s\n" -#endif /* !defined __GNUC__ */ #define STD_ASCTIME_BUF_SIZE 26 /* @@ -75,9 +62,7 @@ */ char * -asctime_r(timeptr, buf) -register const struct tm * timeptr; -char * buf; +asctime_r(register const struct tm *timeptr, char *buf) { static const char wday_name[][3] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" @@ -131,8 +116,7 @@ */ char * -asctime(timeptr) -register const struct tm * timeptr; +asctime(register const struct tm *timeptr) { return asctime_r(timeptr, buf_asctime); } diff -ru tzcode2007h-less-P-macro/date.c tzcode2007-pre-i/date.c --- tzcode2007h-less-P-macro/date.c 2007-11-11 16:56:00.603760665 -0800 +++ tzcode2007-pre-i/date.c 2007-11-13 15:35:01.220657120 -0800 @@ -36,12 +36,12 @@ #include "private.h" #if HAVE_ADJTIME || HAVE_SETTIMEOFDAY -#include "sys/time.h" /* for struct timeval, struct timezone */ +#include /* for struct timeval, struct timezone */ #endif /* HAVE_ADJTIME || HAVE_SETTIMEOFDAY */ -#include "locale.h" -#include "utmp.h" /* for OLD_TIME (or its absence) */ +#include +#include /* for OLD_TIME (or its absence) */ #if HAVE_UTMPX_H -#include "utmpx.h" +#include #endif #ifndef OTIME_MSG @@ -63,14 +63,12 @@ #define SECSPERMIN 60 #endif /* !defined SECSPERMIN */ -extern double atof(); extern char ** environ; -extern char * getlogin(); -extern time_t mktime(); +extern char * getlogin(void); +extern time_t mktime(struct tm *); extern char * optarg; extern int optind; -extern char * strchr(); -extern time_t time(); +extern time_t time(time_t *); extern char * tzname[2]; static int retval = EXIT_SUCCESS; @@ -92,9 +90,7 @@ const char *); int -main(argc, argv) -const int argc; -char * argv[]; +main(int argc, char **argv) { register const char * format; register const char * value; @@ -311,7 +307,7 @@ } static void -dogmt() +dogmt(void) { static char ** fakeenv; @@ -348,7 +344,7 @@ ** and don't have network notification to worry about. */ -#include "fcntl.h" /* for O_WRONLY, O_APPEND */ +#include /* for O_WRONLY, O_APPEND */ /*ARGSUSED*/ static void @@ -428,7 +424,7 @@ */ #ifndef TIME_NAME -#include "sys/param.h" +#include #ifdef BSD4_4 #define TIME_NAME "date" #endif /* defined BSD4_4 */ @@ -437,12 +433,12 @@ #endif /* !defined BSD4_4 */ #endif /* !defined TIME_NAME */ -#include "syslog.h" -#include "sys/socket.h" -#include "netinet/in.h" -#include "netdb.h" +#include +#include +#include +#include #define TSPTYPES -#include "protocols/timed.h" +#include extern int logwtmp(); @@ -454,9 +450,7 @@ /*ARGSUSED*/ #endif /* !defined TSP_SETDATE */ static void -reset(newt, nflag) -const time_t newt; -const int nflag; +reset(const time_t newt, const int nflag) { register const char * username; static struct timeval tv; /* static so tv_usec is 0 */ @@ -487,10 +481,9 @@ #endif /* !defined OLD_TIME */ static void -wildinput(item, value, reason) -const char * const item; -const char * const value; -const char * const reason; +wildinput(const char * const item, + const char * const value, + const char * const reason) { (void) fprintf(stderr, _("date: error: bad command line %s \"%s\", %s\n"), @@ -506,8 +499,7 @@ } static const char * -nondigit(cp) -register const char * cp; +nondigit(register const char *cp) { while (is_digit(*cp)) ++cp; @@ -524,8 +516,7 @@ } static void -oops(string) -const char * const string; +oops(const char * const string) { int e = errno; @@ -537,8 +528,7 @@ } static void -display(format) -const char * const format; +display(const char * const format) { struct tm tm; time_t now; @@ -557,15 +547,12 @@ exit(retval); } -extern size_t strftime(); +extern size_t strftime(char *, size_t, const char *, const struct tm *); #define INCR 1024 static void -timeout(fp, format, tmp) -FILE * const fp; -const char * const format; -const struct tm * const tmp; +timeout(FILE * const fp, const char * const format, const struct tm * const tmp) { char * cp; size_t result; @@ -594,9 +581,8 @@ } static int -comptm(atmp, btmp) -register const struct tm * const atmp; -register const struct tm * const btmp; +comptm(register const struct tm * const atmp, + register const struct tm * const btmp) { register int result; @@ -825,8 +811,7 @@ * notifies the master that a correction is needed. * Returns 1 on success, 0 on failure. */ -netsettime(ntv) - struct timeval ntv; +netsettime(struct timeval ntv) { int s, length, port, timed_ack, found, err; long waittime; diff -ru tzcode2007h-less-P-macro/difftime.c tzcode2007-pre-i/difftime.c --- tzcode2007h-less-P-macro/difftime.c 2007-08-20 07:47:41.000000000 -0700 +++ tzcode2007-pre-i/difftime.c 2007-11-13 15:08:32.934145830 -0800 @@ -14,9 +14,7 @@ #include "private.h" /* for time_t, TYPE_INTEGRAL, and TYPE_SIGNED */ double -difftime(time1, time0) -const time_t time1; -const time_t time0; +difftime(const time_t time1, const time_t time0) { /* ** If (sizeof (double) > sizeof (time_t)) simply convert and subtract diff -ru tzcode2007h-less-P-macro/ialloc.c tzcode2007-pre-i/ialloc.c --- tzcode2007h-less-P-macro/ialloc.c 2007-08-20 07:47:42.000000000 -0700 +++ tzcode2007-pre-i/ialloc.c 2007-11-13 15:16:12.820353251 -0800 @@ -16,16 +16,13 @@ #define nonzero(n) (((n) == 0) ? 1 : (n)) char * -imalloc(n) -const int n; +imalloc(const int n) { return malloc((size_t) nonzero(n)); } char * -icalloc(nelem, elsize) -int nelem; -int elsize; +icalloc(int nelem, int elsize) { if (nelem == 0 || elsize == 0) nelem = elsize = 1; @@ -33,9 +30,7 @@ } void * -irealloc(pointer, size) -void * const pointer; -const int size; +irealloc(void * const pointer, const int size) { if (pointer == NULL) return imalloc(size); @@ -43,9 +38,7 @@ } char * -icatalloc(old, new) -char * const old; -const char * const new; +icatalloc(char * const old, const char * const new) { register char * result; register int oldsize, newsize; @@ -63,23 +56,21 @@ } char * -icpyalloc(string) -const char * const string; +icpyalloc(const char * const string) { return icatalloc((char *) NULL, string); } void -ifree(p) -char * const p; +ifree(char * const p) + { if (p != NULL) (void) free(p); } void -icfree(p) -char * const p; +icfree(char * const p) { if (p != NULL) (void) free(p); diff -ru tzcode2007h-less-P-macro/localtime.c tzcode2007-pre-i/localtime.c --- tzcode2007h-less-P-macro/localtime.c 2007-11-11 16:56:03.611932091 -0800 +++ tzcode2007-pre-i/localtime.c 2007-11-13 15:44:58.578698614 -0800 @@ -18,8 +18,8 @@ #include "private.h" #include "tzfile.h" -#include "fcntl.h" -#include "float.h" /* for FLT_MAX and DBL_MAX */ +#include +#include /* for FLT_MAX and DBL_MAX */ #ifndef TZ_ABBR_MAX_LEN #define TZ_ABBR_MAX_LEN 16 @@ -227,8 +227,7 @@ #endif /* defined ALTZONE */ static long -detzcode(codep) -const char * const codep; +detzcode(const char * const codep) { register long result; register int i; @@ -240,8 +239,7 @@ } static time_t -detzcode64(codep) -const char * const codep; +detzcode64(const char * const codep) { register time_t result; register int i; @@ -321,9 +319,7 @@ } static int -differ_by_repeat(t1, t0) -const time_t t1; -const time_t t0; +differ_by_repeat(const time_t t1, const time_t t0) { if (TYPE_INTEGRAL(time_t) && TYPE_BIT(time_t) - TYPE_SIGNED(time_t) < SECSPERREPEAT_BITS) @@ -332,10 +328,9 @@ } static int -tzload(name, sp, doextend) -register const char * name; -register struct state * const sp; -register const int doextend; +tzload(register const char *name, + register struct state * const sp, + register const int doextend) { register const char * p; register int i; @@ -581,8 +576,7 @@ */ static const char * -getzname(strp) -register const char * strp; +getzname(register const char * strp) { register char c; @@ -619,11 +613,10 @@ */ static const char * -getnum(strp, nump, min, max) -register const char * strp; -int * const nump; -const int min; -const int max; +getnum(register const char * strp, + int * const nump, + const int min, + const int max) { register char c; register int num; @@ -652,9 +645,7 @@ */ static const char * -getsecs(strp, secsp) -register const char * strp; -long * const secsp; +getsecs(register const char * strp, long * const secsp) { int num; @@ -694,9 +685,7 @@ */ static const char * -getoffset(strp, offsetp) -register const char * strp; -long * const offsetp; +getoffset(const char * strp, long * const offsetp) { register int neg = 0; @@ -721,9 +710,7 @@ */ static const char * -getrule(strp, rulep) -const char * strp; -register struct rule * const rulep; +getrule(register const char * strp, register struct rule * const rulep) { if (*strp == 'J') { /* @@ -775,11 +762,10 @@ */ static time_t -transtime(janfirst, year, rulep, offset) -const time_t janfirst; -const int year; -register const struct rule * const rulep; -const long offset; +transtime(const time_t janfirst, + const int year, + register const struct rule * const rulep, + const long offset) { register int leapyear; register time_t value; @@ -870,10 +856,9 @@ */ static int -tzparse(name, sp, lastditch) -const char * name; -register struct state * const sp; -const int lastditch; +tzparse(const char * name, + register struct state * const sp, + const int lastditch) { const char * stdname; const char * dstname; @@ -1105,8 +1090,7 @@ } static void -gmtload(sp) -struct state * const sp; +gmtload(struct state * const sp) { if (tzload(gmt, sp, TRUE) != 0) (void) tzparse(gmt, sp, TRUE); @@ -1194,10 +1178,7 @@ /*ARGSUSED*/ static struct tm * -localsub(timep, offset, tmp) -const time_t * const timep; -const long offset; -struct tm * const tmp; +localsub(const time_t * const timep, const long offset, struct tm * const tmp) { register struct state * sp; register const struct ttinfo * ttisp; @@ -1286,8 +1267,7 @@ } struct tm * -localtime(timep) -const time_t * const timep; +localtime(const time_t * const timep) { tzset(); return localsub(timep, 0L, &tm); @@ -1298,9 +1278,7 @@ */ struct tm * -localtime_r(timep, tmp) -const time_t * const timep; -struct tm * tmp; +localtime_r(const time_t * const timep, struct tm * tmp) { return localsub(timep, 0L, tmp); } @@ -1310,10 +1288,7 @@ */ static struct tm * -gmtsub(timep, offset, tmp) -const time_t * const timep; -const long offset; -struct tm * const tmp; +gmtsub(const time_t * const timep, const long offset, struct tm * const tmp) { register struct tm * result; @@ -1349,8 +1324,7 @@ } struct tm * -gmtime(timep) -const time_t * const timep; +gmtime(const time_t * const timep) { return gmtsub(timep, 0L, &tm); } @@ -1360,9 +1334,7 @@ */ struct tm * -gmtime_r(timep, tmp) -const time_t * const timep; -struct tm * tmp; +gmtime_r(const time_t * const timep, struct tm * tmp) { return gmtsub(timep, 0L, tmp); } @@ -1370,9 +1342,7 @@ #ifdef STD_INSPIRED struct tm * -offtime(timep, offset) -const time_t * const timep; -const long offset; +offtime(const time_t * const timep, const long offset) { return gmtsub(timep, offset, &tm); } @@ -1385,19 +1355,17 @@ */ static int -leaps_thru_end_of(y) -register const int y; +leaps_thru_end_of(register const int y) { return (y >= 0) ? (y / 4 - y / 100 + y / 400) : -(leaps_thru_end_of(-(y + 1)) + 1); } static struct tm * -timesub(timep, offset, sp, tmp) -const time_t * const timep; -const long offset; -register const struct state * const sp; -register struct tm * const tmp; +timesub(const time_t * const timep, + const long offset, + register const struct state * const sp, + register struct tm * const tmp) { register const struct lsinfo * lp; register time_t tdays; @@ -1527,8 +1495,7 @@ } char * -ctime(timep) -const time_t * const timep; +ctime(const time_t * const timep) { /* ** Section 4.12.3.2 of X3.159-1989 requires that @@ -1540,9 +1507,7 @@ } char * -ctime_r(timep, buf) -const time_t * const timep; -char * buf; +ctime_r(const time_t * const timep, char * buf) { struct tm mytm; @@ -1567,9 +1532,7 @@ */ static int -increment_overflow(number, delta) -int * number; -int delta; +increment_overflow(int * number, int delta) { int number0; @@ -1579,9 +1542,7 @@ } static int -long_increment_overflow(number, delta) -long * number; -int delta; +long_increment_overflow(long * number, int delta) { long number0; @@ -1591,10 +1552,7 @@ } static int -normalize_overflow(tensptr, unitsptr, base) -int * const tensptr; -int * const unitsptr; -const int base; +normalize_overflow(int * const tensptr, int * const unitsptr, const int base) { register int tensdelta; @@ -1606,10 +1564,9 @@ } static int -long_normalize_overflow(tensptr, unitsptr, base) -long * const tensptr; -int * const unitsptr; -const int base; +long_normalize_overflow(long * const tensptr, + int * const unitsptr, + const int base) { register int tensdelta; @@ -1621,9 +1578,8 @@ } static int -tmcomp(atmp, btmp) -register const struct tm * const atmp; -register const struct tm * const btmp; +tmcomp(register const struct tm * const atmp, + register const struct tm * const btmp) { register int result; @@ -1637,12 +1593,11 @@ } static time_t -time2sub(tmp, funcp, offset, okayp, do_norm_secs) -struct tm * const tmp; -struct tm * (* const funcp)(const time_t*, long, struct tm*); -const long offset; -int * const okayp; -const int do_norm_secs; +time2sub(struct tm * const tmp, + struct tm * (* const funcp)(const time_t *, long, struct tm *), + const long offset, + int * const okayp, + const int do_norm_secs) { register const struct state * sp; register int dir; @@ -1781,12 +1736,8 @@ ** It's okay to guess wrong since the guess ** gets checked. */ - /* - ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's. - */ sp = (const struct state *) - (((void *) funcp == (void *) localsub) ? - lclptr : gmtptr); + (funcp == localsub ? lclptr : gmtptr); #ifdef ALL_STATE if (sp == NULL) return WRONG; @@ -1825,11 +1776,10 @@ } static time_t -time2(tmp, funcp, offset, okayp) -struct tm * const tmp; -struct tm * (* const funcp)(const time_t*, long, struct tm*); -const long offset; -int * const okayp; +time2(struct tm * const tmp, + struct tm * (* const funcp)(const time_t *, long, struct tm *), + const long offset, + int * const okayp) { time_t t; @@ -1843,10 +1793,9 @@ } static time_t -time1(tmp, funcp, offset) -struct tm * const tmp; -struct tm * (* const funcp)(const time_t *, long, struct tm *); -const long offset; +time1(struct tm * const tmp, + struct tm * (* const funcp)(const time_t *, long, struct tm *), + const long offset) { register time_t t; register const struct state * sp; @@ -1880,11 +1829,7 @@ ** We try to divine the type they started from and adjust to the ** type they need. */ - /* - ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's. - */ - sp = (const struct state *) (((void *) funcp == (void *) localsub) ? - lclptr : gmtptr); + sp = (const struct state *) (funcp == localsub ? lclptr : gmtptr); #ifdef ALL_STATE if (sp == NULL) return WRONG; @@ -1920,8 +1865,7 @@ } time_t -mktime(tmp) -struct tm * const tmp; +mktime(struct tm * const tmp) { tzset(); return time1(tmp, localsub, 0L); @@ -1930,25 +1874,21 @@ #ifdef STD_INSPIRED time_t -timelocal(tmp) -struct tm * const tmp; +timelocal(struct tm * const tmp) { tmp->tm_isdst = -1; /* in case it wasn't initialized */ return mktime(tmp); } time_t -timegm(tmp) -struct tm * const tmp; +timegm(struct tm * const tmp) { tmp->tm_isdst = 0; return time1(tmp, gmtsub, 0L); } time_t -timeoff(tmp, offset) -struct tm * const tmp; -const long offset; +timeoff(struct tm * const tmp, const long offset) { tmp->tm_isdst = 0; return time1(tmp, gmtsub, offset); @@ -1964,8 +1904,7 @@ */ long -gtime(tmp) -struct tm * const tmp; +gtime(struct tm * const tmp) { const time_t t = mktime(tmp); @@ -1991,8 +1930,7 @@ */ static long -leapcorr(timep) -time_t * timep; +leapcorr(time_t * timep) { register struct state * sp; register struct lsinfo * lp; @@ -2009,16 +1947,14 @@ } time_t -time2posix(t) -time_t t; +time2posix(time_t t) { tzset(); return t - leapcorr(&t); } time_t -posix2time(t) -time_t t; +posix2time(time_t t) { time_t x; time_t y; diff -ru tzcode2007h-less-P-macro/logwtmp.c tzcode2007-pre-i/logwtmp.c --- tzcode2007h-less-P-macro/logwtmp.c 2007-08-20 07:47:42.000000000 -0700 +++ tzcode2007-pre-i/logwtmp.c 2007-11-13 15:08:32.934145830 -0800 @@ -51,8 +51,8 @@ struct utmp ut; struct stat buf; int fd; - time_t time(); - char *strncpy(); + time_t time(time_t *); + char *strncpy(char *, const char *); if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0) return; diff -ru tzcode2007h-less-P-macro/private.h tzcode2007-pre-i/private.h --- tzcode2007h-less-P-macro/private.h 2007-11-11 16:56:05.276026922 -0800 +++ tzcode2007-pre-i/private.h 2007-11-13 15:08:32.934145830 -0800 @@ -48,10 +48,6 @@ #define HAVE_SETTIMEOFDAY 3 #endif /* !defined HAVE_SETTIMEOFDAY */ -#ifndef HAVE_STRERROR -#define HAVE_STRERROR 1 -#endif /* !defined HAVE_STRERROR */ - #ifndef HAVE_SYMLINK #define HAVE_SYMLINK 1 #endif /* !defined HAVE_SYMLINK */ @@ -85,16 +81,15 @@ ** Nested includes */ -#include "sys/types.h" /* for time_t */ -#include "stdio.h" -#include "errno.h" -#include "string.h" -#include "limits.h" /* for CHAR_BIT et al. */ -#include "time.h" -#include "stdlib.h" +#include +#include +#include +#include /* for CHAR_BIT et al. */ +#include +#include #if HAVE_GETTEXT -#include "libintl.h" +#include #endif /* HAVE_GETTEXT */ #if HAVE_SYS_WAIT_H @@ -109,17 +104,15 @@ #endif /* !defined WEXITSTATUS */ #if HAVE_UNISTD_H -#include "unistd.h" /* for F_OK and R_OK */ +#include /* for F_OK and R_OK, and other POSIX goodness */ #endif /* HAVE_UNISTD_H */ -#if !HAVE_UNISTD_H #ifndef F_OK #define F_OK 0 #endif /* !defined F_OK */ #ifndef R_OK #define R_OK 4 #endif /* !defined R_OK */ -#endif /* !HAVE_UNISTD_H */ /* Unlike 's isdigit, this also works if c < 0 | c > UCHAR_MAX. */ #define is_digit(c) ((unsigned)(c) - '0' <= 9) @@ -137,7 +130,7 @@ #endif /* !defined HAVE_STDINT_H */ #if HAVE_STDINT_H -#include "stdint.h" +#include #endif /* !HAVE_STDINT_H */ #ifndef INT_FAST64_MAX @@ -165,69 +158,13 @@ */ /* -** SunOS 4.1.1 headers lack EXIT_SUCCESS. -*/ - -#ifndef EXIT_SUCCESS -#define EXIT_SUCCESS 0 -#endif /* !defined EXIT_SUCCESS */ - -/* -** SunOS 4.1.1 headers lack EXIT_FAILURE. -*/ - -#ifndef EXIT_FAILURE -#define EXIT_FAILURE 1 -#endif /* !defined EXIT_FAILURE */ - -/* -** SunOS 4.1.1 headers lack FILENAME_MAX. -*/ - -#ifndef FILENAME_MAX - -#ifndef MAXPATHLEN -#ifdef unix -#include "sys/param.h" -#endif /* defined unix */ -#endif /* !defined MAXPATHLEN */ - -#ifdef MAXPATHLEN -#define FILENAME_MAX MAXPATHLEN -#endif /* defined MAXPATHLEN */ -#ifndef MAXPATHLEN -#define FILENAME_MAX 1024 /* Pure guesswork */ -#endif /* !defined MAXPATHLEN */ - -#endif /* !defined FILENAME_MAX */ - -/* -** SunOS 4.1.1 libraries lack remove. -*/ - -#ifndef remove -extern int unlink(const char * filename); -#define remove unlink -#endif /* !defined remove */ - -/* -** Some ancient errno.h implementations don't declare errno. -** But some newer errno.h implementations define it as a macro. -** Fix the former without affecting the latter. -*/ - -#ifndef errno -extern int errno; -#endif /* !defined errno */ - -/* ** Some time.h implementations don't declare asctime_r. ** Others might define it as a macro. ** Fix the former without affecting the latter. */ #ifndef asctime_r -extern char * asctime_r(); +extern char * asctime_r(struct tm const *, char *); #endif /* diff -ru tzcode2007h-less-P-macro/scheck.c tzcode2007-pre-i/scheck.c --- tzcode2007h-less-P-macro/scheck.c 2007-08-20 07:47:42.000000000 -0700 +++ tzcode2007-pre-i/scheck.c 2007-11-13 15:08:32.938146058 -0800 @@ -14,9 +14,7 @@ #include "private.h" const char * -scheck(string, format) -const char * const string; -const char * const format; +scheck(const char * const string, const char * const format) { register char * fbuf; register const char * fp; @@ -57,7 +55,7 @@ *tp++ = 'c'; *tp = '\0'; if (sscanf(string, fbuf, &dummy) != 1) - result = (char *) format; + result = format; ifree(fbuf); return result; } diff -ru tzcode2007h-less-P-macro/strftime.c tzcode2007-pre-i/strftime.c --- tzcode2007h-less-P-macro/strftime.c 2007-11-11 16:56:07.968180339 -0800 +++ tzcode2007-pre-i/strftime.c 2007-11-13 15:08:32.938146058 -0800 @@ -34,8 +34,8 @@ #endif /* !defined LIBC_SCCS */ #include "tzfile.h" -#include "fcntl.h" -#include "locale.h" +#include +#include struct lc_time_T { const char * mon[MONSPERYEAR]; @@ -51,7 +51,7 @@ }; #ifdef LOCALE_HOME -#include "sys/stat.h" +#include static struct lc_time_T localebuf; static struct lc_time_T * _loc(void); #define Locale _loc() @@ -124,11 +124,10 @@ #define IN_ALL 3 size_t -strftime(s, maxsize, format, t) -char * const s; -const size_t maxsize; -const char * const format; -const struct tm * const t; +strftime(char * const s, + const size_t maxsize, + const char * const format, + const struct tm * const t) { char * p; int warn; @@ -162,12 +161,11 @@ } static char * -_fmt(format, t, pt, ptlim, warnp) -const char * format; -const struct tm * const t; -char * pt; -const char * const ptlim; -int * warnp; +_fmt(const char * format, + const struct tm * const t, + char * pt, + const char * const ptlim, + int * warnp) { for ( ; *format; ++format) { if (*format == '%') { @@ -575,11 +573,10 @@ } static char * -_conv(n, format, pt, ptlim) -const int n; -const char * const format; -char * const pt; -const char * const ptlim; +_conv(const int n, + const char * const format, + char * const pt, + const char * const ptlim) { char buf[INT_STRLEN_MAXIMUM(int) + 1]; @@ -588,10 +585,7 @@ } static char * -_add(str, pt, ptlim) -const char * str; -char * pt; -const char * const ptlim; +_add(const char * str, char * pt, const char * const ptlim) { while (pt < ptlim && (*pt = *str++) != '\0') ++pt; @@ -607,13 +601,12 @@ */ static char * -_yconv(a, b, convert_top, convert_yy, pt, ptlim) -const int a; -const int b; -const int convert_top; -const int convert_yy; -char * pt; -const char * const ptlim; +_yconv(const int a, + const int b, + const int convert_top, + const int convert_yy, + char * pt, + const char * const ptlim) { register int lead; register int trail; diff -ru tzcode2007h-less-P-macro/zdump.c tzcode2007-pre-i/zdump.c --- tzcode2007h-less-P-macro/zdump.c 2007-11-11 16:56:10.112302526 -0800 +++ tzcode2007-pre-i/zdump.c 2007-11-13 15:27:06.301593025 -0800 @@ -6,16 +6,13 @@ ** You can use this code to help in verifying other implementations. */ -#include "stdio.h" /* for stdout, stderr, perror */ -#include "string.h" /* for strcpy */ -#include "sys/types.h" /* for time_t */ -#include "time.h" /* for struct tm */ -#include "stdlib.h" /* for exit, malloc, atoi */ -#include "float.h" /* for FLT_MAX and DBL_MAX */ -#include "ctype.h" /* for isalpha et al. */ -#ifndef isascii -#define isascii(x) 1 -#endif /* !defined isascii */ +#include /* for stdout, stderr, perror */ +#include /* for strcpy */ +#include /* for time_t */ +#include /* for struct tm */ +#include /* for exit, malloc, atoi */ +#include /* for FLT_MAX and DBL_MAX */ +#include /* for isalpha et al. */ #ifndef ZDUMP_LO_YEAR #define ZDUMP_LO_YEAR (-500) @@ -88,9 +85,12 @@ #define SECSPERNYEAR (SECSPERDAY * DAYSPERNYEAR) #define SECSPERLYEAR (SECSPERNYEAR + SECSPERDAY) +#ifndef HAVE_GETTEXT +# define HAVE_GETTEXT 0 +#endif #if HAVE_GETTEXT -#include "locale.h" /* for setlocale */ -#include "libintl.h" +#include /* for setlocale */ +#include #endif /* HAVE_GETTEXT */ #ifndef GNUC_or_lint @@ -129,10 +129,6 @@ #define TZ_DOMAIN "tz" #endif /* !defined TZ_DOMAIN */ -#ifndef P -#define P(x) x -#endif /* !defined P */ - extern char ** environ; extern int getopt(int argc, char * const argv[], const char * options); @@ -160,8 +156,7 @@ #define my_localtime localtime #else /* !defined TYPECHECK */ static struct tm * -my_localtime(tp) -time_t * tp; +my_localtime(time_t * tp) { register struct tm * tmp; @@ -194,18 +189,16 @@ #endif /* !defined TYPECHECK */ static void -abbrok(abbrp, zone) -const char * const abbrp; -const char * const zone; +abbrok(const char * const abbrp, const char * const zone) { register const char * cp; - register char * wp; + register const char * wp; if (warned) return; cp = abbrp; wp = NULL; - while (isascii((unsigned char) *cp) && isalpha((unsigned char) *cp)) + while (isalpha((unsigned char) *cp)) ++cp; if (cp - abbrp == 0) wp = _("lacks alphabetic at start"); @@ -215,8 +208,7 @@ wp = _("has more than 6 alphabetics"); if (wp == NULL && (*cp == '+' || *cp == '-')) { ++cp; - if (isascii((unsigned char) *cp) && - isdigit((unsigned char) *cp)) + if (isdigit((unsigned char) *cp)) if (*cp++ == '1' && *cp >= '0' && *cp <= '4') ++cp; if (*cp != '\0') @@ -232,9 +224,7 @@ } int -main(argc, argv) -int argc; -char * argv[]; +main(int argc, char **argv) { register int i; register int c; @@ -394,7 +384,7 @@ } static void -setabsolutes() +setabsolutes(void) { if (0.5 == (time_t) 0.5) { /* @@ -439,8 +429,7 @@ } static time_t -yeartot(y) -const long y; +yeartot(const long y) { register long myy; register long seconds; @@ -518,9 +507,7 @@ */ static long -delta(newp, oldp) -struct tm * newp; -struct tm * oldp; +delta(struct tm * newp, struct tm * oldp) { register long result; register int tmy; @@ -574,8 +561,7 @@ } static char * -abbr(tmp) -struct tm * tmp; +abbr(struct tm *tmp) { register char * result; static char nada; @@ -592,7 +578,7 @@ */ static const char * -tformat() +tformat(void) { if (0.5 == (time_t) 0.5) { /* floating */ if (sizeof (time_t) > sizeof (double)) @@ -614,8 +600,7 @@ } static void -dumptime(timeptr) -register const struct tm * timeptr; +dumptime(register const struct tm *timeptr) { static const char wday_name[][3] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" diff -ru tzcode2007h-less-P-macro/zic.c tzcode2007-pre-i/zic.c --- tzcode2007h-less-P-macro/zic.c 2007-11-11 16:56:11.636389379 -0800 +++ tzcode2007-pre-i/zic.c 2007-11-13 15:36:59.163378292 -0800 @@ -6,7 +6,7 @@ static char elsieid[] = "@(#)zic.c 8.15"; #include "private.h" -#include "locale.h" +#include #include "tzfile.h" #define ZIC_VERSION '2' @@ -18,7 +18,7 @@ #endif /* !defined ZIC_MAX_ABBR_LEN_WO_WARN */ #if HAVE_SYS_STAT_H -#include "sys/stat.h" +#include #endif #ifdef S_IRUSR #define MKDIR_UMASK (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) @@ -26,18 +26,7 @@ #define MKDIR_UMASK 0755 #endif -/* -** On some ancient hosts, predicates like `isspace(C)' are defined -** only if isascii(C) || C == EOF. Modern hosts obey the C Standard, -** which says they are defined only if C == ((unsigned char) C) || C == EOF. -** Neither the C Standard nor Posix require that `isascii' exist. -** For portability, we check both ancient and modern requirements. -** If isascii is not defined, the isascii check succeeds trivially. -*/ -#include "ctype.h" -#ifndef isascii -#define isascii(x) 1 -#endif +#include #define OFFSET_STRLEN_MAXIMUM (7 + INT_STRLEN_MAXIMUM(long)) #define RULE_STRLEN_MAXIMUM 8 /* "Mdd.dd.d" */ @@ -160,10 +149,6 @@ static void writezone(const char * name, const char * string); static int yearistype(int year, const char * type); -#if !HAVE_STRERROR -static char * strerror(int); -#endif /* !HAVE_STRERROR */ - static int charcnt; static int errors; static const char * filename; @@ -172,8 +157,8 @@ static int leapminyear; static int leapmaxyear; static int linenum; -static int max_abbrvar_len; -static int max_format_len; +static size_t max_abbrvar_len; +static size_t max_format_len; static zic_t max_time; static int max_year; static zic_t min_time; @@ -383,8 +368,7 @@ */ static char * -memcheck(ptr) -char * const ptr; +memcheck(char * const ptr) { if (ptr == NULL) { const char *e = strerror(errno); @@ -405,25 +389,11 @@ ** Error handling. */ -#if !HAVE_STRERROR -static char * -strerror(errnum) -int errnum; -{ - extern char * sys_errlist[]; - extern int sys_nerr; - - return (errnum > 0 && errnum <= sys_nerr) ? - sys_errlist[errnum] : _("Unknown system error"); -} -#endif /* !HAVE_STRERROR */ - static void -eats(name, num, rname, rnum) -const char * const name; -const int num; -const char * const rname; -const int rnum; +eats(const char * const name, + const int num, + const char * const rname, + const int rnum) { filename = name; linenum = num; @@ -432,16 +402,13 @@ } static void -eat(name, num) -const char * const name; -const int num; +eat(const char * const name, const int num) { eats(name, num, (char *) NULL, -1); } static void -error(string) -const char * const string; +error(const char * const string) { /* ** Match the format of "cc" to allow sh users to @@ -458,8 +425,7 @@ } static void -warning(string) -const char * const string; +warning(const char * const string) { char * cp; @@ -487,9 +453,7 @@ static const char * yitcommand; int -main(argc, argv) -int argc; -char * argv[]; +main(int argc, char **argv) { register int i; register int j; @@ -628,9 +592,7 @@ } static void -dolink(fromfield, tofield) -const char * const fromfield; -const char * const tofield; +dolink(const char * const fromfield, const char * const tofield) { register char * fromname; register char * toname; @@ -710,8 +672,7 @@ } static int -itsdir(name) -const char * const name; +itsdir(const char * const name) { register char * myname; register int accres; @@ -732,9 +693,7 @@ */ static int -rcomp(cp1, cp2) -const void * cp1; -const void * cp2; +rcomp(const void * cp1, const void * cp2) { return strcmp(((const struct rule *) cp1)->r_name, ((const struct rule *) cp2)->r_name); @@ -817,8 +776,7 @@ } static void -infile(name) -const char * name; +infile(const char * name) { register FILE * fp; register char ** fields; @@ -921,10 +879,7 @@ */ static long -gethms(string, errstring, signable) -const char * string; -const char * const errstring; -const int signable; +gethms(const char * string, const char * const errstring, const int signable) { long hh; int mm, ss, sign; @@ -966,9 +921,7 @@ } static void -inrule(fields, nfields) -register char ** const fields; -const int nfields; +inrule(register char ** const fields, const int nfields) { static struct rule r; @@ -995,9 +948,7 @@ } static int -inzone(fields, nfields) -register char ** const fields; -const int nfields; +inzone(register char ** const fields, const int nfields) { register int i; static char * buf; @@ -1040,9 +991,7 @@ } static int -inzcont(fields, nfields) -register char ** const fields; -const int nfields; +inzcont(register char ** const fields, const int nfields) { if (nfields < ZONEC_MINFIELDS || nfields > ZONEC_MAXFIELDS) { error(_("wrong number of fields on Zone continuation line")); @@ -1052,10 +1001,7 @@ } static int -inzsub(fields, nfields, iscont) -register char ** const fields; -const int nfields; -const int iscont; +inzsub(register char ** const fields, const int nfields, const int iscont) { register char * cp; static struct zone z; @@ -1133,9 +1079,7 @@ } static void -inleap(fields, nfields) -register char ** const fields; -const int nfields; +inleap(register char ** const fields, const int nfields) { register const char * cp; register const struct lookup * lp; @@ -1237,9 +1181,7 @@ } static void -inlink(fields, nfields) -register char ** const fields; -const int nfields; +inlink(register char ** const fields, const int nfields) { struct link l; @@ -1265,14 +1207,13 @@ } static void -rulesub(rp, loyearp, hiyearp, typep, monthp, dayp, timep) -register struct rule * const rp; -const char * const loyearp; -const char * const hiyearp; -const char * const typep; -const char * const monthp; -const char * const dayp; -const char * const timep; +rulesub(register struct rule * const rp, + const char * const loyearp, + const char * const hiyearp, + const char * const typep, + const char * const monthp, + const char * const dayp, + const char * const timep) { register const struct lookup * lp; register const char * cp; @@ -1416,9 +1357,7 @@ } static void -convert(val, buf) -const long val; -char * const buf; +convert(const long val, char * const buf) { register int i; register int shift; @@ -1428,9 +1367,7 @@ } static void -convert64(val, buf) -const zic_t val; -char * const buf; +convert64(const zic_t val, char * const buf) { register int i; register int shift; @@ -1440,9 +1377,7 @@ } static void -puttzcode(val, fp) -const long val; -FILE * const fp; +puttzcode(const long val, FILE * const fp) { char buf[4]; @@ -1451,9 +1386,7 @@ } static void -puttzcode64(val, fp) -const zic_t val; -FILE * const fp; +puttzcode64(const zic_t val, FILE * const fp) { char buf[8]; @@ -1462,9 +1395,7 @@ } static int -atcomp(avp, bvp) -const void * avp; -const void * bvp; +atcomp(const void * avp, const void * bvp) { const zic_t a = ((const struct attype *) avp)->at; const zic_t b = ((const struct attype *) bvp)->at; @@ -1473,16 +1404,13 @@ } static int -is32(x) -const zic_t x; +is32(const zic_t x) { return INT32_MIN <= x && x <= INT32_MAX; } static void -writezone(name, string) -const char * const name; -const char * const string; +writezone(const char * const name, const char * const string) { register FILE * fp; register int i, j; @@ -1743,12 +1671,11 @@ } static void -doabbr(abbr, format, letters, isdst, doquotes) -char * const abbr; -const char * const format; -const char * const letters; -const int isdst; -const int doquotes; +doabbr(char * const abbr, + const char * const format, + const char * const letters, + const int isdst, + const int doquotes) { register char * cp; register char * slashp; @@ -1764,7 +1691,7 @@ } else { if (slashp > format) (void) strncpy(abbr, format, - (unsigned) (slashp - format)); + (slashp - format)); abbr[slashp - format] = '\0'; } if (!doquotes) @@ -1784,8 +1711,7 @@ } static void -updateminmax(x) -const int x; +updateminmax(const int x) { if (min_year > x) min_year = x; @@ -1794,9 +1720,7 @@ } static int -stringoffset(result, offset) -char * result; -long offset; +stringoffset(char * result, long offset) { register int hours; register int minutes; @@ -1826,11 +1750,10 @@ } static int -stringrule(result, rp, dstoff, gmtoff) -char * result; -const struct rule * const rp; -const long dstoff; -const long gmtoff; +stringrule(char *result, + const struct rule * const rp, + const long dstoff, + const long gmtoff) { register long tod; @@ -1881,10 +1804,9 @@ } static void -stringzone(result, zpfirst, zonecount) -char * result; -const struct zone * const zpfirst; -const int zonecount; +stringzone(char * result, + const struct zone * const zpfirst, + const int zonecount) { register const struct zone * zp; register struct rule * rp; @@ -1964,9 +1886,7 @@ } static void -outzone(zpfirst, zonecount) -const struct zone * const zpfirst; -const int zonecount; +outzone(const struct zone * const zpfirst, const int zonecount) { register const struct zone * zp; register struct rule * rp; @@ -2209,9 +2129,7 @@ } static void -addtt(starttime, type) -const zic_t starttime; -int type; +addtt(const zic_t starttime, int type) { if (starttime <= min_time || (timecnt == 1 && attypes[0].at < min_time)) { @@ -2237,12 +2155,11 @@ } static int -addtype(gmtoff, abbr, isdst, ttisstd, ttisgmt) -const long gmtoff; -const char * const abbr; -const int isdst; -const int ttisstd; -const int ttisgmt; +addtype(const long gmtoff, + const char * const abbr, + const int isdst, + const int ttisstd, + const int ttisgmt) { register int i, j; @@ -2297,11 +2214,7 @@ } static void -leapadd(t, positive, rolling, count) -const zic_t t; -const int positive; -const int rolling; -int count; +leapadd(const zic_t t, const int positive, const int rolling, int count) { register int i, j; @@ -2346,9 +2259,7 @@ } static int -yearistype(year, type) -const int year; -const char * const type; +yearistype(const int year, const char * const type) { static char * buf; int result; @@ -2372,17 +2283,15 @@ } static int -lowerit(a) -int a; +lowerit(int a) { a = (unsigned char) a; - return (isascii(a) && isupper(a)) ? tolower(a) : a; + return (isupper(a)) ? tolower(a) : a; } static int -ciequal(ap, bp) /* case-insensitive equality */ -register const char * ap; -register const char * bp; +ciequal(register const char *ap, + register const char *bp) /* case-insensitive equality */ { while (lowerit(*ap) == lowerit(*bp++)) if (*ap++ == '\0') @@ -2391,9 +2300,7 @@ } static int -itsabbr(abbr, word) -register const char * abbr; -register const char * word; +itsabbr(register const char *abbr, register const char *word) { if (lowerit(*abbr) != lowerit(*word)) return FALSE; @@ -2407,9 +2314,8 @@ } static const struct lookup * -byword(word, table) -register const char * const word; -register const struct lookup * const table; +byword(register const char * const word, + register const struct lookup * const table) { register const struct lookup * foundlp; register const struct lookup * lp; @@ -2436,8 +2342,7 @@ } static char ** -getfields(cp) -register char * cp; +getfields(register char *cp) { register char * dp; register char ** array; @@ -2449,8 +2354,7 @@ emalloc((int) ((strlen(cp) + 1) * sizeof *array)); nsubs = 0; for ( ; ; ) { - while (isascii((unsigned char) *cp) && - isspace((unsigned char) *cp)) + while (isspace((unsigned char) *cp)) ++cp; if (*cp == '\0' || *cp == '#') break; @@ -2468,8 +2372,8 @@ exit(1); } } while (*cp != '\0' && *cp != '#' && - (!isascii(*cp) || !isspace((unsigned char) *cp))); - if (isascii(*cp) && isspace((unsigned char) *cp)) + !isspace((unsigned char) *cp)); + if (isspace((unsigned char) *cp)) ++cp; *dp = '\0'; } @@ -2478,9 +2382,7 @@ } static long -oadd(t1, t2) -const long t1; -const long t2; +oadd(const long t1, const long t2) { register long t; @@ -2493,9 +2395,7 @@ } static zic_t -tadd(t1, t2) -const zic_t t1; -const long t2; +tadd(const zic_t t1, const long t2) { register zic_t t; @@ -2517,9 +2417,7 @@ */ static zic_t -rpytime(rp, wantedy) -register const struct rule * const rp; -register const int wantedy; +rpytime(register const struct rule * const rp, register const int wantedy) { register int y, m, i; register long dayoff; /* with a nod to Margaret O. */ @@ -2600,14 +2498,13 @@ } static void -newabbr(string) -const char * const string; +newabbr(const char * const string) { register int i; if (strcmp(string, GRANDPARENTED) != 0) { register const char * cp; - register char * wp; + register const char * wp; /* ** Want one to ZIC_MAX_ABBR_LEN_WO_WARN alphabetics @@ -2615,8 +2512,7 @@ */ cp = string; wp = NULL; - while (isascii((unsigned char) *cp) && - isalpha((unsigned char) *cp)) + while (isalpha((unsigned char) *cp)) ++cp; if (cp - string == 0) wp = _("time zone abbreviation lacks alphabetic at start"); @@ -2626,8 +2522,7 @@ wp = _("time zone abbreviation has too many alphabetics"); if (wp == NULL && (*cp == '+' || *cp == '-')) { ++cp; - if (isascii((unsigned char) *cp) && - isdigit((unsigned char) *cp)) + if (isdigit((unsigned char) *cp)) if (*cp++ == '1' && *cp >= '0' && *cp <= '4') ++cp; @@ -2635,12 +2530,12 @@ if (*cp != '\0') wp = _("time zone abbreviation differs from POSIX standard"); if (wp != NULL) { - wp = ecpyalloc(wp); - wp = ecatalloc(wp, " ("); - wp = ecatalloc(wp, string); - wp = ecatalloc(wp, ")"); - warning(wp); - ifree(wp); + char *xp = ecpyalloc(wp); + xp = ecatalloc(xp, " ("); + xp = ecatalloc(xp, string); + xp = ecatalloc(xp, ")"); + warning(xp); + ifree(xp); } } i = strlen(string) + 1; @@ -2653,8 +2548,7 @@ } static int -mkdirs(argname) -char * argname; +mkdirs(char * argname) { register char * name; register char * cp; @@ -2700,8 +2594,7 @@ } static long -eitol(i) -const int i; +eitol(const int i) { long l;