Lines Matching refs:sp
144 static void gmtload(struct state * sp);
171 const struct state * sp, struct tm * tmp);
177 static int typesequiv(const struct state * sp, int a, int b);
178 static int tzload(const char * name, struct state * sp,
180 static int tzparse(const char * name, struct state * sp,
254 register struct state * const sp = lclptr; in settzname() local
265 if (sp == NULL) { in settzname()
272 for (i = 0; i < sp->typecnt; ++i) { in settzname()
273 register const struct ttinfo * const ttisp = &sp->ttis[i]; in settzname()
275 tzname[ttisp->tt_isdst] = &sp->chars[ttisp->tt_abbrind]; in settzname()
277 for (i = 0; i < sp->timecnt; ++i) { in settzname()
279 &sp->ttis[ in settzname()
280 sp->types[i]]; in settzname()
283 &sp->chars[ttisp->tt_abbrind]; in settzname()
299 for (i = 0; i < sp->charcnt; ++i) in settzname()
300 if (strchr(TZ_ABBR_CHAR_SET, sp->chars[i]) == NULL) in settzname()
301 sp->chars[i] = TZ_ABBR_ERR_CHAR; in settzname()
305 for (i = 0; i < sp->typecnt; ++i) { in settzname()
306 register const struct ttinfo * const ttisp = &sp->ttis[i]; in settzname()
307 register char * cp = &sp->chars[ttisp->tt_abbrind]; in settzname()
324 tzload(register const char *name, register struct state *const sp, in tzload() argument
335 2 * sizeof *sp + in tzload()
345 sp->goback = sp->goahead = FALSE; in tzload()
396 sp->leapcnt = (int) detzcode(up->tzhead.tzh_leapcnt); in tzload()
397 sp->timecnt = (int) detzcode(up->tzhead.tzh_timecnt); in tzload()
398 sp->typecnt = (int) detzcode(up->tzhead.tzh_typecnt); in tzload()
399 sp->charcnt = (int) detzcode(up->tzhead.tzh_charcnt); in tzload()
401 if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || in tzload()
402 sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || in tzload()
403 sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || in tzload()
404 sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || in tzload()
405 (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) || in tzload()
406 (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0)) in tzload()
409 sp->timecnt * stored + /* ats */ in tzload()
410 sp->timecnt + /* types */ in tzload()
411 sp->typecnt * 6 + /* ttinfos */ in tzload()
412 sp->charcnt + /* chars */ in tzload()
413 sp->leapcnt * (stored + 4) + /* lsinfos */ in tzload()
418 for (i = 0; i < sp->timecnt; ++i) { in tzload()
421 sp->types[i] = ((TYPE_SIGNED(time_t) in tzload()
425 if (sp->types[i]) { in tzload()
432 sp->types[i - 1] = 1; in tzload()
433 sp->ats[timecnt++] = time_t_min; in tzload()
435 sp->ats[timecnt++] = at; in tzload()
440 for (i = 0; i < sp->timecnt; ++i) { in tzload()
442 if (sp->typecnt <= typ) in tzload()
444 if (sp->types[i]) in tzload()
445 sp->types[timecnt++] = typ; in tzload()
447 sp->timecnt = timecnt; in tzload()
448 for (i = 0; i < sp->typecnt; ++i) { in tzload()
451 ttisp = &sp->ttis[i]; in tzload()
459 ttisp->tt_abbrind > sp->charcnt) in tzload()
462 for (i = 0; i < sp->charcnt; ++i) in tzload()
463 sp->chars[i] = *p++; in tzload()
464 sp->chars[i] = '\0'; /* ensure '\0' at end */ in tzload()
465 for (i = 0; i < sp->leapcnt; ++i) { in tzload()
468 lsisp = &sp->lsis[i]; in tzload()
475 for (i = 0; i < sp->typecnt; ++i) { in tzload()
478 ttisp = &sp->ttis[i]; in tzload()
488 for (i = 0; i < sp->typecnt; ++i) { in tzload()
491 ttisp = &sp->ttis[i]; in tzload()
517 sp->typecnt + 2 <= TZ_MAX_TYPES) { in tzload()
524 sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) { in tzload()
527 sp->charcnt; in tzload()
529 sp->chars[sp->charcnt++] = in tzload()
534 sp->ats[sp->timecnt - 1]) in tzload()
537 sp->timecnt < TZ_MAX_TIMES) { in tzload()
538 sp->ats[sp->timecnt] = in tzload()
540 sp->types[sp->timecnt] = in tzload()
541 sp->typecnt + in tzload()
543 ++sp->timecnt; in tzload()
546 sp->ttis[sp->typecnt++] = ts.ttis[0]; in tzload()
547 sp->ttis[sp->typecnt++] = ts.ttis[1]; in tzload()
550 if (sp->timecnt > 1) { in tzload()
551 for (i = 1; i < sp->timecnt; ++i) in tzload()
552 if (typesequiv(sp, sp->types[i], sp->types[0]) && in tzload()
553 differ_by_repeat(sp->ats[i], sp->ats[0])) { in tzload()
554 sp->goback = TRUE; in tzload()
557 for (i = sp->timecnt - 2; i >= 0; --i) in tzload()
558 if (typesequiv(sp, sp->types[sp->timecnt - 1], in tzload()
559 sp->types[i]) && in tzload()
560 differ_by_repeat(sp->ats[sp->timecnt - 1], in tzload()
561 sp->ats[i])) { in tzload()
562 sp->goahead = TRUE; in tzload()
570 for (i = 0; i < sp->typecnt; ++i) in tzload()
571 if (sp->types[i] == 0) in tzload()
573 i = (i >= sp->typecnt) ? 0 : -1; in tzload()
581 if (i < 0 && sp->timecnt > 0 && sp->ttis[sp->types[0]].tt_isdst) { in tzload()
582 i = sp->types[0]; in tzload()
584 if (!sp->ttis[i].tt_isdst) in tzload()
593 while (sp->ttis[i].tt_isdst) in tzload()
594 if (++i >= sp->typecnt) { in tzload()
599 sp->defaulttype = i; in tzload()
612 typesequiv(const struct state *const sp, const int a, const int b) in typesequiv() argument
616 if (sp == NULL || in typesequiv()
617 a < 0 || a >= sp->typecnt || in typesequiv()
618 b < 0 || b >= sp->typecnt) in typesequiv()
621 register const struct ttinfo * ap = &sp->ttis[a]; in typesequiv()
622 register const struct ttinfo * bp = &sp->ttis[b]; in typesequiv()
627 strcmp(&sp->chars[ap->tt_abbrind], in typesequiv()
628 &sp->chars[bp->tt_abbrind]) == 0; in typesequiv()
922 tzparse(const char *name, register struct state *const sp, in tzparse() argument
940 if (stdlen >= sizeof sp->chars) in tzparse()
941 stdlen = (sizeof sp->chars) - 1; in tzparse()
962 load_result = tzload(TZDEFRULES, sp, FALSE); in tzparse()
964 sp->leapcnt = 0; /* so, we're off a little */ in tzparse()
1002 sp->typecnt = 2; /* standard time and DST */ in tzparse()
1006 sp->ttis[0] = sp->ttis[1] = zttinfo; in tzparse()
1007 sp->ttis[0].tt_gmtoff = -dstoffset; in tzparse()
1008 sp->ttis[0].tt_isdst = 1; in tzparse()
1009 sp->ttis[0].tt_abbrind = stdlen + 1; in tzparse()
1010 sp->ttis[1].tt_gmtoff = -stdoffset; in tzparse()
1011 sp->ttis[1].tt_isdst = 0; in tzparse()
1012 sp->ttis[1].tt_abbrind = 0; in tzparse()
1013 sp->defaulttype = 0; in tzparse()
1038 sp->ats[timecnt] = janfirst; in tzparse()
1040 (&sp->ats[timecnt], starttime)) in tzparse()
1042 sp->types[timecnt++] = reversed; in tzparse()
1043 sp->ats[timecnt] = janfirst; in tzparse()
1045 (&sp->ats[timecnt], endtime)) in tzparse()
1047 sp->types[timecnt++] = !reversed; in tzparse()
1052 sp->timecnt = timecnt; in tzparse()
1054 sp->typecnt = 1; /* Perpetual DST. */ in tzparse()
1069 for (i = 0; i < sp->timecnt; ++i) { in tzparse()
1070 j = sp->types[i]; in tzparse()
1071 if (!sp->ttis[j].tt_isdst) { in tzparse()
1073 -sp->ttis[j].tt_gmtoff; in tzparse()
1078 for (i = 0; i < sp->timecnt; ++i) { in tzparse()
1079 j = sp->types[i]; in tzparse()
1080 if (sp->ttis[j].tt_isdst) { in tzparse()
1082 -sp->ttis[j].tt_gmtoff; in tzparse()
1095 for (i = 0; i < sp->timecnt; ++i) { in tzparse()
1096 j = sp->types[i]; in tzparse()
1097 sp->types[i] = sp->ttis[j].tt_isdst; in tzparse()
1098 if (sp->ttis[j].tt_ttisgmt) { in tzparse()
1115 if (isdst && !sp->ttis[j].tt_ttisstd) { in tzparse()
1116 sp->ats[i] += dstoffset - in tzparse()
1119 sp->ats[i] += stdoffset - in tzparse()
1123 theiroffset = -sp->ttis[j].tt_gmtoff; in tzparse()
1124 if (sp->ttis[j].tt_isdst) in tzparse()
1131 sp->ttis[0] = sp->ttis[1] = zttinfo; in tzparse()
1132 sp->ttis[0].tt_gmtoff = -stdoffset; in tzparse()
1133 sp->ttis[0].tt_isdst = FALSE; in tzparse()
1134 sp->ttis[0].tt_abbrind = 0; in tzparse()
1135 sp->ttis[1].tt_gmtoff = -dstoffset; in tzparse()
1136 sp->ttis[1].tt_isdst = TRUE; in tzparse()
1137 sp->ttis[1].tt_abbrind = stdlen + 1; in tzparse()
1138 sp->typecnt = 2; in tzparse()
1139 sp->defaulttype = 0; in tzparse()
1143 sp->typecnt = 1; /* only standard time */ in tzparse()
1144 sp->timecnt = 0; in tzparse()
1145 sp->ttis[0] = zttinfo; in tzparse()
1146 sp->ttis[0].tt_gmtoff = -stdoffset; in tzparse()
1147 sp->ttis[0].tt_isdst = 0; in tzparse()
1148 sp->ttis[0].tt_abbrind = 0; in tzparse()
1149 sp->defaulttype = 0; in tzparse()
1151 sp->charcnt = stdlen + 1; in tzparse()
1153 sp->charcnt += dstlen + 1; in tzparse()
1154 if ((size_t) sp->charcnt > sizeof sp->chars) in tzparse()
1156 cp = sp->chars; in tzparse()
1168 gmtload(struct state *const sp) in gmtload() argument
1170 if (tzload(gmt, sp, TRUE) != 0) in gmtload()
1171 (void) tzparse(gmt, sp, TRUE); in gmtload()
1259 register struct state * sp; in localsub() local
1265 sp = lclptr; in localsub()
1266 if (sp == NULL) in localsub()
1268 if ((sp->goback && t < sp->ats[0]) || in localsub()
1269 (sp->goahead && t > sp->ats[sp->timecnt - 1])) { in localsub()
1274 if (t < sp->ats[0]) in localsub()
1275 seconds = sp->ats[0] - t; in localsub()
1276 else seconds = t - sp->ats[sp->timecnt - 1]; in localsub()
1280 if (t < sp->ats[0]) in localsub()
1283 if (newt < sp->ats[0] || in localsub()
1284 newt > sp->ats[sp->timecnt - 1]) in localsub()
1291 if (t < sp->ats[0]) in localsub()
1300 if (sp->timecnt == 0 || t < sp->ats[0]) { in localsub()
1301 i = sp->defaulttype; in localsub()
1304 register int hi = sp->timecnt; in localsub()
1309 if (t < sp->ats[mid]) in localsub()
1313 i = (int) sp->types[lo - 1]; in localsub()
1315 ttisp = &sp->ttis[i]; in localsub()
1322 result = timesub(&t, ttisp->tt_gmtoff, sp, tmp); in localsub()
1324 tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind]; in localsub()
1326 tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind]; in localsub()
1418 register const struct state *const sp, in timesub() argument
1433 i = (sp == NULL) ? 0 : sp->leapcnt; in timesub()
1435 lp = &sp->lsis[i]; in timesub()
1439 lp->ls_corr > sp->lsis[i - 1].ls_corr); in timesub()
1442 sp->lsis[i].ls_trans == in timesub()
1443 sp->lsis[i - 1].ls_trans + 1 && in timesub()
1444 sp->lsis[i].ls_corr == in timesub()
1445 sp->lsis[i - 1].ls_corr + 1) { in timesub()
1673 register const struct state * sp; in time2sub() local
1805 sp = (const struct state *) in time2sub()
1807 if (sp == NULL) in time2sub()
1809 for (i = sp->typecnt - 1; i >= 0; --i) { in time2sub()
1810 if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) in time2sub()
1812 for (j = sp->typecnt - 1; j >= 0; --j) { in time2sub()
1813 if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) in time2sub()
1815 newt = t + sp->ttis[j].tt_gmtoff - in time2sub()
1816 sp->ttis[i].tt_gmtoff; in time2sub()
1865 register const struct state * sp; in time1() local
1898 sp = (const struct state *) ((funcp == localsub) ? lclptr : gmtptr); in time1()
1899 if (sp == NULL) in time1()
1901 for (i = 0; i < sp->typecnt; ++i) in time1()
1904 for (i = sp->timecnt - 1; i >= 0; --i) in time1()
1905 if (!seen[sp->types[i]]) { in time1()
1906 seen[sp->types[i]] = TRUE; in time1()
1907 types[nseen++] = sp->types[i]; in time1()
1911 if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) in time1()
1915 if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) in time1()
1917 tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - in time1()
1918 sp->ttis[samei].tt_gmtoff; in time1()
1923 tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff - in time1()
1924 sp->ttis[samei].tt_gmtoff; in time1()
2002 register struct state * sp; in leapcorr() local
2006 sp = lclptr; in leapcorr()
2007 i = sp->leapcnt; in leapcorr()
2009 lp = &sp->lsis[i]; in leapcorr()