Here are proposed changes to eliminate the "P" macro from time zone source (a first step in simplifying the code by assuming C99 compilers). --ado ------- date.c ------- *** /tmp/geta13002 Thu Nov 8 09:23:34 2007 --- /tmp/getb13002 Thu Nov 8 09:23:34 2007 *************** *** 1,6 **** #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)date.c 8.2"; /* ** Modified from the UCB version with the SCCS ID appearing below. */ --- 1,6 ---- #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)date.c 8.3"; /* ** Modified from the UCB version with the SCCS ID appearing below. */ *************** *** 75,95 **** static int retval = EXIT_SUCCESS; ! static void checkfinal P((const char *, int, time_t, time_t)); ! static int comptm P((const struct tm *, const struct tm *)); ! static time_t convert P((const char *, int, time_t)); ! static void display P((const char *)); ! static void dogmt P((void)); ! static void errensure P((void)); ! static void iffy P((time_t, time_t, const char *, const char *)); ! int main P((int, char**)); ! static const char * nondigit P((const char *)); ! static void oops P((const char *)); ! static void reset P((time_t, int)); ! static void timeout P((FILE *, const char *, const struct tm *)); ! static void usage P((void)); ! static void wildinput P((const char *, const char *, ! const char *)); int main(argc, argv) --- 75,95 ---- static int retval = EXIT_SUCCESS; ! static void checkfinal(const char *, int, time_t, time_t); ! static int comptm(const struct tm *, const struct tm *); ! static time_t convert(const char *, int, time_t); ! static void display(const char *); ! static void dogmt(void); ! static void errensure(void); ! static void iffy(time_t, time_t, const char *, const char *); ! int main(int, char**); ! static const char * nondigit(const char *); ! static void oops(const char *); ! static void reset(time_t, int); ! static void timeout(FILE *, const char *, const struct tm *); ! static void usage(void); ! static void wildinput(const char *, const char *, ! const char *); int main(argc, argv) *************** *** 499,505 **** } static void ! errensure P((void)) { if (retval == EXIT_SUCCESS) retval = EXIT_FAILURE; --- 499,505 ---- } static void ! errensure(void) { if (retval == EXIT_SUCCESS) retval = EXIT_FAILURE; *************** *** 515,521 **** } static void ! usage P((void)) { (void) fprintf(stderr, _("date: usage is date [-u] [-c] [-n] [-d dst] \ [-t min-west] [-a sss.fff] [[yyyy]mmddhhmm[yyyy][.ss]] [+format]\n")); --- 515,521 ---- } static void ! usage(void) { (void) fprintf(stderr, _("date: usage is date [-u] [-c] [-n] [-d dst] \ [-t min-west] [-a sss.fff] [[yyyy]mmddhhmm[yyyy][.ss]] [+format]\n")); ------- localtime.c ------- *** /tmp/geta13021 Thu Nov 8 09:23:35 2007 --- /tmp/getb13021 Thu Nov 8 09:23:35 2007 *************** *** 5,11 **** #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)localtime.c 8.5"; #endif /* !defined NOID */ #endif /* !defined lint */ --- 5,11 ---- #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)localtime.c 8.6"; #endif /* !defined NOID */ #endif /* !defined lint */ *************** *** 136,186 **** ** Prototypes for static functions. */ ! static long detzcode P((const char * codep)); ! static time_t detzcode64 P((const char * codep)); ! static int differ_by_repeat P((time_t t1, time_t t0)); ! static const char * getzname P((const char * strp)); ! static const char * getqzname P((const char * strp, const int delim)); ! static const char * getnum P((const char * strp, int * nump, int min, ! int max)); ! static const char * getsecs P((const char * strp, long * secsp)); ! static const char * getoffset P((const char * strp, long * offsetp)); ! static const char * getrule P((const char * strp, struct rule * rulep)); ! static void gmtload P((struct state * sp)); ! static struct tm * gmtsub P((const time_t * timep, long offset, ! struct tm * tmp)); ! static struct tm * localsub P((const time_t * timep, long offset, ! struct tm * tmp)); ! static int increment_overflow P((int * number, int delta)); ! static int leaps_thru_end_of P((int y)); ! static int long_increment_overflow P((long * number, int delta)); ! static int long_normalize_overflow P((long * tensptr, ! int * unitsptr, int base)); ! static int normalize_overflow P((int * tensptr, int * unitsptr, ! int base)); ! static void settzname P((void)); ! static time_t time1 P((struct tm * tmp, ! struct tm * (*funcp) P((const time_t *, ! long, struct tm *)), ! long offset)); ! static time_t time2 P((struct tm *tmp, ! struct tm * (*funcp) P((const time_t *, ! long, struct tm*)), ! long offset, int * okayp)); ! static time_t time2sub P((struct tm *tmp, ! struct tm * (*funcp) P((const time_t *, ! long, struct tm*)), ! long offset, int * okayp, int do_norm_secs)); ! static struct tm * timesub P((const time_t * timep, long offset, ! const struct state * sp, struct tm * tmp)); ! static int tmcomp P((const struct tm * atmp, ! const struct tm * btmp)); ! static time_t transtime P((time_t janfirst, int year, ! const struct rule * rulep, long offset)); ! static int tzload P((const char * name, struct state * sp, ! int doextend)); ! static int tzparse P((const char * name, struct state * sp, ! int lastditch)); #ifdef ALL_STATE static struct state * lclptr; --- 136,186 ---- ** Prototypes for static functions. */ ! static long detzcode(const char * codep); ! static time_t detzcode64(const char * codep); ! static int differ_by_repeat(time_t t1, time_t t0); ! static const char * getzname(const char * strp); ! static const char * getqzname(const char * strp, const int delim); ! static const char * getnum(const char * strp, int * nump, int min, ! int max); ! static const char * getsecs(const char * strp, long * secsp); ! static const char * getoffset(const char * strp, long * offsetp); ! static const char * getrule(const char * strp, struct rule * rulep); ! static void gmtload(struct state * sp); ! static struct tm * gmtsub(const time_t * timep, long offset, ! struct tm * tmp); ! static struct tm * localsub(const time_t * timep, long offset, ! struct tm * tmp); ! static int increment_overflow(int * number, int delta); ! static int leaps_thru_end_of(int y); ! static int long_increment_overflow(long * number, int delta); ! static int long_normalize_overflow(long * tensptr, ! int * unitsptr, int base); ! static int normalize_overflow(int * tensptr, int * unitsptr, ! int base); ! static void settzname(void); ! static time_t time1(struct tm * tmp, ! struct tm * (*funcp)(const time_t *, ! long, struct tm *), ! long offset); ! static time_t time2(struct tm *tmp, ! struct tm * (*funcp)(const time_t *, ! long, struct tm*), ! long offset, int * okayp); ! static time_t time2sub(struct tm *tmp, ! struct tm * (*funcp)(const time_t *, ! long, struct tm*), ! long offset, int * okayp, int do_norm_secs); ! static struct tm * timesub(const time_t * timep, long offset, ! const struct state * sp, struct tm * tmp); ! static int tmcomp(const struct tm * atmp, ! const struct tm * btmp); ! static time_t transtime(time_t janfirst, int year, ! const struct rule * rulep, long offset); ! static int tzload(const char * name, struct state * sp, ! int doextend); ! static int tzparse(const char * name, struct state * sp, ! int lastditch); #ifdef ALL_STATE static struct state * lclptr; *************** *** 253,259 **** } static void ! settzname P((void)) { register struct state * const sp = lclptr; register int i; --- 253,259 ---- } static void ! settzname(void) { register struct state * const sp = lclptr; register int i; *************** *** 1120,1126 **** static #endif /* !defined STD_INSPIRED */ void ! tzsetwall P((void)) { if (lcl_is_set < 0) return; --- 1120,1126 ---- static #endif /* !defined STD_INSPIRED */ void ! tzsetwall(void) { if (lcl_is_set < 0) return; *************** *** 1141,1147 **** } void ! tzset P((void)) { register const char * name; --- 1141,1147 ---- } void ! tzset(void) { register const char * name; *************** *** 1639,1645 **** static time_t time2sub(tmp, funcp, offset, okayp, do_norm_secs) struct tm * const tmp; ! struct tm * (* const funcp) P((const time_t*, long, struct tm*)); const long offset; int * const okayp; const int do_norm_secs; --- 1639,1645 ---- 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; *************** *** 1827,1833 **** static time_t time2(tmp, funcp, offset, okayp) struct tm * const tmp; ! struct tm * (* const funcp) P((const time_t*, long, struct tm*)); const long offset; int * const okayp; { --- 1827,1833 ---- 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; { *************** *** 1845,1851 **** static time_t time1(tmp, funcp, offset) struct tm * const tmp; ! struct tm * (* const funcp) P((const time_t *, long, struct tm *)); const long offset; { register time_t t; --- 1845,1851 ---- static time_t time1(tmp, funcp, offset) struct tm * const tmp; ! struct tm * (* const funcp)(const time_t *, long, struct tm *); const long offset; { register time_t t; ------- private.h ------- *** /tmp/geta13040 Thu Nov 8 09:23:35 2007 --- /tmp/getb13040 Thu Nov 8 09:23:35 2007 *************** *** 21,27 **** #ifndef lint #ifndef NOID ! static char privatehid[] = "@(#)private.h 8.3"; #endif /* !defined NOID */ #endif /* !defined lint */ --- 21,27 ---- #ifndef lint #ifndef NOID ! static char privatehid[] = "@(#)private.h 8.4"; #endif /* !defined NOID */ #endif /* !defined lint */ *************** *** 165,178 **** */ /* - ** If your compiler lacks prototypes, "#define P(x) ()". - */ - - #ifndef P - #define P(x) x - #endif /* !defined P */ - - /* ** SunOS 4.1.1 headers lack EXIT_SUCCESS. */ --- 165,170 ---- *************** *** 214,220 **** */ #ifndef remove ! extern int unlink P((const char * filename)); #define remove unlink #endif /* !defined remove */ --- 206,212 ---- */ #ifndef remove ! extern int unlink(const char * filename); #define remove unlink #endif /* !defined remove */ *************** *** 242,255 **** ** Private function declarations. */ ! char * icalloc P((int nelem, int elsize)); ! char * icatalloc P((char * old, const char * new)); ! char * icpyalloc P((const char * string)); ! char * imalloc P((int n)); ! void * irealloc P((void * pointer, int size)); ! void icfree P((char * pointer)); ! void ifree P((char * pointer)); ! const char * scheck P((const char * string, const char * format)); /* ** Finally, some convenience items. --- 234,247 ---- ** Private function declarations. */ ! char * icalloc(int nelem, int elsize); ! char * icatalloc(char * old, const char * new); ! char * icpyalloc(const char * string); ! char * imalloc(int n); ! void * irealloc(void * pointer, int size); ! void icfree(char * pointer); ! void ifree(char * pointer); ! const char * scheck(const char * string, const char * format); /* ** Finally, some convenience items. *************** *** 337,344 **** #if HAVE_INCOMPATIBLE_CTIME_R #undef asctime_r #undef ctime_r ! char *asctime_r P((struct tm const *, char *)); ! char *ctime_r P((time_t const *, char *)); #endif /* HAVE_INCOMPATIBLE_CTIME_R */ #ifndef YEARSPERREPEAT --- 329,336 ---- #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 ------- strftime.c ------- *** /tmp/geta13059 Thu Nov 8 09:23:35 2007 --- /tmp/getb13059 Thu Nov 8 09:23:35 2007 *************** *** 1,6 **** #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)strftime.c 8.1"; /* ** Based on the UCB version with the ID appearing below. ** This is ANSIish only when "multibyte character == plain character". --- 1,6 ---- #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)strftime.c 8.2"; /* ** Based on the UCB version with the ID appearing below. ** This is ANSIish only when "multibyte character == plain character". *************** *** 53,59 **** #ifdef LOCALE_HOME #include "sys/stat.h" static struct lc_time_T localebuf; ! static struct lc_time_T * _loc P((void)); #define Locale _loc() #endif /* defined LOCALE_HOME */ #ifndef LOCALE_HOME --- 53,59 ---- #ifdef LOCALE_HOME #include "sys/stat.h" static struct lc_time_T localebuf; ! static struct lc_time_T * _loc(void); #define Locale _loc() #endif /* defined LOCALE_HOME */ #ifndef LOCALE_HOME *************** *** 106,116 **** "%a %b %e %H:%M:%S %Z %Y" }; ! static char * _add P((const char *, char *, const char *)); ! static char * _conv P((int, const char *, char *, const char *)); ! static char * _fmt P((const char *, const struct tm *, char *, const char *, ! int *)); ! static char * _yconv P((int, int, int, int, char *, const char *)); extern char * tzname[]; --- 106,116 ---- "%a %b %e %H:%M:%S %Z %Y" }; ! static char * _add(const char *, char *, const char *); ! static char * _conv(int, const char *, char *, const char *); ! static char * _fmt(const char *, const struct tm *, char *, const char *, ! int *); ! static char * _yconv(int, int, int, int, char *, const char *); extern char * tzname[]; *************** *** 641,647 **** #ifdef LOCALE_HOME static struct lc_time_T * ! _loc P((void)) { static const char locale_home[] = LOCALE_HOME; static const char lc_time[] = "LC_TIME"; --- 641,647 ---- #ifdef LOCALE_HOME static struct lc_time_T * ! _loc(void) { static const char locale_home[] = LOCALE_HOME; static const char lc_time[] = "LC_TIME"; ------- zdump.c ------- *** /tmp/geta13078 Thu Nov 8 09:23:36 2007 --- /tmp/getb13078 Thu Nov 8 09:23:36 2007 *************** *** 1,4 **** ! static char elsieid[] = "@(#)zdump.c 8.4"; /* ** This code has been made independent of the rest of the time --- 1,4 ---- ! static char elsieid[] = "@(#)zdump.c 8.5"; /* ** This code has been made independent of the rest of the time *************** *** 134,141 **** #endif /* !defined P */ extern char ** environ; ! extern int getopt P((int argc, char * const argv[], ! const char * options)); extern char * optarg; extern int optind; extern char * tzname[2]; --- 134,141 ---- #endif /* !defined P */ extern char ** environ; ! extern int getopt(int argc, char * const argv[], ! const char * options); extern char * optarg; extern int optind; extern char * tzname[2]; *************** *** 146,160 **** static char * progname; static int warned; ! static char * abbr P((struct tm * tmp)); ! static void abbrok P((const char * abbrp, const char * zone)); ! static long delta P((struct tm * newp, struct tm * oldp)); ! static void dumptime P((const struct tm * tmp)); ! static time_t hunt P((char * name, time_t lot, time_t hit)); ! static void setabsolutes P((void)); ! static void show P((char * zone, time_t t, int v)); ! static const char * tformat P((void)); ! static time_t yeartot P((long y)); #ifndef TYPECHECK #define my_localtime localtime --- 146,160 ---- static char * progname; static int warned; ! static char * abbr(struct tm * tmp); ! static void abbrok(const char * abbrp, const char * zone); ! static long delta(struct tm * newp, struct tm * oldp); ! static void dumptime(const struct tm * tmp); ! static time_t hunt(char * name, time_t lot, time_t hit); ! static void setabsolutes(void); ! static void show(char * zone, time_t t, int v); ! static const char * tformat(void); ! static time_t yeartot(long y); #ifndef TYPECHECK #define my_localtime localtime ------- zic.c ------- *** /tmp/geta13097 Thu Nov 8 09:23:36 2007 --- /tmp/getb13097 Thu Nov 8 09:23:36 2007 *************** *** 3,9 **** ** 2006-07-17 by Arthur David Olson. */ ! static char elsieid[] = "@(#)zic.c 8.14"; #include "private.h" #include "locale.h" --- 3,9 ---- ** 2006-07-17 by Arthur David Olson. */ ! static char elsieid[] = "@(#)zic.c 8.15"; #include "private.h" #include "locale.h" *************** *** 99,167 **** zic_t z_untiltime; }; ! extern int getopt P((int argc, char * const argv[], ! const char * options)); ! extern int link P((const char * fromname, const char * toname)); extern char * optarg; extern int optind; ! static void addtt P((zic_t starttime, int type)); ! static int addtype P((long gmtoff, const char * abbr, int isdst, ! int ttisstd, int ttisgmt)); ! static void leapadd P((zic_t t, int positive, int rolling, int count)); ! static void adjleap P((void)); ! static void associate P((void)); ! static int ciequal P((const char * ap, const char * bp)); ! static void convert P((long val, char * buf)); ! static void convert64 P((zic_t val, char * buf)); ! static void dolink P((const char * fromfield, const char * tofield)); ! static void doabbr P((char * abbr, const char * format, ! const char * letters, int isdst, int doquotes)); ! static void eat P((const char * name, int num)); ! static void eats P((const char * name, int num, ! const char * rname, int rnum)); ! static long eitol P((int i)); ! static void error P((const char * message)); ! static char ** getfields P((char * buf)); ! static long gethms P((const char * string, const char * errstrng, ! int signable)); ! static void infile P((const char * filename)); ! static void inleap P((char ** fields, int nfields)); ! static void inlink P((char ** fields, int nfields)); ! static void inrule P((char ** fields, int nfields)); ! static int inzcont P((char ** fields, int nfields)); ! static int inzone P((char ** fields, int nfields)); ! static int inzsub P((char ** fields, int nfields, int iscont)); ! static int is32 P((zic_t x)); ! static int itsabbr P((const char * abbr, const char * word)); ! static int itsdir P((const char * name)); ! static int lowerit P((int c)); ! static char * memcheck P((char * tocheck)); ! static int mkdirs P((char * filename)); ! static void newabbr P((const char * abbr)); ! static long oadd P((long t1, long t2)); ! static void outzone P((const struct zone * zp, int ntzones)); ! static void puttzcode P((long code, FILE * fp)); ! static void puttzcode64 P((zic_t code, FILE * fp)); ! static int rcomp P((const void * leftp, const void * rightp)); ! static zic_t rpytime P((const struct rule * rp, int wantedy)); ! static void rulesub P((struct rule * rp, const char * loyearp, const char * hiyearp, const char * typep, const char * monthp, ! const char * dayp, const char * timep)); ! static int stringoffset P((char * result, long offset)); ! static int stringrule P((char * result, const struct rule * rp, ! long dstoff, long gmtoff)); ! static void stringzone P((char * result, ! const struct zone * zp, int ntzones)); ! static void setboundaries P((void)); ! static zic_t tadd P((zic_t t1, long t2)); ! static void usage P((void)); ! static void writezone P((const char * name, const char * string)); ! static int yearistype P((int year, const char * type)); #if !HAVE_STRERROR ! static char * strerror P((int)); #endif /* !HAVE_STRERROR */ static int charcnt; --- 99,167 ---- zic_t z_untiltime; }; ! extern int getopt(int argc, char * const argv[], ! const char * options); ! extern int link(const char * fromname, const char * toname); extern char * optarg; extern int optind; ! static void addtt(zic_t starttime, int type); ! static int addtype(long gmtoff, const char * abbr, int isdst, ! int ttisstd, int ttisgmt); ! static void leapadd(zic_t t, int positive, int rolling, int count); ! static void adjleap(void); ! static void associate(void); ! static int ciequal(const char * ap, const char * bp); ! static void convert(long val, char * buf); ! static void convert64(zic_t val, char * buf); ! static void dolink(const char * fromfield, const char * tofield); ! static void doabbr(char * abbr, const char * format, ! const char * letters, int isdst, int doquotes); ! static void eat(const char * name, int num); ! static void eats(const char * name, int num, ! const char * rname, int rnum); ! static long eitol(int i); ! static void error(const char * message); ! static char ** getfields(char * buf); ! static long gethms(const char * string, const char * errstrng, ! int signable); ! static void infile(const char * filename); ! static void inleap(char ** fields, int nfields); ! static void inlink(char ** fields, int nfields); ! static void inrule(char ** fields, int nfields); ! static int inzcont(char ** fields, int nfields); ! static int inzone(char ** fields, int nfields); ! static int inzsub(char ** fields, int nfields, int iscont); ! static int is32(zic_t x); ! static int itsabbr(const char * abbr, const char * word); ! static int itsdir(const char * name); ! static int lowerit(int c); ! static char * memcheck(char * tocheck); ! static int mkdirs(char * filename); ! static void newabbr(const char * abbr); ! static long oadd(long t1, long t2); ! static void outzone(const struct zone * zp, int ntzones); ! static void puttzcode(long code, FILE * fp); ! static void puttzcode64(zic_t code, FILE * fp); ! static int rcomp(const void * leftp, const void * rightp); ! static zic_t rpytime(const struct rule * rp, int wantedy); ! static void rulesub(struct rule * rp, const char * loyearp, const char * hiyearp, const char * typep, const char * monthp, ! const char * dayp, const char * timep); ! static int stringoffset(char * result, long offset); ! static int stringrule(char * result, const struct rule * rp, ! long dstoff, long gmtoff); ! static void stringzone(char * result, ! const struct zone * zp, int ntzones); ! static void setboundaries(void); ! static zic_t tadd(zic_t t1, long t2); ! static void usage(void); ! 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; *************** *** 287,294 **** const int l_value; }; ! static struct lookup const * byword P((const char * string, ! const struct lookup * lp)); static struct lookup const line_codes[] = { { "Rule", LC_RULE }, --- 287,294 ---- const int l_value; }; ! static struct lookup const * byword(const char * string, ! const struct lookup * lp); static struct lookup const line_codes[] = { { "Rule", LC_RULE }, *************** *** 471,477 **** } static void ! usage P((void)) { (void) fprintf(stderr, _("%s: usage is %s \ [ --version ] [ -v ] [ -l localtime ] [ -p posixrules ] \\\n\ --- 471,477 ---- } static void ! usage(void) { (void) fprintf(stderr, _("%s: usage is %s \ [ --version ] [ -v ] [ -l localtime ] [ -p posixrules ] \\\n\ *************** *** 699,705 **** #define TIME_T_BITS_IN_FILE 64 static void ! setboundaries P((void)) { register int i; --- 699,705 ---- #define TIME_T_BITS_IN_FILE 64 static void ! setboundaries(void) { register int i; *************** *** 741,747 **** } static void ! associate P((void)) { register struct zone * zp; register struct rule * rp; --- 741,747 ---- } static void ! associate(void) { register struct zone * zp; register struct rule * rp; *************** *** 2331,2337 **** } static void ! adjleap P((void)) { register int i; register long last = 0; --- 2331,2337 ---- } static void ! adjleap(void) { register int i; register long last = 0;