diff --git a/localtime.c b/localtime.c index 9dd496d..05390fd 100644 --- a/localtime.c +++ b/localtime.c @@ -18,6 +18,8 @@ #include "tzfile.h" #include +#include + #if defined THREAD_SAFE && THREAD_SAFE # include static pthread_mutex_t locallock = PTHREAD_MUTEX_INITIALIZER; @@ -1476,6 +1478,15 @@ tzfree(timezone_t sp) ** but it is actually a boolean and its value should be 0 or 1. */ +static void +printtm(char const *name, struct tm const *tmp) +{ + printf(" %s={%d-%.3d %d-%.2d-%.2d %.2d:%.2d:%.2d dst=%d}", + name, tmp->tm_year + 1900, tmp->tm_yday + 1, + tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, + tmp->tm_hour, tmp->tm_min, tmp->tm_sec, tmp->tm_isdst); +} + /*ARGSUSED*/ static struct tm * localsub(struct state const *sp, time_t const *timep, int_fast32_t setname, @@ -1490,6 +1501,10 @@ localsub(struct state const *sp, time_t const *timep, int_fast32_t setname, /* Don't bother to set tzname etc.; tzset has already done it. */ return gmtsub(gmtptr, timep, 0, tmp); } + printf("\nt=%jd sp->ats[0]=%jd sp->timecnt=%d\n", + (intmax_t)t, (intmax_t)sp->ats[0], sp->timecnt); + printf("sp->ats[sp->timecnt-1]=%jd sp->goback=%d sp->goahead=%d\n", + (intmax_t) sp->ats[sp->timecnt - 1], sp->goback, sp->goahead); if ((sp->goback && t < sp->ats[0]) || (sp->goahead && t > sp->ats[sp->timecnt - 1])) { time_t newt; @@ -1530,6 +1545,7 @@ localsub(struct state const *sp, time_t const *timep, int_fast32_t setname, } if (sp->timecnt == 0 || t < sp->ats[0]) { i = sp->defaulttype; + printf("i=sp->defaulttype=%d\n", i); } else { register int lo = 1; register int hi = sp->timecnt; @@ -1537,13 +1553,17 @@ localsub(struct state const *sp, time_t const *timep, int_fast32_t setname, while (lo < hi) { register int mid = (lo + hi) >> 1; + printf("\tlo=%d mid=%d hi=%d sp->ats[mid]=%jd\n", + lo, mid, hi, (intmax_t)sp->ats[mid]); if (t < sp->ats[mid]) hi = mid; else lo = mid + 1; } i = (int) sp->types[lo - 1]; + printf("lo=%d i=sp->types[lo - 1]=%d\n", lo, i); } ttisp = &sp->ttis[i]; + printf("ttisp->tt_utoff=%ld\n", (long)ttisp->tt_utoff); /* ** To get (wrong) behavior that's compatible with System V Release 2.0 ** you'd replace the statement below with @@ -1559,6 +1579,8 @@ localsub(struct state const *sp, time_t const *timep, int_fast32_t setname, if (setname) update_tzname_etc(sp, ttisp); } + printtm("localsub", result); + printf("\n"); return result; } diff --git a/zdump.c b/zdump.c index 16e73ae..e6559a9 100644 --- a/zdump.c +++ b/zdump.c @@ -521,7 +521,7 @@ main(int argc, char *argv[]) gmtzinit(); INITIALIZE(now); if (! (iflag | vflag | Vflag)) - now = time(NULL); + now = -1830383495; longest = 0; for (i = optind; i < argc; i++) { size_t arglen = strlen(argv[i]);