/* * Load a timezone definition. * Does not verify that the timezone is acceptable! * * This corresponds to the backend's pg_tzset(), except that we only support * one loaded timezone at a time. */ static pg_tz * pg_load_tz(const char *name) { static pg_tz tz; if (strlen(name) > TZ_STRLEN_MAX) return NULL; /* not going to fit */ /* * "GMT" is always sent to tzparse(); see comments for pg_tzset(). */ if (strcmp(name, "GMT") == 0) { if (!tzparse(name, &tz.state, true)) { /* This really, really should not happen ... */ return NULL; } } else if (tzload(name, NULL, &tz.state, true) != 0) { if (name[0] == ':' || !tzparse(name, &tz.state, false)) { return NULL; /* unknown timezone */ } } strcpy(tz.TZname, name); return &tz; }
/* * Load a timezone from file or from cache. * Does not verify that the timezone is acceptable! */ struct pg_tz * pg_tzset(const char *name) { pg_tz_cache *tzp; struct state tzstate; char uppername[TZ_STRLEN_MAX + 1]; char canonname[TZ_STRLEN_MAX + 1]; char *p; if (strlen(name) > TZ_STRLEN_MAX) return NULL; /* not going to fit */ if (!timezone_cache) if (!init_timezone_hashtable()) return NULL; /* * Upcase the given name to perform a case-insensitive hashtable search. * (We could alternatively downcase it, but we prefer upcase so that we * can get consistently upcased results from tzparse() in case the name is * a POSIX-style timezone spec.) */ p = uppername; while (*name) *p++ = pg_toupper((unsigned char) *name++); *p = '\0'; tzp = (pg_tz_cache *) hash_search(timezone_cache, uppername, HASH_FIND, NULL); if (tzp) { /* Timezone found in cache, nothing more to do */ return &tzp->tz; } if (tzload(uppername, canonname, &tzstate, TRUE) != 0) { if (uppername[0] == ':' || tzparse(uppername, &tzstate, FALSE) != 0) { /* Unknown timezone. Fail our call instead of loading GMT! */ return NULL; } /* For POSIX timezone specs, use uppercase name as canonical */ strcpy(canonname, uppername); } /* Save timezone in the cache */ tzp = (pg_tz_cache *) hash_search(timezone_cache, uppername, HASH_ENTER, NULL); /* hash_search already copied uppername into the hash key */ strcpy(tzp->tz.TZname, canonname); memcpy(&tzp->tz.state, &tzstate, sizeof(tzstate)); return &tzp->tz; }
static void tztime(const time_t *const timep, const char *tzstring, struct tm *const tmp) { struct state *tzptr, *sp; const time_t t = *timep; register int i; register const struct ttinfo *ttisp; if (tzstring == NULL) tzstring = gmt; tzptr = (struct state *) malloc(sizeof(struct state)); sp = tzptr; if (tzptr != NULL) { memset(tzptr, 0, sizeof(struct state)); (void) tzparse(tzstring, tzptr, FALSE); if (sp->timecnt == 0 || t < sp->ats[0]) { i = 0; while (sp->ttis[i].tt_isdst) if (++i >= sp->typecnt) { i = 0; break; } } else { for (i = 1; i < sp->timecnt; ++i) if (t < sp->ats[i]) break; i = sp->types[i - 1]; // DST begin or DST end } ttisp = &sp->ttis[i]; /* To get (wrong) behavior that's compatible with System V Release 2.0 you'd replace the statement below with t += ttisp->tt_gmtoff; timesub(&t, 0L, sp, tmp); */ if (tmp != NULL) { /* Just a check not to assert */ timesub(&t, ttisp->tt_gmtoff, sp, tmp); tmp->tm_isdst = ttisp->tt_isdst; #if defined(HAVE_STRUCT_TM_TM_ZONE) tmp->tm_zone = &sp->chars[ttisp->tt_abbrind]; #endif } free(tzptr); } }
/* * Pre-initialize timezone library * * This is called before GUC variable initialization begins. Its purpose * is to ensure that elog.c has a pgtz variable available to format timestamps * with, in case log_line_prefix is set to a value requiring that. We cannot * set log_timezone yet. */ void pg_timezone_pre_initialize(void) { /* * We can't use tzload() because we may not know where PGSHAREDIR is (in * particular this is true in an EXEC_BACKEND subprocess). Since this * timezone variable will only be used for emergency fallback purposes, it * seems OK to just use the "lastditch" case provided by tzparse(). */ if (tzparse("GMT", &gmt_timezone_data.state, TRUE) != 0) elog(FATAL, "could not initialize GMT time zone"); strcpy(gmt_timezone_data.TZname, "GMT"); gmt_timezone = &gmt_timezone_data; }
/* * Load a timezone from file or from cache. * Does not verify that the timezone is acceptable! */ struct pg_tz * pg_tzset(const char *name) { pg_tz *tzp; pg_tz tz; if (strlen(name) > TZ_STRLEN_MAX) return NULL; /* not going to fit */ if (!timezone_cache) if (!init_timezone_hashtable()) return NULL; tzp = (pg_tz *) hash_search(timezone_cache, name, HASH_FIND, NULL); if (tzp) { /* Timezone found in cache, nothing more to do */ return tzp; } if (tzload(name, &tz.state) != 0) { if (name[0] == ':' || tzparse(name, &tz.state, FALSE) != 0) { /* Unknown timezone. Fail our call instead of loading GMT! */ return NULL; } } strcpy(tz.TZname, name); /* Save timezone in the cache */ tzp = hash_search(timezone_cache, name, HASH_ENTER, NULL); strcpy(tzp->TZname, tz.TZname); memcpy(&tzp->state, &tz.state, sizeof(tz.state)); return tzp; }
static void tzset_basic(int rdlocked) { const char * name; name = getenv("TZ"); if (name == NULL) { tzsetwall_basic(rdlocked); return; } if (!rdlocked) _RWLOCK_RDLOCK(&lcl_rwlock); if (lcl_is_set > 0 && strcmp(lcl_TZname, name) == 0) { if (!rdlocked) _RWLOCK_UNLOCK(&lcl_rwlock); return; } _RWLOCK_UNLOCK(&lcl_rwlock); _RWLOCK_WRLOCK(&lcl_rwlock); lcl_is_set = strlen(name) < sizeof lcl_TZname; if (lcl_is_set) strcpy(lcl_TZname, name); if (*name == '\0') { /* ** User wants it fast rather than right. */ lclptr->leapcnt = 0; /* so, we're off a little */ lclptr->timecnt = 0; lclptr->typecnt = 0; lclptr->ttis[0].tt_isdst = 0; lclptr->ttis[0].tt_gmtoff = 0; lclptr->ttis[0].tt_abbrind = 0; strcpy(lclptr->chars, gmt); } else if (tzload(name, lclptr, TRUE) != 0) if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0) gmtload(lclptr); settzname(); _RWLOCK_UNLOCK(&lcl_rwlock); if (rdlocked) _RWLOCK_RDLOCK(&lcl_rwlock); }
static void gmtload(struct state * sp) { if (tzload(gmt, NULL, sp, TRUE) != 0) (void) tzparse(gmt, sp, TRUE); }
int tzload(const char *name, char *canonname, struct state * sp, int doextend) { const char *p; int i; int fid; int stored; int nread; union { struct tzhead tzhead; char buf[2 * sizeof(struct tzhead) + 2 * sizeof *sp + 4 * TZ_MAX_TIMES]; } u; sp->goback = sp->goahead = FALSE; if (name == NULL && (name = TZDEFAULT) == NULL) return -1; if (name[0] == ':') ++name; fid = pg_open_tzfile(name, canonname); if (fid < 0) return -1; nread = read(fid, u.buf, sizeof u.buf); if (close(fid) != 0 || nread <= 0) return -1; for (stored = 4; stored <= 8; stored *= 2) { int ttisstdcnt; int ttisgmtcnt; ttisstdcnt = (int) detzcode(u.tzhead.tzh_ttisstdcnt); ttisgmtcnt = (int) detzcode(u.tzhead.tzh_ttisgmtcnt); sp->leapcnt = (int) detzcode(u.tzhead.tzh_leapcnt); sp->timecnt = (int) detzcode(u.tzhead.tzh_timecnt); sp->typecnt = (int) detzcode(u.tzhead.tzh_typecnt); sp->charcnt = (int) detzcode(u.tzhead.tzh_charcnt); p = u.tzhead.tzh_charcnt + sizeof u.tzhead.tzh_charcnt; if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) || (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0)) return -1; if (nread - (p - u.buf) < sp->timecnt * stored + /* ats */ sp->timecnt + /* types */ sp->typecnt * 6 + /* ttinfos */ sp->charcnt + /* chars */ sp->leapcnt * (stored + 4) + /* lsinfos */ ttisstdcnt + /* ttisstds */ ttisgmtcnt) /* ttisgmts */ return -1; for (i = 0; i < sp->timecnt; ++i) { sp->ats[i] = (stored == 4) ? detzcode(p) : detzcode64(p); p += stored; } for (i = 0; i < sp->timecnt; ++i) { sp->types[i] = (unsigned char) *p++; if (sp->types[i] >= sp->typecnt) return -1; } for (i = 0; i < sp->typecnt; ++i) { struct ttinfo *ttisp; ttisp = &sp->ttis[i]; ttisp->tt_gmtoff = detzcode(p); p += 4; ttisp->tt_isdst = (unsigned char) *p++; if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1) return -1; ttisp->tt_abbrind = (unsigned char) *p++; if (ttisp->tt_abbrind < 0 || ttisp->tt_abbrind > sp->charcnt) return -1; } for (i = 0; i < sp->charcnt; ++i) sp->chars[i] = *p++; sp->chars[i] = '\0'; /* ensure '\0' at end */ for (i = 0; i < sp->leapcnt; ++i) { struct lsinfo *lsisp; lsisp = &sp->lsis[i]; lsisp->ls_trans = (stored == 4) ? detzcode(p) : detzcode64(p); p += stored; lsisp->ls_corr = detzcode(p); p += 4; } for (i = 0; i < sp->typecnt; ++i) { struct ttinfo *ttisp; ttisp = &sp->ttis[i]; if (ttisstdcnt == 0) ttisp->tt_ttisstd = FALSE; else { ttisp->tt_ttisstd = *p++; if (ttisp->tt_ttisstd != TRUE && ttisp->tt_ttisstd != FALSE) return -1; } } for (i = 0; i < sp->typecnt; ++i) { struct ttinfo *ttisp; ttisp = &sp->ttis[i]; if (ttisgmtcnt == 0) ttisp->tt_ttisgmt = FALSE; else { ttisp->tt_ttisgmt = *p++; if (ttisp->tt_ttisgmt != TRUE && ttisp->tt_ttisgmt != FALSE) return -1; } } /* * Out-of-sort ats should mean we're running on a signed time_t system * but using a data file with unsigned values (or vice versa). */ for (i = 0; i < sp->timecnt - 2; ++i) if (sp->ats[i] > sp->ats[i + 1]) { ++i; if (TYPE_SIGNED(pg_time_t)) { /* * Ignore the end (easy). */ sp->timecnt = i; } else { /* * Ignore the beginning (harder). */ int j; for (j = 0; j + i < sp->timecnt; ++j) { sp->ats[j] = sp->ats[j + i]; sp->types[j] = sp->types[j + i]; } sp->timecnt = j; } break; } /* * If this is an old file, we're done. */ if (u.tzhead.tzh_version[0] == '\0') break; nread -= p - u.buf; for (i = 0; i < nread; ++i) u.buf[i] = p[i]; /* * If this is a narrow integer time_t system, we're done. */ if (stored >= (int) sizeof(pg_time_t) && TYPE_INTEGRAL(pg_time_t)) break; } if (doextend && nread > 2 && u.buf[0] == '\n' && u.buf[nread - 1] == '\n' && sp->typecnt + 2 <= TZ_MAX_TYPES) { struct state ts; int result; u.buf[nread - 1] = '\0'; result = tzparse(&u.buf[1], &ts, FALSE); if (result == 0 && ts.typecnt == 2 && sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) { for (i = 0; i < 2; ++i) ts.ttis[i].tt_abbrind += sp->charcnt; for (i = 0; i < ts.charcnt; ++i) sp->chars[sp->charcnt++] = ts.chars[i]; i = 0; while (i < ts.timecnt && ts.ats[i] <= sp->ats[sp->timecnt - 1]) ++i; while (i < ts.timecnt && sp->timecnt < TZ_MAX_TIMES) { sp->ats[sp->timecnt] = ts.ats[i]; sp->types[sp->timecnt] = sp->typecnt + ts.types[i]; ++sp->timecnt; ++i; } sp->ttis[sp->typecnt++] = ts.ttis[0]; sp->ttis[sp->typecnt++] = ts.ttis[1]; } } if (sp->timecnt > 1) { for (i = 1; i < sp->timecnt; ++i) if (typesequiv(sp, sp->types[i], sp->types[0]) && differ_by_repeat(sp->ats[i], sp->ats[0])) { sp->goback = TRUE; break; } for (i = sp->timecnt - 2; i >= 0; --i) if (typesequiv(sp, sp->types[sp->timecnt - 1], sp->types[i]) && differ_by_repeat(sp->ats[sp->timecnt - 1], sp->ats[i])) { sp->goahead = TRUE; break; } } return 0; }
/* * See how well a specific timezone setting matches the system behavior * * We score a timezone setting according to the number of test times it * matches. (The test times are ordered later-to-earlier, but this routine * doesn't actually know that; it just scans until the first non-match.) * * We return -1 for a completely unusable setting; this is worse than the * score of zero for a setting that works but matches not even the first * test time. */ static int score_timezone(const char *tzname, struct tztry * tt) { int i; pg_time_t pgtt; struct tm* systm; struct pg_tm* pgtm; char cbuf[TZ_STRLEN_MAX + 1]; pg_tz tz; /* * Load timezone directly. Don't use pg_tzset, because we don't want all * timezones loaded in the cache at startup. */ if (tzload(tzname, NULL, &tz.state, TRUE) != 0) { if (tzname[0] == ':' || tzparse(tzname, &tz.state, FALSE) != 0) { return -1; /* can't handle the TZ name at all */ } } /* Reject if leap seconds involved */ if (!tz_acceptable(&tz)) { elog(DEBUG4, "Reject TZ \"%s\": uses leap seconds", tzname); return -1; } /* Check for match at all the test times */ for (i = 0; i < tt->n_test_times; i++) { pgtt = (pg_time_t) (tt->test_times[i]); pgtm = pg_localtime(&pgtt, &tz); if (!pgtm) return -1; /* probably shouldn't happen */ systm = localtime(&(tt->test_times[i])); if (!systm) { elog(DEBUG4, "TZ \"%s\" scores %d:" " at %ld %04d-%02d-%02d %02d:%02d:%02d %s, system had no data", tzname, i, (long) pgtt, pgtm->tm_year + 1900, pgtm->tm_mon + 1, pgtm->tm_mday, pgtm->tm_hour, pgtm->tm_min, pgtm->tm_sec, pgtm->tm_isdst ? "dst" : "std"); return i; } if (!compare_tm(systm, pgtm)) { elog(DEBUG4, "TZ \"%s\" scores %d:" " at %ld %04d-%02d-%02d %02d:%02d:%02d %s" " versus %04d-%02d-%02d %02d:%02d:%02d %s", tzname, i, (long) pgtt, pgtm->tm_year + 1900, pgtm->tm_mon + 1, pgtm->tm_mday, pgtm->tm_hour, pgtm->tm_min, pgtm->tm_sec, pgtm->tm_isdst ? "dst" : "std", systm->tm_year + 1900, systm->tm_mon + 1, systm->tm_mday, systm->tm_hour, systm->tm_min, systm->tm_sec, systm->tm_isdst ? "dst" : "std"); return i; } if (systm->tm_isdst >= 0) { /* Check match of zone names, too */ if (pgtm->tm_zone == NULL) return -1; /* probably shouldn't happen */ memset(cbuf, 0, sizeof(cbuf)); strftime(cbuf, sizeof(cbuf) - 1, "%Z", systm); /* zone abbr */ if (strcmp(cbuf, pgtm->tm_zone) != 0) { elog(DEBUG4, "TZ \"%s\" scores %d: at %ld \"%s\" versus \"%s\"", tzname, i, (long) pgtt, pgtm->tm_zone, cbuf); return i; } } } elog(DEBUG4, "TZ \"%s\" gets max score %d", tzname, i); return i; }
static int tzload(const char *name, struct state * const sp, const int doextend) { const char * p; int i; int fid; int stored; int nread; typedef union { struct tzhead tzhead; char buf[2 * sizeof(struct tzhead) + 2 * sizeof *sp + 4 * TZ_MAX_TIMES]; } u_t; u_t u; u_t * const up = &u; sp->goback = sp->goahead = FALSE; /* XXX The following is from OpenBSD, and I'm not sure it is correct */ if (name != NULL && issetugid() != 0) if ((name[0] == ':' && name[1] == '/') || name[0] == '/' || strchr(name, '.')) name = NULL; if (name == NULL && (name = TZDEFAULT) == NULL) goto oops; { int doaccess; struct stat stab; /* ** Section 4.9.1 of the C standard says that ** "FILENAME_MAX expands to an integral constant expression ** that is the size needed for an array of char large enough ** to hold the longest file name string that the implementation ** guarantees can be opened." */ char fullname[FILENAME_MAX + 1]; if (name[0] == ':') ++name; doaccess = name[0] == '/'; if (!doaccess) { if ((p = TZDIR) == NULL) goto oops; if ((strlen(p) + 1 + strlen(name) + 1) >= sizeof fullname) goto oops; strcpy(fullname, p); strcat(fullname, "/"); strcat(fullname, name); /* ** Set doaccess if '.' (as in "../") shows up in name. */ if (strchr(name, '.') != NULL) doaccess = TRUE; name = fullname; } if (doaccess && access(name, R_OK) != 0) goto oops; if ((fid = _open(name, O_RDONLY)) == -1) goto oops; if ((_fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode)) { _close(fid); return -1; } } nread = _read(fid, up->buf, sizeof up->buf); if (_close(fid) < 0 || nread <= 0) goto oops; for (stored = 4; stored <= 8; stored *= 2) { int ttisstdcnt; int ttisgmtcnt; ttisstdcnt = (int) detzcode(up->tzhead.tzh_ttisstdcnt); ttisgmtcnt = (int) detzcode(up->tzhead.tzh_ttisgmtcnt); sp->leapcnt = (int) detzcode(up->tzhead.tzh_leapcnt); sp->timecnt = (int) detzcode(up->tzhead.tzh_timecnt); sp->typecnt = (int) detzcode(up->tzhead.tzh_typecnt); sp->charcnt = (int) detzcode(up->tzhead.tzh_charcnt); p = up->tzhead.tzh_charcnt + sizeof up->tzhead.tzh_charcnt; if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) || (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0)) goto oops; if (nread - (p - up->buf) < sp->timecnt * stored + /* ats */ sp->timecnt + /* types */ sp->typecnt * 6 + /* ttinfos */ sp->charcnt + /* chars */ sp->leapcnt * (stored + 4) + /* lsinfos */ ttisstdcnt + /* ttisstds */ ttisgmtcnt) /* ttisgmts */ goto oops; for (i = 0; i < sp->timecnt; ++i) { sp->ats[i] = (stored == 4) ? detzcode(p) : detzcode64(p); p += stored; } for (i = 0; i < sp->timecnt; ++i) { sp->types[i] = (unsigned char) *p++; if (sp->types[i] >= sp->typecnt) goto oops; } for (i = 0; i < sp->typecnt; ++i) { struct ttinfo * ttisp; ttisp = &sp->ttis[i]; ttisp->tt_gmtoff = detzcode(p); p += 4; ttisp->tt_isdst = (unsigned char) *p++; if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1) goto oops; ttisp->tt_abbrind = (unsigned char) *p++; if (ttisp->tt_abbrind < 0 || ttisp->tt_abbrind > sp->charcnt) goto oops; } for (i = 0; i < sp->charcnt; ++i) sp->chars[i] = *p++; sp->chars[i] = '\0'; /* ensure '\0' at end */ for (i = 0; i < sp->leapcnt; ++i) { struct lsinfo * lsisp; lsisp = &sp->lsis[i]; lsisp->ls_trans = (stored == 4) ? detzcode(p) : detzcode64(p); p += stored; lsisp->ls_corr = detzcode(p); p += 4; } for (i = 0; i < sp->typecnt; ++i) { struct ttinfo * ttisp; ttisp = &sp->ttis[i]; if (ttisstdcnt == 0) ttisp->tt_ttisstd = FALSE; else { ttisp->tt_ttisstd = *p++; if (ttisp->tt_ttisstd != TRUE && ttisp->tt_ttisstd != FALSE) goto oops; } } for (i = 0; i < sp->typecnt; ++i) { struct ttinfo * ttisp; ttisp = &sp->ttis[i]; if (ttisgmtcnt == 0) ttisp->tt_ttisgmt = FALSE; else { ttisp->tt_ttisgmt = *p++; if (ttisp->tt_ttisgmt != TRUE && ttisp->tt_ttisgmt != FALSE) goto oops; } } /* ** Out-of-sort ats should mean we're running on a ** signed time_t system but using a data file with ** unsigned values (or vice versa). */ for (i = 0; i < sp->timecnt - 2; ++i) if (sp->ats[i] > sp->ats[i + 1]) { ++i; if (TYPE_SIGNED(time_t)) { /* ** Ignore the end (easy). */ sp->timecnt = i; } else { /* ** Ignore the beginning (harder). */ int j; for (j = 0; j + i < sp->timecnt; ++j) { sp->ats[j] = sp->ats[j + i]; sp->types[j] = sp->types[j + i]; } sp->timecnt = j; } break; } /* ** If this is an old file, we're done. */ if (up->tzhead.tzh_version[0] == '\0') break; nread -= p - up->buf; for (i = 0; i < nread; ++i) up->buf[i] = p[i]; /* ** If this is a narrow integer time_t system, we're done. */ if (stored >= (int) sizeof(time_t) && TYPE_INTEGRAL(time_t)) break; } if (doextend && nread > 2 && up->buf[0] == '\n' && up->buf[nread - 1] == '\n' && sp->typecnt + 2 <= TZ_MAX_TYPES) { struct state ts; int result; up->buf[nread - 1] = '\0'; result = tzparse(&up->buf[1], &ts, FALSE); if (result == 0 && ts.typecnt == 2 && sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) { for (i = 0; i < 2; ++i) ts.ttis[i].tt_abbrind += sp->charcnt; for (i = 0; i < ts.charcnt; ++i) sp->chars[sp->charcnt++] = ts.chars[i]; i = 0; while (i < ts.timecnt && ts.ats[i] <= sp->ats[sp->timecnt - 1]) ++i; while (i < ts.timecnt && sp->timecnt < TZ_MAX_TIMES) { sp->ats[sp->timecnt] = ts.ats[i]; sp->types[sp->timecnt] = sp->typecnt + ts.types[i]; ++sp->timecnt; ++i; } sp->ttis[sp->typecnt++] = ts.ttis[0]; sp->ttis[sp->typecnt++] = ts.ttis[1]; } } if (sp->timecnt > 1) { for (i = 1; i < sp->timecnt; ++i) if (typesequiv(sp, sp->types[i], sp->types[0]) && differ_by_repeat(sp->ats[i], sp->ats[0])) { sp->goback = TRUE; break; } for (i = sp->timecnt - 2; i >= 0; --i) if (typesequiv(sp, sp->types[sp->timecnt - 1], sp->types[i]) && differ_by_repeat(sp->ats[sp->timecnt - 1], sp->ats[i])) { sp->goahead = TRUE; break; } } return 0; oops: return -1; }
static void gmtload(struct state * const sp) { if (tzload(gmt, sp, TRUE) != 0) tzparse(gmt, sp, TRUE); }