Lines Matching refs:sp
264 update_tzname_etc(struct state const *sp, struct ttinfo const *ttisp) in update_tzname_etc() argument
266 tzname[ttisp->tt_isdst] = (char *) &sp->chars[ttisp->tt_abbrind]; in update_tzname_etc()
280 register struct state * const sp = lclptr; in settzname() local
291 if (sp == NULL) { in settzname()
298 for (i = 0; i < sp->typecnt; ++i) { in settzname()
299 register const struct ttinfo * const ttisp = &sp->ttis[i]; in settzname()
300 update_tzname_etc(sp, ttisp); in settzname()
302 for (i = 0; i < sp->timecnt; ++i) { in settzname()
304 &sp->ttis[ in settzname()
305 sp->types[i]]; in settzname()
306 update_tzname_etc(sp, ttisp); in settzname()
315 scrub_abbrs(struct state *sp) in scrub_abbrs() argument
321 for (i = 0; i < sp->charcnt; ++i) in scrub_abbrs()
322 if (strchr(TZ_ABBR_CHAR_SET, sp->chars[i]) == NULL) in scrub_abbrs()
323 sp->chars[i] = TZ_ABBR_ERR_CHAR; in scrub_abbrs()
327 for (i = 0; i < sp->typecnt; ++i) { in scrub_abbrs()
328 register const struct ttinfo * const ttisp = &sp->ttis[i]; in scrub_abbrs()
329 register char * cp = &sp->chars[ttisp->tt_abbrind]; in scrub_abbrs()
376 tzloadbody(char const *name, struct state *sp, bool doextend, in tzloadbody() argument
390 sp->goback = sp->goahead = false; in tzloadbody()
464 sp->leapcnt = leapcnt; in tzloadbody()
465 sp->timecnt = timecnt; in tzloadbody()
466 sp->typecnt = typecnt; in tzloadbody()
467 sp->charcnt = charcnt; in tzloadbody()
473 for (i = 0; i < sp->timecnt; ++i) { in tzloadbody()
476 sp->types[i] = at <= time_t_max; in tzloadbody()
477 if (sp->types[i]) { in tzloadbody()
481 if (timecnt && attime <= sp->ats[timecnt - 1]) { in tzloadbody()
482 if (attime < sp->ats[timecnt - 1]) in tzloadbody()
484 sp->types[i - 1] = 0; in tzloadbody()
487 sp->ats[timecnt++] = attime; in tzloadbody()
493 for (i = 0; i < sp->timecnt; ++i) { in tzloadbody()
495 if (sp->typecnt <= typ) in tzloadbody()
497 if (sp->types[i]) in tzloadbody()
498 sp->types[timecnt++] = typ; in tzloadbody()
500 sp->timecnt = timecnt; in tzloadbody()
501 for (i = 0; i < sp->typecnt; ++i) { in tzloadbody()
505 ttisp = &sp->ttis[i]; in tzloadbody()
513 if (! (abbrind < sp->charcnt)) in tzloadbody()
517 for (i = 0; i < sp->charcnt; ++i) in tzloadbody()
518 sp->chars[i] = *p++; in tzloadbody()
519 sp->chars[i] = '\0'; /* ensure '\0' at end */ in tzloadbody()
523 for (i = 0; i < sp->leapcnt; ++i) { in tzloadbody()
531 if (leapcnt && trans <= sp->lsis[leapcnt - 1].ls_trans) { in tzloadbody()
532 if (trans < sp->lsis[leapcnt - 1].ls_trans) in tzloadbody()
536 sp->lsis[leapcnt].ls_trans = trans; in tzloadbody()
537 sp->lsis[leapcnt].ls_corr = corr; in tzloadbody()
541 sp->leapcnt = leapcnt; in tzloadbody()
543 for (i = 0; i < sp->typecnt; ++i) { in tzloadbody()
546 ttisp = &sp->ttis[i]; in tzloadbody()
555 for (i = 0; i < sp->typecnt; ++i) { in tzloadbody()
558 ttisp = &sp->ttis[i]; in tzloadbody()
577 sp->typecnt + 2 <= TZ_MAX_TYPES) { in tzloadbody()
592 int charcnt = sp->charcnt; in tzloadbody()
597 if (strcmp(sp->chars + j, tsabbr) == 0) { in tzloadbody()
605 strcpy(sp->chars + j, tsabbr); in tzloadbody()
613 sp->charcnt = charcnt; in tzloadbody()
615 if (sp->ats[sp->timecnt - 1] < ts->ats[i]) in tzloadbody()
618 && sp->timecnt < TZ_MAX_TIMES) { in tzloadbody()
619 sp->ats[sp->timecnt] = ts->ats[i]; in tzloadbody()
620 sp->types[sp->timecnt] = (sp->typecnt in tzloadbody()
622 sp->timecnt++; in tzloadbody()
625 sp->ttis[sp->typecnt++] = ts->ttis[0]; in tzloadbody()
626 sp->ttis[sp->typecnt++] = ts->ttis[1]; in tzloadbody()
630 if (sp->timecnt > 1) { in tzloadbody()
631 for (i = 1; i < sp->timecnt; ++i) in tzloadbody()
632 if (typesequiv(sp, sp->types[i], sp->types[0]) && in tzloadbody()
633 differ_by_repeat(sp->ats[i], sp->ats[0])) { in tzloadbody()
634 sp->goback = true; in tzloadbody()
637 for (i = sp->timecnt - 2; i >= 0; --i) in tzloadbody()
638 if (typesequiv(sp, sp->types[sp->timecnt - 1], in tzloadbody()
639 sp->types[i]) && in tzloadbody()
640 differ_by_repeat(sp->ats[sp->timecnt - 1], in tzloadbody()
641 sp->ats[i])) { in tzloadbody()
642 sp->goahead = true; in tzloadbody()
650 for (i = 0; i < sp->timecnt; ++i) in tzloadbody()
651 if (sp->types[i] == 0) in tzloadbody()
653 i = i < sp->timecnt ? -1 : 0; in tzloadbody()
661 if (i < 0 && sp->timecnt > 0 && sp->ttis[sp->types[0]].tt_isdst) { in tzloadbody()
662 i = sp->types[0]; in tzloadbody()
664 if (!sp->ttis[i].tt_isdst) in tzloadbody()
673 while (sp->ttis[i].tt_isdst) in tzloadbody()
674 if (++i >= sp->typecnt) { in tzloadbody()
679 sp->defaulttype = i; in tzloadbody()
686 tzload(char const *name, struct state *sp, bool doextend) in tzload() argument
693 int err = tzloadbody(name, sp, doextend, lsp); in tzload()
699 return tzloadbody(name, sp, doextend, &ls); in tzload()
704 typesequiv(const struct state *sp, int a, int b) in typesequiv() argument
708 if (sp == NULL || in typesequiv()
709 a < 0 || a >= sp->typecnt || in typesequiv()
710 b < 0 || b >= sp->typecnt) in typesequiv()
713 register const struct ttinfo * ap = &sp->ttis[a]; in typesequiv()
714 register const struct ttinfo * bp = &sp->ttis[b]; in typesequiv()
719 strcmp(&sp->chars[ap->tt_abbrind], in typesequiv()
720 &sp->chars[bp->tt_abbrind]) == 0; in typesequiv()
1014 tzparse(const char *name, struct state *sp, bool lastditch) in tzparse() argument
1051 if (sizeof sp->chars < charcnt) in tzparse()
1053 load_ok = tzload(TZDEFRULES, sp, false) == 0; in tzparse()
1055 sp->leapcnt = 0; /* so, we're off a little */ in tzparse()
1072 if (sizeof sp->chars < charcnt) in tzparse()
1098 sp->typecnt = 2; /* standard time and DST */ in tzparse()
1102 init_ttinfo(&sp->ttis[0], -dstoffset, true, stdlen + 1); in tzparse()
1103 init_ttinfo(&sp->ttis[1], -stdoffset, false, 0); in tzparse()
1104 sp->defaulttype = 0; in tzparse()
1129 sp->ats[timecnt] = janfirst; in tzparse()
1131 (&sp->ats[timecnt], starttime)) in tzparse()
1133 sp->types[timecnt++] = reversed; in tzparse()
1134 sp->ats[timecnt] = janfirst; in tzparse()
1136 (&sp->ats[timecnt], endtime)) in tzparse()
1138 sp->types[timecnt++] = !reversed; in tzparse()
1143 sp->timecnt = timecnt; in tzparse()
1145 sp->typecnt = 1; /* Perpetual DST. */ in tzparse()
1160 for (i = 0; i < sp->timecnt; ++i) { in tzparse()
1161 j = sp->types[i]; in tzparse()
1162 if (!sp->ttis[j].tt_isdst) { in tzparse()
1164 -sp->ttis[j].tt_gmtoff; in tzparse()
1169 for (i = 0; i < sp->timecnt; ++i) { in tzparse()
1170 j = sp->types[i]; in tzparse()
1171 if (sp->ttis[j].tt_isdst) { in tzparse()
1173 -sp->ttis[j].tt_gmtoff; in tzparse()
1186 for (i = 0; i < sp->timecnt; ++i) { in tzparse()
1187 j = sp->types[i]; in tzparse()
1188 sp->types[i] = sp->ttis[j].tt_isdst; in tzparse()
1189 if (sp->ttis[j].tt_ttisgmt) { in tzparse()
1206 if (isdst && !sp->ttis[j].tt_ttisstd) { in tzparse()
1207 sp->ats[i] += dstoffset - in tzparse()
1210 sp->ats[i] += stdoffset - in tzparse()
1214 theiroffset = -sp->ttis[j].tt_gmtoff; in tzparse()
1215 if (sp->ttis[j].tt_isdst) in tzparse()
1222 init_ttinfo(&sp->ttis[0], -stdoffset, false, 0); in tzparse()
1223 init_ttinfo(&sp->ttis[1], -dstoffset, true, stdlen + 1); in tzparse()
1224 sp->typecnt = 2; in tzparse()
1225 sp->defaulttype = 0; in tzparse()
1229 sp->typecnt = 1; /* only standard time */ in tzparse()
1230 sp->timecnt = 0; in tzparse()
1231 init_ttinfo(&sp->ttis[0], -stdoffset, false, 0); in tzparse()
1232 sp->defaulttype = 0; in tzparse()
1234 sp->charcnt = charcnt; in tzparse()
1235 cp = sp->chars; in tzparse()
1247 gmtload(struct state *const sp) in gmtload() argument
1249 if (tzload(gmt, sp, true) != 0) in gmtload()
1250 tzparse(gmt, sp, true); in gmtload()
1256 zoneinit(struct state *sp, char const *name) in zoneinit() argument
1262 sp->leapcnt = 0; /* so, we're off a little */ in zoneinit()
1263 sp->timecnt = 0; in zoneinit()
1264 sp->typecnt = 0; in zoneinit()
1265 sp->charcnt = 0; in zoneinit()
1266 sp->goback = sp->goahead = false; in zoneinit()
1267 init_ttinfo(&sp->ttis[0], 0, false, 0); in zoneinit()
1268 strcpy(sp->chars, gmt); in zoneinit()
1269 sp->defaulttype = 0; in zoneinit()
1272 int err = tzload(name, sp, true); in zoneinit()
1273 if (err != 0 && name && name[0] != ':' && tzparse(name, sp, false)) in zoneinit()
1276 scrub_abbrs(sp); in zoneinit()
1284 struct state *sp = lclptr; in tzsetlcl() local
1291 if (! sp) in tzsetlcl()
1292 lclptr = sp = malloc(sizeof *lclptr); in tzsetlcl()
1294 if (sp) { in tzsetlcl()
1295 if (zoneinit(sp, name) != 0) in tzsetlcl()
1296 zoneinit(sp, ""); in tzsetlcl()
1356 timezone_t sp = malloc(sizeof *sp); in tzalloc() local
1357 if (sp) { in tzalloc()
1358 int err = zoneinit(sp, name); in tzalloc()
1360 free(sp); in tzalloc()
1365 return sp; in tzalloc()
1369 tzfree(timezone_t sp) in tzfree() argument
1371 free(sp); in tzfree()
1402 localsub(struct state const *sp, time_t const *timep, int_fast32_t setname, in localsub() argument
1410 if (sp == NULL) { in localsub()
1414 if ((sp->goback && t < sp->ats[0]) || in localsub()
1415 (sp->goahead && t > sp->ats[sp->timecnt - 1])) { in localsub()
1420 if (t < sp->ats[0]) in localsub()
1421 seconds = sp->ats[0] - t; in localsub()
1422 else seconds = t - sp->ats[sp->timecnt - 1]; in localsub()
1426 if (t < sp->ats[0]) in localsub()
1429 if (newt < sp->ats[0] || in localsub()
1430 newt > sp->ats[sp->timecnt - 1]) in localsub()
1432 result = localsub(sp, &newt, setname, tmp); in localsub()
1437 if (t < sp->ats[0]) in localsub()
1446 if (sp->timecnt == 0 || t < sp->ats[0]) { in localsub()
1447 i = sp->defaulttype; in localsub()
1450 register int hi = sp->timecnt; in localsub()
1455 if (t < sp->ats[mid]) in localsub()
1459 i = (int) sp->types[lo - 1]; in localsub()
1461 ttisp = &sp->ttis[i]; in localsub()
1468 result = timesub(&t, ttisp->tt_gmtoff, sp, tmp); in localsub()
1472 result->TM_ZONE = (char *) &sp->chars[ttisp->tt_abbrind]; in localsub()
1475 update_tzname_etc(sp, ttisp); in localsub()
1483 localtime_rz(struct state *sp, time_t const *timep, struct tm *tmp) in localtime_rz() argument
1485 return localsub(sp, timep, 0, tmp); in localtime_rz()
1528 gmtsub(struct state const *sp, time_t const *timep, int_fast32_t offset, in gmtsub() argument
1588 const struct state *sp, struct tm *tmp) in timesub() argument
1602 i = (sp == NULL) ? 0 : sp->leapcnt; in timesub()
1604 lp = &sp->lsis[i]; in timesub()
1608 lp->ls_corr > sp->lsis[i - 1].ls_corr); in timesub()
1611 sp->lsis[i].ls_trans == in timesub()
1612 sp->lsis[i - 1].ls_trans + 1 && in timesub()
1613 sp->lsis[i].ls_corr == in timesub()
1614 sp->lsis[i - 1].ls_corr + 1) { in timesub()
1836 struct state const *sp, in time2sub() argument
1930 if (! funcp(sp, &t, offset, &mytm)) { in time2sub()
1976 if (funcp(sp, &altt, offset, &alttm) in time2sub()
1994 if (sp == NULL) in time2sub()
1996 for (i = sp->typecnt - 1; i >= 0; --i) { in time2sub()
1997 if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) in time2sub()
1999 for (j = sp->typecnt - 1; j >= 0; --j) { in time2sub()
2000 if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) in time2sub()
2002 newt = t + sp->ttis[j].tt_gmtoff - in time2sub()
2003 sp->ttis[i].tt_gmtoff; in time2sub()
2004 if (! funcp(sp, &newt, offset, &mytm)) in time2sub()
2024 if (funcp(sp, &t, offset, tmp)) in time2sub()
2033 struct state const *sp, in time2() argument
2044 t = time2sub(tmp, funcp, sp, offset, okayp, false); in time2()
2045 return *okayp ? t : time2sub(tmp, funcp, sp, offset, okayp, true); in time2()
2052 struct state const *sp, in time1() argument
2070 t = time2(tmp, funcp, sp, offset, &okay); in time1()
2088 if (sp == NULL) in time1()
2090 for (i = 0; i < sp->typecnt; ++i) in time1()
2093 for (i = sp->timecnt - 1; i >= 0; --i) in time1()
2094 if (!seen[sp->types[i]]) { in time1()
2095 seen[sp->types[i]] = true; in time1()
2096 types[nseen++] = sp->types[i]; in time1()
2100 if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) in time1()
2104 if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) in time1()
2106 tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - in time1()
2107 sp->ttis[samei].tt_gmtoff; in time1()
2109 t = time2(tmp, funcp, sp, offset, &okay); in time1()
2112 tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff - in time1()
2113 sp->ttis[samei].tt_gmtoff; in time1()
2121 mktime_tzname(struct state *sp, struct tm *tmp, bool setname) in mktime_tzname() argument
2123 if (sp) in mktime_tzname()
2124 return time1(tmp, localsub, sp, setname); in mktime_tzname()
2134 mktime_z(struct state *sp, struct tm *tmp) in mktime_z() argument
2136 return mktime_tzname(sp, tmp, false); in mktime_z()
2206 leapcorr(struct state const *sp, time_t t) in leapcorr() argument
2211 i = sp->leapcnt; in leapcorr()
2213 lp = &sp->lsis[i]; in leapcorr()
2221 time2posix_z(struct state *sp, time_t t) in time2posix_z() argument
2223 return t - leapcorr(sp, t); in time2posix_z()
2243 posix2time_z(struct state *sp, time_t t) in posix2time_z() argument
2253 x = t + leapcorr(sp, t); in posix2time_z()
2254 y = x - leapcorr(sp, x); in posix2time_z()
2258 y = x - leapcorr(sp, x); in posix2time_z()
2264 y = x - leapcorr(sp, x); in posix2time_z()