• Home
  • Raw
  • Download

Lines Matching refs:sp

220 ttunspecified(struct state const *sp, int i)  in ttunspecified()  argument
222 char const *abbr = &sp->chars[sp->ttis[i].tt_desigidx]; in ttunspecified()
274 update_tzname_etc(struct state const *sp, struct ttinfo const *ttisp) in update_tzname_etc() argument
277 tzname[ttisp->tt_isdst] = (char *) &sp->chars[ttisp->tt_desigidx]; in update_tzname_etc()
294 may_update_tzname_etc(int stddst_mask, struct state *sp, int type) in may_update_tzname_etc() argument
296 struct ttinfo *ttisp = &sp->ttis[type]; in may_update_tzname_etc()
299 update_tzname_etc(sp, ttisp); in may_update_tzname_etc()
300 if (!ttunspecified(sp, type)) in may_update_tzname_etc()
309 register struct state * const sp = lclptr; in settzname() local
318 tzname[0] = tzname[1] = (char *) (sp ? wildabbr : utc); in settzname()
332 if (sp) { in settzname()
333 for (i = sp->timecnt - 1; stddst_mask && 0 <= i; i--) in settzname()
334 stddst_mask = may_update_tzname_etc(stddst_mask, sp, sp->types[i]); in settzname()
335 for (i = sp->typecnt - 1; stddst_mask && 0 <= i; i--) in settzname()
336 stddst_mask = may_update_tzname_etc(stddst_mask, sp, i); in settzname()
347 scrub_abbrs(struct state *sp) in scrub_abbrs() argument
352 for (i = 0; i < sp->charcnt - (TZNAME_MAXIMUM + 1); ) { in scrub_abbrs()
353 int len = strlen(&sp->chars[i]); in scrub_abbrs()
360 for (i = 0; i < sp->charcnt; ++i) in scrub_abbrs()
361 if (strchr(TZ_ABBR_CHAR_SET, sp->chars[i]) == NULL) in scrub_abbrs()
362 sp->chars[i] = TZ_ABBR_ERR_CHAR; in scrub_abbrs()
399 tzloadbody(char const *name, struct state *sp, bool doextend, in tzloadbody() argument
410 sp->goback = sp->goahead = false; in tzloadbody()
504 sp->leapcnt = leapcnt; in tzloadbody()
505 sp->timecnt = timecnt; in tzloadbody()
506 sp->typecnt = typecnt; in tzloadbody()
507 sp->charcnt = charcnt; in tzloadbody()
513 for (i = 0; i < sp->timecnt; ++i) { in tzloadbody()
516 sp->types[i] = at <= TIME_T_MAX; in tzloadbody()
517 if (sp->types[i]) { in tzloadbody()
521 if (timecnt && attime <= sp->ats[timecnt - 1]) { in tzloadbody()
522 if (attime < sp->ats[timecnt - 1]) in tzloadbody()
524 sp->types[i - 1] = 0; in tzloadbody()
527 sp->ats[timecnt++] = attime; in tzloadbody()
533 for (i = 0; i < sp->timecnt; ++i) { in tzloadbody()
535 if (sp->typecnt <= typ) in tzloadbody()
537 if (sp->types[i]) in tzloadbody()
538 sp->types[timecnt++] = typ; in tzloadbody()
540 sp->timecnt = timecnt; in tzloadbody()
541 for (i = 0; i < sp->typecnt; ++i) { in tzloadbody()
545 ttisp = &sp->ttis[i]; in tzloadbody()
553 if (! (desigidx < sp->charcnt)) in tzloadbody()
557 for (i = 0; i < sp->charcnt; ++i) in tzloadbody()
558 sp->chars[i] = *p++; in tzloadbody()
561 memset(&sp->chars[i], 0, CHARS_EXTRA); in tzloadbody()
565 for (i = 0; i < sp->leapcnt; ++i) { in tzloadbody()
590 sp->lsis[leapcnt].ls_trans = tr; in tzloadbody()
591 sp->lsis[leapcnt].ls_corr = corr; in tzloadbody()
595 sp->leapcnt = leapcnt; in tzloadbody()
597 for (i = 0; i < sp->typecnt; ++i) { in tzloadbody()
600 ttisp = &sp->ttis[i]; in tzloadbody()
609 for (i = 0; i < sp->typecnt; ++i) { in tzloadbody()
612 ttisp = &sp->ttis[i]; in tzloadbody()
632 sp->typecnt + 2 <= TZ_MAX_TYPES) { in tzloadbody()
636 if (tzparse(&up->buf[1], ts, sp)) { in tzloadbody()
646 int charcnt = sp->charcnt; in tzloadbody()
651 if (strcmp(sp->chars + j, tsabbr) == 0) { in tzloadbody()
659 strcpy(sp->chars + j, tsabbr); in tzloadbody()
667 sp->charcnt = charcnt; in tzloadbody()
672 while (1 < sp->timecnt in tzloadbody()
673 && (sp->types[sp->timecnt - 1] in tzloadbody()
674 == sp->types[sp->timecnt - 2])) in tzloadbody()
675 sp->timecnt--; in tzloadbody()
678 i < ts->timecnt && sp->timecnt < TZ_MAX_TIMES; in tzloadbody()
681 if (increment_overflow_time(&t, leapcorr(sp, t)) in tzloadbody()
682 || (0 < sp->timecnt in tzloadbody()
683 && t <= sp->ats[sp->timecnt - 1])) in tzloadbody()
685 sp->ats[sp->timecnt] = t; in tzloadbody()
686 sp->types[sp->timecnt] = (sp->typecnt in tzloadbody()
688 sp->timecnt++; in tzloadbody()
691 sp->ttis[sp->typecnt++] = ts->ttis[i]; in tzloadbody()
695 if (sp->typecnt == 0) in tzloadbody()
697 if (sp->timecnt > 1) { in tzloadbody()
698 if (sp->ats[0] <= TIME_T_MAX - SECSPERREPEAT) { in tzloadbody()
699 time_t repeatat = sp->ats[0] + SECSPERREPEAT; in tzloadbody()
700 int repeattype = sp->types[0]; in tzloadbody()
701 for (i = 1; i < sp->timecnt; ++i) in tzloadbody()
702 if (sp->ats[i] == repeatat in tzloadbody()
703 && typesequiv(sp, sp->types[i], repeattype)) { in tzloadbody()
704 sp->goback = true; in tzloadbody()
708 if (TIME_T_MIN + SECSPERREPEAT <= sp->ats[sp->timecnt - 1]) { in tzloadbody()
709 time_t repeatat = sp->ats[sp->timecnt - 1] - SECSPERREPEAT; in tzloadbody()
710 int repeattype = sp->types[sp->timecnt - 1]; in tzloadbody()
711 for (i = sp->timecnt - 2; i >= 0; --i) in tzloadbody()
712 if (sp->ats[i] == repeatat in tzloadbody()
713 && typesequiv(sp, sp->types[i], repeattype)) { in tzloadbody()
714 sp->goahead = true; in tzloadbody()
734 for (i = 0; i < sp->timecnt; ++i) in tzloadbody()
735 if (sp->types[i] == 0) in tzloadbody()
737 i = i < sp->timecnt && ! ttunspecified(sp, 0) ? -1 : 0; in tzloadbody()
745 if (i < 0 && sp->timecnt > 0 && sp->ttis[sp->types[0]].tt_isdst) { in tzloadbody()
746 i = sp->types[0]; in tzloadbody()
748 if (!sp->ttis[i].tt_isdst) in tzloadbody()
760 while (sp->ttis[i].tt_isdst) in tzloadbody()
761 if (++i >= sp->typecnt) { in tzloadbody()
770 sp->defaulttype = i; in tzloadbody()
778 tzload(char const *name, struct state *sp, bool doextend) in tzload() argument
785 int err = tzloadbody(name, sp, doextend, lsp); in tzload()
791 return tzloadbody(name, sp, doextend, &ls); in tzload()
796 typesequiv(const struct state *sp, int a, int b) in typesequiv() argument
800 if (sp == NULL || in typesequiv()
801 a < 0 || a >= sp->typecnt || in typesequiv()
802 b < 0 || b >= sp->typecnt) in typesequiv()
809 register const struct ttinfo * ap = &sp->ttis[a]; in typesequiv()
810 register const struct ttinfo * bp = &sp->ttis[b]; in typesequiv()
813 && (strcmp(&sp->chars[ap->tt_desigidx], in typesequiv()
814 &sp->chars[bp->tt_desigidx]) in typesequiv()
1119 tzparse(const char *name, struct state *sp, struct state *basep) in tzparse() argument
1153 sp->leapcnt = basep->leapcnt; in tzparse()
1154 memcpy(sp->lsis, basep->lsis, sp->leapcnt * sizeof *sp->lsis); in tzparse()
1156 load_ok = tzload(TZDEFRULES, sp, false) == 0; in tzparse()
1158 sp->leapcnt = 0; /* So, we're off a little. */ in tzparse()
1160 if (0 < sp->leapcnt) in tzparse()
1161 leaplo = sp->lsis[sp->leapcnt - 1].ls_trans; in tzparse()
1203 sp->typecnt = 2; /* standard time and DST */ in tzparse()
1207 init_ttinfo(&sp->ttis[0], -stdoffset, false, 0); in tzparse()
1208 init_ttinfo(&sp->ttis[1], -dstoffset, true, stdlen + 1); in tzparse()
1209 sp->defaulttype = 0; in tzparse()
1259 sp->ats[timecnt] = janfirst; in tzparse()
1261 (&sp->ats[timecnt], in tzparse()
1263 && atlo <= sp->ats[timecnt]) in tzparse()
1264 sp->types[timecnt++] = !reversed; in tzparse()
1265 sp->ats[timecnt] = janfirst; in tzparse()
1267 (&sp->ats[timecnt], in tzparse()
1269 && atlo <= sp->ats[timecnt]) { in tzparse()
1270 sp->types[timecnt++] = reversed; in tzparse()
1284 sp->timecnt = timecnt; in tzparse()
1286 sp->ttis[0] = sp->ttis[1]; in tzparse()
1287 sp->typecnt = 1; /* Perpetual DST. */ in tzparse()
1289 sp->goback = sp->goahead = true; in tzparse()
1304 for (i = 0; i < sp->timecnt; ++i) { in tzparse()
1305 j = sp->types[i]; in tzparse()
1306 if (!sp->ttis[j].tt_isdst) { in tzparse()
1308 - sp->ttis[j].tt_utoff; in tzparse()
1313 for (i = 0; i < sp->timecnt; ++i) { in tzparse()
1314 j = sp->types[i]; in tzparse()
1315 if (sp->ttis[j].tt_isdst) { in tzparse()
1317 - sp->ttis[j].tt_utoff; in tzparse()
1329 for (i = 0; i < sp->timecnt; ++i) { in tzparse()
1330 j = sp->types[i]; in tzparse()
1331 sp->types[i] = sp->ttis[j].tt_isdst; in tzparse()
1332 if (sp->ttis[j].tt_ttisut) { in tzparse()
1350 if (isdst && !sp->ttis[j].tt_ttisstd) { in tzparse()
1351 sp->ats[i] += dstoffset - in tzparse()
1354 sp->ats[i] += stdoffset - in tzparse()
1358 theiroffset = -sp->ttis[j].tt_utoff; in tzparse()
1359 if (sp->ttis[j].tt_isdst) in tzparse()
1366 init_ttinfo(&sp->ttis[0], -stdoffset, false, 0); in tzparse()
1367 init_ttinfo(&sp->ttis[1], -dstoffset, true, stdlen + 1); in tzparse()
1368 sp->typecnt = 2; in tzparse()
1369 sp->defaulttype = 0; in tzparse()
1373 sp->typecnt = 1; /* only standard time */ in tzparse()
1374 sp->timecnt = 0; in tzparse()
1375 init_ttinfo(&sp->ttis[0], -stdoffset, false, 0); in tzparse()
1376 sp->defaulttype = 0; in tzparse()
1378 sp->charcnt = charcnt; in tzparse()
1379 cp = sp->chars; in tzparse()
1391 gmtload(struct state *const sp) in gmtload() argument
1393 if (tzload(etc_utc, sp, true) != 0) in gmtload()
1394 tzparse("UTC0", sp, NULL); in gmtload()
1400 zoneinit(struct state *sp, char const *name) in zoneinit() argument
1406 sp->leapcnt = 0; /* so, we're off a little */ in zoneinit()
1407 sp->timecnt = 0; in zoneinit()
1408 sp->typecnt = 0; in zoneinit()
1409 sp->charcnt = 0; in zoneinit()
1410 sp->goback = sp->goahead = false; in zoneinit()
1411 init_ttinfo(&sp->ttis[0], 0, false, 0); in zoneinit()
1412 strcpy(sp->chars, utc); in zoneinit()
1413 sp->defaulttype = 0; in zoneinit()
1416 int err = tzload(name, sp, true); in zoneinit()
1417 if (err != 0 && name && name[0] != ':' && tzparse(name, sp, NULL)) in zoneinit()
1420 err = scrub_abbrs(sp); in zoneinit()
1429 struct state *sp = lclptr; in tzset_unlocked() local
1436 if (! sp) in tzset_unlocked()
1437 lclptr = sp = malloc(sizeof *lclptr); in tzset_unlocked()
1439 if (sp) { in tzset_unlocked()
1440 if (zoneinit(sp, name) != 0) in tzset_unlocked()
1441 zoneinit(sp, ""); in tzset_unlocked()
1480 timezone_t sp = malloc(sizeof *sp); in tzalloc() local
1481 if (sp) { in tzalloc()
1482 int err = zoneinit(sp, name); in tzalloc()
1484 free(sp); in tzalloc()
1490 return sp; in tzalloc()
1494 tzfree(timezone_t sp) in tzfree() argument
1496 free(sp); in tzfree()
1527 localsub(struct state const *sp, time_t const *timep, int_fast32_t setname, in localsub() argument
1535 if (sp == NULL) { in localsub()
1539 if ((sp->goback && t < sp->ats[0]) || in localsub()
1540 (sp->goahead && t > sp->ats[sp->timecnt - 1])) { in localsub()
1545 if (t < sp->ats[0]) in localsub()
1546 seconds = sp->ats[0] - t; in localsub()
1547 else seconds = t - sp->ats[sp->timecnt - 1]; in localsub()
1555 if (t < sp->ats[0]) in localsub()
1560 if (newt < sp->ats[0] || in localsub()
1561 newt > sp->ats[sp->timecnt - 1]) in localsub()
1563 result = localsub(sp, &newt, setname, tmp); in localsub()
1566 if (t < sp->ats[0] in localsub()
1576 if (t < sp->ats[0]) in localsub()
1586 if (sp->timecnt == 0 || t < sp->ats[0]) { in localsub()
1587 i = sp->defaulttype; in localsub()
1590 register int hi = sp->timecnt; in localsub()
1595 if (t < sp->ats[mid]) in localsub()
1599 i = sp->types[lo - 1]; in localsub()
1601 ttisp = &sp->ttis[i]; in localsub()
1608 result = timesub(&t, ttisp->tt_utoff, sp, tmp); in localsub()
1612 result->TM_ZONE = (char *) &sp->chars[ttisp->tt_desigidx]; in localsub()
1615 update_tzname_etc(sp, ttisp); in localsub()
1623 localtime_rz(struct state *restrict sp, time_t const *restrict timep, in localtime_rz() argument
1626 return localsub(sp, timep, 0, tmp); in localtime_rz()
1666 gmtsub(ATTRIBUTE_MAYBE_UNUSED struct state const *sp, time_t const *timep, in gmtsub() argument
1740 const struct state *sp, struct tm *tmp) in timesub() argument
1756 i = (sp == NULL) ? 0 : sp->leapcnt; in timesub()
1758 lp = &sp->lsis[i]; in timesub()
1987 struct state const *sp, in time2sub() argument
2087 if (! funcp(sp, &t, offset, &mytm)) { in time2sub()
2133 if (funcp(sp, &altt, offset, &alttm) in time2sub()
2151 if (sp == NULL) in time2sub()
2153 for (i = sp->typecnt - 1; i >= 0; --i) { in time2sub()
2154 if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) in time2sub()
2156 for (j = sp->typecnt - 1; j >= 0; --j) { in time2sub()
2157 if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) in time2sub()
2159 if (ttunspecified(sp, j)) in time2sub()
2161 newt = (t + sp->ttis[j].tt_utoff in time2sub()
2162 - sp->ttis[i].tt_utoff); in time2sub()
2163 if (! funcp(sp, &newt, offset, &mytm)) in time2sub()
2183 if (funcp(sp, &t, offset, tmp)) in time2sub()
2192 struct state const *sp, in time2() argument
2203 t = time2sub(tmp, funcp, sp, offset, okayp, false); in time2()
2204 return *okayp ? t : time2sub(tmp, funcp, sp, offset, okayp, true); in time2()
2211 struct state const *sp, in time1() argument
2229 t = time2(tmp, funcp, sp, offset, &okay); in time1()
2247 if (sp == NULL) in time1()
2249 for (i = 0; i < sp->typecnt; ++i) in time1()
2252 for (i = sp->timecnt - 1; i >= 0; --i) in time1()
2253 if (!seen[sp->types[i]] && !ttunspecified(sp, sp->types[i])) { in time1()
2254 seen[sp->types[i]] = true; in time1()
2255 types[nseen++] = sp->types[i]; in time1()
2259 if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) in time1()
2263 if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) in time1()
2265 tmp->tm_sec += (sp->ttis[otheri].tt_utoff in time1()
2266 - sp->ttis[samei].tt_utoff); in time1()
2268 t = time2(tmp, funcp, sp, offset, &okay); in time1()
2271 tmp->tm_sec -= (sp->ttis[otheri].tt_utoff in time1()
2272 - sp->ttis[samei].tt_utoff); in time1()
2280 mktime_tzname(struct state *sp, struct tm *tmp, bool setname) in mktime_tzname() argument
2282 if (sp) in mktime_tzname()
2283 return time1(tmp, localsub, sp, setname); in mktime_tzname()
2293 mktime_z(struct state *restrict sp, struct tm *restrict tmp) in mktime_z() argument
2295 return mktime_tzname(sp, tmp, false); in mktime_z()
2349 leapcorr(struct state const *sp, time_t t) in leapcorr() argument
2354 i = sp->leapcnt; in leapcorr()
2356 lp = &sp->lsis[i]; in leapcorr()
2386 time2posix_z(struct state *sp, time_t t) in time2posix_z() argument
2388 return t - leapcorr(sp, t); in time2posix_z()
2408 posix2time_z(struct state *sp, time_t t) in posix2time_z() argument
2418 x = t + leapcorr(sp, t); in posix2time_z()
2419 y = x - leapcorr(sp, x); in posix2time_z()
2423 y = x - leapcorr(sp, x); in posix2time_z()
2429 y = x - leapcorr(sp, x); in posix2time_z()