diff -ur tz2011j.mod1/zic.c tz2011j.mod2/zic.c --- tz2011j.mod1/zic.c 2011-10-11 21:34:44.000000000 +0100 +++ tz2011j.mod2/zic.c 2011-10-11 22:56:40.000000000 +0100 @@ -1968,8 +1968,11 @@ ** presume this is a zone handled on a year-by-year basis; ** do not try to apply a rule to the zone. */ - if (stdrp != NULL && stdrp->r_hiyear == 2037) + if (stdrp != NULL && stdrp->r_hiyear == 2037) { + result[0] = '!'; + result[1] = '\0'; return; + } } if (stdrp == NULL && (zp->z_nrules != 0 || zp->z_stdoff != 0)) return; @@ -2023,6 +2026,7 @@ register int max_abbr_len; register int max_envvar_len; register int prodstic; /* all rules are min to max */ + register int do_extend; max_abbr_len = 2 + max_format_len + max_abbrvar_len; max_envvar_len = 2 * max_abbr_len + 5 * 9; @@ -2067,6 +2071,9 @@ ** Generate lots of data if a rule can't cover all future times. */ stringzone(envvar, zpfirst, zonecount); + do_extend = envvar[0] == '\0'; + if(envvar[0] == '!' && envvar[1] == '\0') + envvar[0] = '\0'; if (noise && envvar[0] == '\0') { register char * wp; @@ -2076,7 +2083,7 @@ warning(wp); ifree(wp); } - if (envvar[0] == '\0') { + if (do_extend) { if (min_year >= INT_MIN + YEARSPERREPEAT) min_year -= YEARSPERREPEAT; else min_year = INT_MIN; @@ -2257,6 +2264,45 @@ starttime = tadd(starttime, -gmtoff); } } + if (do_extend) { + /* + ** If we're extending the explicitly listed observations + ** for 400 years because we can't fill the POSIX-TZ field, + ** check whether we actually ended up explicitly listing + ** observations through that period. If there aren't any + ** near the end of the 400-year period, add a redundant + ** one at the end of the final year, to make it clear + ** that we are claiming to have definite knowledge of + ** the lack of transitions up to that point. + */ + struct rule xr; + int i; + struct attype *lastat; + xr.r_month = TM_JANUARY; + xr.r_dycode = DC_DOM; + xr.r_dayofmonth = 1; + xr.r_tod = 0; + for (lastat = &attypes[0], i = 1; i <= timecnt; i++) + if (attypes[i].at > lastat->at) + lastat = &attypes[i]; + if (lastat->at < rpytime(&xr, max_year - 1)) { + /* + ** Create new type code for the redundant entry, + ** to prevent it being optimised away. + */ + if (typecnt >= TZ_MAX_TYPES) { + error(_("too many local time types")); + exit(EXIT_FAILURE); + } + gmtoffs[typecnt] = gmtoffs[lastat->type]; + isdsts[typecnt] = isdsts[lastat->type]; + ttisstds[typecnt] = ttisstds[lastat->type]; + ttisgmts[typecnt] = ttisgmts[lastat->type]; + abbrinds[typecnt] = abbrinds[lastat->type]; + ++typecnt; + addtt(rpytime(&xr, max_year + 1), typecnt-1); + } + } writezone(zpfirst->z_name, envvar); ifree(startbuf); ifree(ab);