Lines Matching refs:sp
146 static void gmtload(struct state * sp);
173 const struct state * sp, struct tm * tmp);
179 static int typesequiv(const struct state * sp, int a, int b);
180 static int tzload(const char * name, struct state * sp,
182 static int tzparse(const char * name, struct state * sp,
256 register struct state * const sp = lclptr; in settzname() local
267 if (sp == NULL) { in settzname()
274 for (i = 0; i < sp->typecnt; ++i) { in settzname()
275 register const struct ttinfo * const ttisp = &sp->ttis[i]; in settzname()
277 tzname[ttisp->tt_isdst] = &sp->chars[ttisp->tt_abbrind]; in settzname()
279 for (i = 0; i < sp->timecnt; ++i) { in settzname()
281 &sp->ttis[ in settzname()
282 sp->types[i]]; in settzname()
285 &sp->chars[ttisp->tt_abbrind]; in settzname()
301 for (i = 0; i < sp->charcnt; ++i) in settzname()
302 if (strchr(TZ_ABBR_CHAR_SET, sp->chars[i]) == NULL) in settzname()
303 sp->chars[i] = TZ_ABBR_ERR_CHAR; in settzname()
307 for (i = 0; i < sp->typecnt; ++i) { in settzname()
308 register const struct ttinfo * const ttisp = &sp->ttis[i]; in settzname()
309 register char * cp = &sp->chars[ttisp->tt_abbrind]; in settzname()
326 tzload(register const char *name, register struct state *const sp, in tzload() argument
337 2 * sizeof *sp + in tzload()
347 sp->goback = sp->goahead = false; in tzload()
398 sp->leapcnt = (int) detzcode(up->tzhead.tzh_leapcnt); in tzload()
399 sp->timecnt = (int) detzcode(up->tzhead.tzh_timecnt); in tzload()
400 sp->typecnt = (int) detzcode(up->tzhead.tzh_typecnt); in tzload()
401 sp->charcnt = (int) detzcode(up->tzhead.tzh_charcnt); in tzload()
403 if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || in tzload()
404 sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || in tzload()
405 sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || in tzload()
406 sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || in tzload()
407 (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) || in tzload()
408 (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0)) in tzload()
411 sp->timecnt * stored + /* ats */ in tzload()
412 sp->timecnt + /* types */ in tzload()
413 sp->typecnt * 6 + /* ttinfos */ in tzload()
414 sp->charcnt + /* chars */ in tzload()
415 sp->leapcnt * (stored + 4) + /* lsinfos */ in tzload()
420 for (i = 0; i < sp->timecnt; ++i) { in tzload()
423 sp->types[i] = ((TYPE_SIGNED(time_t) in tzload()
427 if (sp->types[i]) { in tzload()
434 sp->types[i - 1] = 1; in tzload()
435 sp->ats[timecnt++] = time_t_min; in tzload()
437 sp->ats[timecnt++] = at; in tzload()
442 for (i = 0; i < sp->timecnt; ++i) { in tzload()
444 if (sp->typecnt <= typ) in tzload()
446 if (sp->types[i]) in tzload()
447 sp->types[timecnt++] = typ; in tzload()
449 sp->timecnt = timecnt; in tzload()
450 for (i = 0; i < sp->typecnt; ++i) { in tzload()
453 ttisp = &sp->ttis[i]; in tzload()
461 ttisp->tt_abbrind > sp->charcnt) in tzload()
464 for (i = 0; i < sp->charcnt; ++i) in tzload()
465 sp->chars[i] = *p++; in tzload()
466 sp->chars[i] = '\0'; /* ensure '\0' at end */ in tzload()
467 for (i = 0; i < sp->leapcnt; ++i) { in tzload()
470 lsisp = &sp->lsis[i]; in tzload()
477 for (i = 0; i < sp->typecnt; ++i) { in tzload()
480 ttisp = &sp->ttis[i]; in tzload()
490 for (i = 0; i < sp->typecnt; ++i) { in tzload()
493 ttisp = &sp->ttis[i]; in tzload()
519 sp->typecnt + 2 <= TZ_MAX_TYPES) { in tzload()
526 sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) { in tzload()
529 sp->charcnt; in tzload()
531 sp->chars[sp->charcnt++] = in tzload()
536 sp->ats[sp->timecnt - 1]) in tzload()
539 sp->timecnt < TZ_MAX_TIMES) { in tzload()
540 sp->ats[sp->timecnt] = in tzload()
542 sp->types[sp->timecnt] = in tzload()
543 sp->typecnt + in tzload()
545 ++sp->timecnt; in tzload()
548 sp->ttis[sp->typecnt++] = ts.ttis[0]; in tzload()
549 sp->ttis[sp->typecnt++] = ts.ttis[1]; in tzload()
552 if (sp->timecnt > 1) { in tzload()
553 for (i = 1; i < sp->timecnt; ++i) in tzload()
554 if (typesequiv(sp, sp->types[i], sp->types[0]) && in tzload()
555 differ_by_repeat(sp->ats[i], sp->ats[0])) { in tzload()
556 sp->goback = true; in tzload()
559 for (i = sp->timecnt - 2; i >= 0; --i) in tzload()
560 if (typesequiv(sp, sp->types[sp->timecnt - 1], in tzload()
561 sp->types[i]) && in tzload()
562 differ_by_repeat(sp->ats[sp->timecnt - 1], in tzload()
563 sp->ats[i])) { in tzload()
564 sp->goahead = true; in tzload()
572 for (i = 0; i < sp->typecnt; ++i) in tzload()
573 if (sp->types[i] == 0) in tzload()
575 i = (i >= sp->typecnt) ? 0 : -1; in tzload()
583 if (i < 0 && sp->timecnt > 0 && sp->ttis[sp->types[0]].tt_isdst) { in tzload()
584 i = sp->types[0]; in tzload()
586 if (!sp->ttis[i].tt_isdst) in tzload()
595 while (sp->ttis[i].tt_isdst) in tzload()
596 if (++i >= sp->typecnt) { in tzload()
601 sp->defaulttype = i; in tzload()
614 typesequiv(const struct state *const sp, const int a, const int b) in typesequiv() argument
618 if (sp == NULL || in typesequiv()
619 a < 0 || a >= sp->typecnt || in typesequiv()
620 b < 0 || b >= sp->typecnt) in typesequiv()
623 register const struct ttinfo * ap = &sp->ttis[a]; in typesequiv()
624 register const struct ttinfo * bp = &sp->ttis[b]; in typesequiv()
629 strcmp(&sp->chars[ap->tt_abbrind], in typesequiv()
630 &sp->chars[bp->tt_abbrind]) == 0; in typesequiv()
924 tzparse(const char *name, register struct state *const sp, in tzparse() argument
942 if (stdlen >= sizeof sp->chars) in tzparse()
943 stdlen = (sizeof sp->chars) - 1; in tzparse()
964 load_result = tzload(TZDEFRULES, sp, false); in tzparse()
966 sp->leapcnt = 0; /* so, we're off a little */ in tzparse()
1004 sp->typecnt = 2; /* standard time and DST */ in tzparse()
1008 sp->ttis[0] = sp->ttis[1] = zttinfo; in tzparse()
1009 sp->ttis[0].tt_gmtoff = -dstoffset; in tzparse()
1010 sp->ttis[0].tt_isdst = 1; in tzparse()
1011 sp->ttis[0].tt_abbrind = stdlen + 1; in tzparse()
1012 sp->ttis[1].tt_gmtoff = -stdoffset; in tzparse()
1013 sp->ttis[1].tt_isdst = 0; in tzparse()
1014 sp->ttis[1].tt_abbrind = 0; in tzparse()
1015 sp->defaulttype = 0; in tzparse()
1040 sp->ats[timecnt] = janfirst; in tzparse()
1042 (&sp->ats[timecnt], starttime)) in tzparse()
1044 sp->types[timecnt++] = reversed; in tzparse()
1045 sp->ats[timecnt] = janfirst; in tzparse()
1047 (&sp->ats[timecnt], endtime)) in tzparse()
1049 sp->types[timecnt++] = !reversed; in tzparse()
1054 sp->timecnt = timecnt; in tzparse()
1056 sp->typecnt = 1; /* Perpetual DST. */ in tzparse()
1071 for (i = 0; i < sp->timecnt; ++i) { in tzparse()
1072 j = sp->types[i]; in tzparse()
1073 if (!sp->ttis[j].tt_isdst) { in tzparse()
1075 -sp->ttis[j].tt_gmtoff; in tzparse()
1080 for (i = 0; i < sp->timecnt; ++i) { in tzparse()
1081 j = sp->types[i]; in tzparse()
1082 if (sp->ttis[j].tt_isdst) { in tzparse()
1084 -sp->ttis[j].tt_gmtoff; in tzparse()
1097 for (i = 0; i < sp->timecnt; ++i) { in tzparse()
1098 j = sp->types[i]; in tzparse()
1099 sp->types[i] = sp->ttis[j].tt_isdst; in tzparse()
1100 if (sp->ttis[j].tt_ttisgmt) { in tzparse()
1117 if (isdst && !sp->ttis[j].tt_ttisstd) { in tzparse()
1118 sp->ats[i] += dstoffset - in tzparse()
1121 sp->ats[i] += stdoffset - in tzparse()
1125 theiroffset = -sp->ttis[j].tt_gmtoff; in tzparse()
1126 if (sp->ttis[j].tt_isdst) in tzparse()
1133 sp->ttis[0] = sp->ttis[1] = zttinfo; in tzparse()
1134 sp->ttis[0].tt_gmtoff = -stdoffset; in tzparse()
1135 sp->ttis[0].tt_isdst = false; in tzparse()
1136 sp->ttis[0].tt_abbrind = 0; in tzparse()
1137 sp->ttis[1].tt_gmtoff = -dstoffset; in tzparse()
1138 sp->ttis[1].tt_isdst = true; in tzparse()
1139 sp->ttis[1].tt_abbrind = stdlen + 1; in tzparse()
1140 sp->typecnt = 2; in tzparse()
1141 sp->defaulttype = 0; in tzparse()
1145 sp->typecnt = 1; /* only standard time */ in tzparse()
1146 sp->timecnt = 0; in tzparse()
1147 sp->ttis[0] = zttinfo; in tzparse()
1148 sp->ttis[0].tt_gmtoff = -stdoffset; in tzparse()
1149 sp->ttis[0].tt_isdst = 0; in tzparse()
1150 sp->ttis[0].tt_abbrind = 0; in tzparse()
1151 sp->defaulttype = 0; in tzparse()
1153 sp->charcnt = stdlen + 1; in tzparse()
1155 sp->charcnt += dstlen + 1; in tzparse()
1156 if ((size_t) sp->charcnt > sizeof sp->chars) in tzparse()
1158 cp = sp->chars; in tzparse()
1170 gmtload(struct state *const sp) in gmtload() argument
1172 if (tzload(gmt, sp, true) != 0) in gmtload()
1173 (void) tzparse(gmt, sp, true); in gmtload()
1261 register struct state * sp; in localsub() local
1267 sp = lclptr; in localsub()
1268 if (sp == NULL) in localsub()
1270 if ((sp->goback && t < sp->ats[0]) || in localsub()
1271 (sp->goahead && t > sp->ats[sp->timecnt - 1])) { in localsub()
1276 if (t < sp->ats[0]) in localsub()
1277 seconds = sp->ats[0] - t; in localsub()
1278 else seconds = t - sp->ats[sp->timecnt - 1]; in localsub()
1282 if (t < sp->ats[0]) in localsub()
1285 if (newt < sp->ats[0] || in localsub()
1286 newt > sp->ats[sp->timecnt - 1]) in localsub()
1293 if (t < sp->ats[0]) in localsub()
1302 if (sp->timecnt == 0 || t < sp->ats[0]) { in localsub()
1303 i = sp->defaulttype; in localsub()
1306 register int hi = sp->timecnt; in localsub()
1311 if (t < sp->ats[mid]) in localsub()
1315 i = (int) sp->types[lo - 1]; in localsub()
1317 ttisp = &sp->ttis[i]; in localsub()
1324 result = timesub(&t, ttisp->tt_gmtoff, sp, tmp); in localsub()
1326 tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind]; in localsub()
1328 tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind]; in localsub()
1420 register const struct state *const sp, in timesub() argument
1435 i = (sp == NULL) ? 0 : sp->leapcnt; in timesub()
1437 lp = &sp->lsis[i]; in timesub()
1441 lp->ls_corr > sp->lsis[i - 1].ls_corr); in timesub()
1444 sp->lsis[i].ls_trans == in timesub()
1445 sp->lsis[i - 1].ls_trans + 1 && in timesub()
1446 sp->lsis[i].ls_corr == in timesub()
1447 sp->lsis[i - 1].ls_corr + 1) { in timesub()
1675 register const struct state * sp; in time2sub() local
1807 sp = (const struct state *) in time2sub()
1809 if (sp == NULL) in time2sub()
1811 for (i = sp->typecnt - 1; i >= 0; --i) { in time2sub()
1812 if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) in time2sub()
1814 for (j = sp->typecnt - 1; j >= 0; --j) { in time2sub()
1815 if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) in time2sub()
1817 newt = t + sp->ttis[j].tt_gmtoff - in time2sub()
1818 sp->ttis[i].tt_gmtoff; in time2sub()
1867 register const struct state * sp; in time1() local
1900 sp = (const struct state *) ((funcp == localsub) ? lclptr : gmtptr); in time1()
1901 if (sp == NULL) in time1()
1903 for (i = 0; i < sp->typecnt; ++i) in time1()
1906 for (i = sp->timecnt - 1; i >= 0; --i) in time1()
1907 if (!seen[sp->types[i]]) { in time1()
1908 seen[sp->types[i]] = true; in time1()
1909 types[nseen++] = sp->types[i]; in time1()
1913 if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) in time1()
1917 if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) in time1()
1919 tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - in time1()
1920 sp->ttis[samei].tt_gmtoff; in time1()
1925 tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff - in time1()
1926 sp->ttis[samei].tt_gmtoff; in time1()
2004 register struct state * sp; in leapcorr() local
2008 sp = lclptr; in leapcorr()
2009 i = sp->leapcnt; in leapcorr()
2011 lp = &sp->lsis[i]; in leapcorr()