Lines Matching defs:sp

182 static void		gmtload P((struct state * sp));
186 struct tm * tmp, const struct state *sp));
197 long, struct tm *, const struct state* sp)),
198 long offset, const struct state * sp));
201 long, struct tm*, const struct state* sp)),
202 long offset, int * okayp, const struct state * sp));
204 struct tm * (*funcp) P((const time_t*, long, struct tm*,const struct state *sp)),
206 const struct state *sp));
208 const struct state * sp, struct tm * tmp));
213 static int tzload P((const char * name, struct state * sp,
215 static int tzload_uncached P((const char * name, struct state * sp,
217 static int tzparse P((const char * name, struct state * sp,
311 tzload(const char *name, struct state * const sp, const int doextend)
321 *sp = g_utc;
326 *sp = g_cacheStates[i];
343 *sp = g_cacheStates[i];
350 return tzload_uncached(name, sp, doextend);
354 tzload_uncached(name, sp, doextend)
356 register struct state * const sp;
367 2 * sizeof *sp +
452 sp->leapcnt = (int) detzcode(u.tzhead.tzh_leapcnt);
453 sp->timecnt = (int) detzcode(u.tzhead.tzh_timecnt);
454 sp->typecnt = (int) detzcode(u.tzhead.tzh_typecnt);
455 sp->charcnt = (int) detzcode(u.tzhead.tzh_charcnt);
457 if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS ||
458 sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES ||
459 sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES ||
460 sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS ||
461 (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) ||
462 (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0))
465 sp->timecnt * stored + /* ats */
466 sp->timecnt + /* types */
467 sp->typecnt * 6 + /* ttinfos */
468 sp->charcnt + /* chars */
469 sp->leapcnt * (stored + 4) + /* lsinfos */
473 for (i = 0; i < sp->timecnt; ++i) {
474 sp->ats[i] = (stored == 4) ?
478 for (i = 0; i < sp->timecnt; ++i) {
479 sp->types[i] = (unsigned char) *p++;
480 if (sp->types[i] >= sp->typecnt)
483 for (i = 0; i < sp->typecnt; ++i) {
486 ttisp = &sp->ttis[i];
494 ttisp->tt_abbrind > sp->charcnt)
497 for (i = 0; i < sp->charcnt; ++i)
498 sp->chars[i] = *p++;
499 sp->chars[i] = '\0'; /* ensure '\0' at end */
500 for (i = 0; i < sp->leapcnt; ++i) {
503 lsisp = &sp->lsis[i];
510 for (i = 0; i < sp->typecnt; ++i) {
513 ttisp = &sp->ttis[i];
523 for (i = 0; i < sp->typecnt; ++i) {
526 ttisp = &sp->ttis[i];
541 for (i = 0; i < sp->timecnt - 2; ++i)
542 if (sp->ats[i] > sp->ats[i + 1]) {
548 sp->timecnt = i;
555 for (j = 0; j + i < sp->timecnt; ++j) {
556 sp->ats[j] = sp->ats[j + i];
557 sp->types[j] = sp->types[j + i];
559 sp->timecnt = j;
579 sp->typecnt + 2 <= TZ_MAX_TYPES) {
586 sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) {
589 sp->charcnt;
591 sp->chars[sp->charcnt++] =
596 sp->ats[sp->timecnt - 1])
599 sp->timecnt < TZ_MAX_TIMES) {
600 sp->ats[sp->timecnt] =
602 sp->types[sp->timecnt] =
603 sp->typecnt +
605 ++sp->timecnt;
608 sp->ttis[sp->typecnt++] = ts.ttis[0];
609 sp->ttis[sp->typecnt++] = ts.ttis[1];
613 sp->goback = sp->goahead = sp->timecnt > i;
614 sp->goback &= sp->types[i] == sp->types[0] &&
615 differ_by_repeat(sp->ats[i], sp->ats[0]);
616 sp->goahead &=
617 sp->types[sp->timecnt - 1] == sp->types[sp->timecnt - 1 - i] &&
618 differ_by_repeat(sp->ats[sp->timecnt - 1],
619 sp->ats[sp->timecnt - 1 - i]);
928 tzparse(name, sp, lastditch)
930 register struct state * const sp;
949 if (stdlen >= sizeof sp->chars)
950 stdlen = (sizeof sp->chars) - 1;
971 load_result = tzload(TZDEFRULES, sp, FALSE);
973 sp->leapcnt = 0; /* so, we're off a little */
974 sp->timecnt = 0;
1012 sp->typecnt = 2; /* standard time and DST */
1016 sp->ttis[0].tt_gmtoff = -dstoffset;
1017 sp->ttis[0].tt_isdst = 1;
1018 sp->ttis[0].tt_abbrind = stdlen + 1;
1019 sp->ttis[1].tt_gmtoff = -stdoffset;
1020 sp->ttis[1].tt_isdst = 0;
1021 sp->ttis[1].tt_abbrind = 0;
1022 atp = sp->ats;
1023 typep = sp->types;
1026 sp->timecnt + 2 <= TZ_MAX_TIMES;
1045 sp->timecnt += 2;
1067 for (i = 0; i < sp->timecnt; ++i) {
1068 j = sp->types[i];
1069 if (!sp->ttis[j].tt_isdst) {
1071 -sp->ttis[j].tt_gmtoff;
1076 for (i = 0; i < sp->timecnt; ++i) {
1077 j = sp->types[i];
1078 if (sp->ttis[j].tt_isdst) {
1080 -sp->ttis[j].tt_gmtoff;
1093 for (i = 0; i < sp->timecnt; ++i) {
1094 j = sp->types[i];
1095 sp->types[i] = sp->ttis[j].tt_isdst;
1096 if (sp->ttis[j].tt_ttisgmt) {
1113 if (isdst && !sp->ttis[j].tt_ttisstd) {
1114 sp->ats[i] += dstoffset -
1117 sp->ats[i] += stdoffset -
1121 theiroffset = -sp->ttis[j].tt_gmtoff;
1122 if (sp->ttis[j].tt_isdst)
1130 sp->ttis[0].tt_gmtoff = -stdoffset;
1131 sp->ttis[0].tt_isdst = FALSE;
1132 sp->ttis[0].tt_abbrind = 0;
1133 sp->ttis[1].tt_gmtoff = -dstoffset;
1134 sp->ttis[1].tt_isdst = TRUE;
1135 sp->ttis[1].tt_abbrind = stdlen + 1;
1136 sp->typecnt = 2;
1140 sp->typecnt = 1; /* only standard time */
1141 sp->timecnt = 0;
1142 sp->ttis[0].tt_gmtoff = -stdoffset;
1143 sp->ttis[0].tt_isdst = 0;
1144 sp->ttis[0].tt_abbrind = 0;
1146 sp->charcnt = stdlen + 1;
1148 sp->charcnt += dstlen + 1;
1149 if ((size_t) sp->charcnt > sizeof sp->chars)
1151 cp = sp->chars;
1163 gmtload(sp)
1164 struct state * const sp;
1166 if (tzload(gmt, sp, TRUE) != 0)
1167 (void) tzparse(gmt, sp, TRUE);
1181 localsub(timep, offset, tmp, sp)
1185 const struct state * sp;
1193 if (sp == NULL)
1196 if ((sp->goback && t < sp->ats[0]) ||
1197 (sp->goahead && t > sp->ats[sp->timecnt - 1])) {
1203 if (t < sp->ats[0])
1204 seconds = sp->ats[0] - t;
1205 else seconds = t - sp->ats[sp->timecnt - 1];
1215 if (t < sp->ats[0])
1218 if (newt < sp->ats[0] ||
1219 newt > sp->ats[sp->timecnt - 1])
1221 result = localsub(&newt, offset, tmp, sp);
1226 if (t < sp->ats[0])
1235 if (sp->timecnt == 0 || t < sp->ats[0]) {
1237 while (sp->ttis[i].tt_isdst)
1238 if (++i >= sp->typecnt) {
1244 register int hi = sp->timecnt;
1249 if (t < sp->ats[mid])
1253 i = (int) sp->types[lo - 1];
1255 ttisp = &sp->ttis[i];
1260 ** timesub(&t, 0L, sp, tmp);
1262 result = timesub(&t, ttisp->tt_gmtoff, sp, tmp);
1267 tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind];
1269 tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind];
1400 timesub(timep, offset, sp, tmp)
1403 register const struct state * const sp;
1419 i = (sp == NULL) ? 0 : sp->leapcnt;
1422 i = sp->leapcnt;
1425 lp = &sp->lsis[i];
1429 lp->ls_corr > sp->lsis[i - 1].ls_corr);
1432 sp->lsis[i].ls_trans ==
1433 sp->lsis[i - 1].ls_trans + 1 &&
1434 sp->lsis[i].ls_corr ==
1435 sp->lsis[i - 1].ls_corr + 1) {
1660 time2sub(tmp, funcp, offset, okayp, do_norm_secs, sp)
1662 struct tm * (* const funcp) P((const time_t*, long, struct tm*,const struct state *sp));
1666 const struct state * sp;
1769 if ((*funcp)(&t, offset, &mytm, sp) == NULL) {
1808 if (sp == NULL)
1811 for (i = sp->typecnt - 1; i >= 0; --i) {
1812 if (sp->ttis[i].tt_isdst != yourtm.tm_isdst)
1814 for (j = sp->typecnt - 1; j >= 0; --j) {
1815 if (sp->ttis[j].tt_isdst == yourtm.tm_isdst)
1817 newt = t + sp->ttis[j].tt_gmtoff -
1818 sp->ttis[i].tt_gmtoff;
1819 if ((*funcp)(&newt, offset, &mytm, sp) == NULL)
1839 if ((*funcp)(&t, offset, tmp, sp))
1845 time2(tmp, funcp, offset, okayp, sp)
1848 const struct state* sp));
1851 const struct state * sp;
1860 t = time2sub(tmp, funcp, offset, okayp, FALSE, sp);
1861 return *okayp ? t : time2sub(tmp, funcp, offset, okayp, TRUE, sp);
1865 time1(tmp, funcp, offset, sp)
1867 struct tm * (* const funcp) P((const time_t *, long, struct tm *, const struct state* sp));
1869 const struct state * sp;
1882 t = time2(tmp, funcp, offset, &okay, sp);
1907 if (sp == NULL)
1910 for (i = 0; i < sp->typecnt; ++i)
1913 for (i = sp->timecnt - 1; i >= 0; --i)
1914 if (!seen[sp->types[i]]) {
1915 seen[sp->types[i]] = TRUE;
1916 types[nseen++] = sp->types[i];
1920 if (sp->ttis[samei].tt_isdst != tmp->tm_isdst)
1924 if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst)
1926 tmp->tm_sec += sp->ttis[otheri].tt_gmtoff -
1927 sp->ttis[samei].tt_gmtoff;
1929 t = time2(tmp, funcp, offset, &okay, sp);
1932 tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff -
1933 sp->ttis[samei].tt_gmtoff;