Lines Matching refs:sp

225 ttunspecified(struct state const *sp, int i)
227 char const *abbr = &sp->chars[sp->ttis[i].tt_desigidx];
279 update_tzname_etc(struct state const *sp, struct ttinfo const *ttisp)
282 tzname[ttisp->tt_isdst] = (char *) &sp->chars[ttisp->tt_desigidx];
299 may_update_tzname_etc(int stddst_mask, struct state *sp, int type)
301 struct ttinfo *ttisp = &sp->ttis[type];
304 update_tzname_etc(sp, ttisp);
305 if (!ttunspecified(sp, type))
314 register struct state * const sp = lclptr;
323 tzname[0] = tzname[1] = (char *) (sp ? wildabbr : utc);
337 if (sp) {
338 for (i = sp->timecnt - 1; stddst_mask && 0 <= i; i--)
339 stddst_mask = may_update_tzname_etc(stddst_mask, sp, sp->types[i]);
340 for (i = sp->typecnt - 1; stddst_mask && 0 <= i; i--)
341 stddst_mask = may_update_tzname_etc(stddst_mask, sp, i);
352 scrub_abbrs(struct state *sp)
357 for (i = 0; i < sp->charcnt - (TZNAME_MAXIMUM + 1); ) {
358 int len = strlen(&sp->chars[i]);
365 for (i = 0; i < sp->charcnt; ++i)
366 if (strchr(TZ_ABBR_CHAR_SET, sp->chars[i]) == NULL)
367 sp->chars[i] = TZ_ABBR_ERR_CHAR;
410 tzloadbody(char const *name, struct state *sp, bool doextend,
421 sp->goback = sp->goahead = false;
515 sp->leapcnt = leapcnt;
516 sp->timecnt = timecnt;
517 sp->typecnt = typecnt;
518 sp->charcnt = charcnt;
524 for (i = 0; i < sp->timecnt; ++i) {
527 sp->types[i] = at <= TIME_T_MAX;
528 if (sp->types[i]) {
532 if (timecnt && attime <= sp->ats[timecnt - 1]) {
533 if (attime < sp->ats[timecnt - 1])
535 sp->types[i - 1] = 0;
538 sp->ats[timecnt++] = attime;
544 for (i = 0; i < sp->timecnt; ++i) {
546 if (sp->typecnt <= typ)
548 if (sp->types[i])
549 sp->types[timecnt++] = typ;
551 sp->timecnt = timecnt;
552 for (i = 0; i < sp->typecnt; ++i) {
556 ttisp = &sp->ttis[i];
564 if (! (desigidx < sp->charcnt))
568 for (i = 0; i < sp->charcnt; ++i)
569 sp->chars[i] = *p++;
572 memset(&sp->chars[i], 0, CHARS_EXTRA);
576 for (i = 0; i < sp->leapcnt; ++i) {
601 sp->lsis[leapcnt].ls_trans = tr;
602 sp->lsis[leapcnt].ls_corr = corr;
606 sp->leapcnt = leapcnt;
608 for (i = 0; i < sp->typecnt; ++i) {
611 ttisp = &sp->ttis[i];
620 for (i = 0; i < sp->typecnt; ++i) {
623 ttisp = &sp->ttis[i];
643 sp->typecnt + 2 <= TZ_MAX_TYPES) {
647 if (tzparse(&up->buf[1], ts, sp)) {
652 sp->charcnt equals 40 (for LMT AST AWT APT AHST
654 (for AKST AKDT). Reusing means sp->charcnt can
657 int charcnt = sp->charcnt;
662 if (strcmp(sp->chars + j, tsabbr) == 0) {
670 strcpy(sp->chars + j, tsabbr);
678 sp->charcnt = charcnt;
683 while (1 < sp->timecnt
684 && (sp->types[sp->timecnt - 1]
685 == sp->types[sp->timecnt - 2]))
686 sp->timecnt--;
688 sp->goahead = ts->goahead;
692 if (increment_overflow_time(&t, leapcorr(sp, t))
693 || (0 < sp->timecnt
694 && t <= sp->ats[sp->timecnt - 1]))
696 if (TZ_MAX_TIMES <= sp->timecnt) {
697 sp->goahead = false;
700 sp->ats[sp->timecnt] = t;
701 sp->types[sp->timecnt] = (sp->typecnt
703 sp->timecnt++;
706 sp->ttis[sp->typecnt++] = ts->ttis[i];
710 if (sp->typecnt == 0)
713 /* Infer sp->defaulttype from the data. Although this default
727 for (i = 0; i < sp->timecnt; ++i)
728 if (sp->types[i] == 0)
730 i = i < sp->timecnt && ! ttunspecified(sp, 0) ? -1 : 0;
738 if (i < 0 && sp->timecnt > 0 && sp->ttis[sp->types[0]].tt_isdst) {
739 i = sp->types[0];
741 if (!sp->ttis[i].tt_isdst)
753 while (sp->ttis[i].tt_isdst)
754 if (++i >= sp->typecnt) {
759 /* A simple 'sp->defaulttype = 0;' would suffice here if we
763 sp->defaulttype = i;
771 tzload(char const *name, struct state *sp, bool doextend)
778 int err = tzloadbody(name, sp, doextend, lsp);
784 return tzloadbody(name, sp, doextend, &ls);
1088 tzparse(const char *name, struct state *sp, struct state const *basep)
1122 sp->leapcnt = basep->leapcnt;
1123 memcpy(sp->lsis, basep->lsis, sp->leapcnt * sizeof *sp->lsis);
1125 load_ok = tzload(TZDEFRULES, sp, false) == 0;
1127 sp->leapcnt = 0; /* So, we're off a little. */
1129 if (0 < sp->leapcnt)
1130 leaplo = sp->lsis[sp->leapcnt - 1].ls_trans;
1131 sp->goback = sp->goahead = false;
1173 sp->typecnt = 2; /* standard time and DST */
1177 init_ttinfo(&sp->ttis[0], -stdoffset, false, 0);
1178 init_ttinfo(&sp->ttis[1], -dstoffset, true, stdlen + 1);
1228 sp->ats[timecnt] = janfirst;
1230 (&sp->ats[timecnt],
1232 && atlo <= sp->ats[timecnt])
1233 sp->types[timecnt++] = !reversed;
1234 sp->ats[timecnt] = janfirst;
1236 (&sp->ats[timecnt],
1238 && atlo <= sp->ats[timecnt]) {
1239 sp->types[timecnt++] = reversed;
1253 sp->timecnt = timecnt;
1255 sp->ttis[0] = sp->ttis[1];
1256 sp->typecnt = 1; /* Perpetual DST. */
1258 sp->goback = sp->goahead = true;
1273 for (i = 0; i < sp->timecnt; ++i) {
1274 j = sp->types[i];
1275 if (!sp->ttis[j].tt_isdst) {
1277 - sp->ttis[j].tt_utoff;
1282 for (i = 0; i < sp->timecnt; ++i) {
1283 j = sp->types[i];
1284 if (sp->ttis[j].tt_isdst) {
1286 - sp->ttis[j].tt_utoff;
1298 for (i = 0; i < sp->timecnt; ++i) {
1299 j = sp->types[i];
1300 sp->types[i] = sp->ttis[j].tt_isdst;
1301 if (sp->ttis[j].tt_ttisut) {
1319 if (isdst && !sp->ttis[j].tt_ttisstd) {
1320 sp->ats[i] += dstoffset -
1323 sp->ats[i] += stdoffset -
1327 theiroffset = -sp->ttis[j].tt_utoff;
1328 if (sp->ttis[j].tt_isdst)
1335 init_ttinfo(&sp->ttis[0], -stdoffset, false, 0);
1336 init_ttinfo(&sp->ttis[1], -dstoffset, true, stdlen + 1);
1337 sp->typecnt = 2;
1341 sp->typecnt = 1; /* only standard time */
1342 sp->timecnt = 0;
1343 init_ttinfo(&sp->ttis[0], -stdoffset, false, 0);
1345 sp->defaulttype = 0;
1346 sp->charcnt = charcnt;
1347 cp = sp->chars;
1359 gmtload(struct state *const sp)
1361 if (tzload(etc_utc, sp, true) != 0)
1362 tzparse("UTC0", sp, NULL);
1368 zoneinit(struct state *sp, char const *name)
1374 sp->leapcnt = 0; /* so, we're off a little */
1375 sp->timecnt = 0;
1376 sp->typecnt = 0;
1377 sp->charcnt = 0;
1378 sp->goback = sp->goahead = false;
1379 init_ttinfo(&sp->ttis[0], 0, false, 0);
1380 strcpy(sp->chars, utc);
1381 sp->defaulttype = 0;
1384 int err = tzload(name, sp, true);
1385 if (err != 0 && name && name[0] != ':' && tzparse(name, sp, NULL))
1388 err = scrub_abbrs(sp);
1397 struct state *sp = lclptr;
1404 if (! sp)
1405 lclptr = sp = malloc(sizeof *lclptr);
1407 if (sp) {
1408 if (zoneinit(sp, name) != 0)
1409 zoneinit(sp, "");
1448 timezone_t sp = malloc(sizeof *sp);
1449 if (sp) {
1450 int err = zoneinit(sp, name);
1452 free(sp);
1458 return sp;
1462 tzfree(timezone_t sp)
1464 free(sp);
1496 localsub(struct state const *sp, time_t const *timep, int_fast32_t setname,
1504 if (sp == NULL) {
1508 if ((sp->goback && t < sp->ats[0]) ||
1509 (sp->goahead && t > sp->ats[sp->timecnt - 1])) {
1514 if (t < sp->ats[0])
1515 seconds = sp->ats[0] - t;
1516 else seconds = t - sp->ats[sp->timecnt - 1];
1524 if (t < sp->ats[0])
1529 if (newt < sp->ats[0] ||
1530 newt > sp->ats[sp->timecnt - 1])
1532 result = localsub(sp, &newt, setname, tmp);
1535 if (t < sp->ats[0]
1545 if (t < sp->ats[0])
1555 if (sp->timecnt == 0 || t < sp->ats[0]) {
1556 i = sp->defaulttype;
1559 register int hi = sp->timecnt;
1564 if (t < sp->ats[mid])
1568 i = sp->types[lo - 1];
1570 ttisp = &sp->ttis[i];
1575 ** timesub(&t, 0L, sp, tmp);
1577 result = timesub(&t, ttisp->tt_utoff, sp, tmp);
1581 result->TM_ZONE = (char *) &sp->chars[ttisp->tt_desigidx];
1584 update_tzname_etc(sp, ttisp);
1592 localtime_rz(struct state *restrict sp, time_t const *restrict timep,
1595 return localsub(sp, timep, 0, tmp);
1635 gmtsub(ATTRIBUTE_MAYBE_UNUSED struct state const *sp, time_t const *timep,
1712 const struct state *sp, struct tm *tmp)
1728 i = (sp == NULL) ? 0 : sp->leapcnt;
1730 lp = &sp->lsis[i];
1959 struct state const *sp,
2059 if (! funcp(sp, &t, offset, &mytm)) {
2105 if (funcp(sp, &altt, offset, &alttm)
2123 if (sp == NULL)
2125 for (i = sp->typecnt - 1; i >= 0; --i) {
2126 if (sp->ttis[i].tt_isdst != yourtm.tm_isdst)
2128 for (j = sp->typecnt - 1; j >= 0; --j) {
2129 if (sp->ttis[j].tt_isdst == yourtm.tm_isdst)
2131 if (ttunspecified(sp, j))
2133 newt = (t + sp->ttis[j].tt_utoff
2134 - sp->ttis[i].tt_utoff);
2135 if (! funcp(sp, &newt, offset, &mytm))
2155 if (funcp(sp, &t, offset, tmp))
2164 struct state const *sp,
2175 t = time2sub(tmp, funcp, sp, offset, okayp, false);
2176 return *okayp ? t : time2sub(tmp, funcp, sp, offset, okayp, true);
2183 struct state const *sp,
2201 t = time2(tmp, funcp, sp, offset, &okay);
2219 if (sp == NULL)
2221 for (i = 0; i < sp->typecnt; ++i)
2224 for (i = sp->timecnt - 1; i >= 0; --i)
2225 if (!seen[sp->types[i]] && !ttunspecified(sp, sp->types[i])) {
2226 seen[sp->types[i]] = true;
2227 types[nseen++] = sp->types[i];
2231 if (sp->ttis[samei].tt_isdst != tmp->tm_isdst)
2235 if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst)
2237 tmp->tm_sec += (sp->ttis[otheri].tt_utoff
2238 - sp->ttis[samei].tt_utoff);
2240 t = time2(tmp, funcp, sp, offset, &okay);
2243 tmp->tm_sec -= (sp->ttis[otheri].tt_utoff
2244 - sp->ttis[samei].tt_utoff);
2252 mktime_tzname(struct state *sp, struct tm *tmp, bool setname)
2254 if (sp)
2255 return time1(tmp, localsub, sp, setname);
2265 mktime_z(struct state *restrict sp, struct tm *restrict tmp)
2267 return mktime_tzname(sp, tmp, false);
2331 leapcorr(struct state const *sp, time_t t)
2336 i = sp->leapcnt;
2338 lp = &sp->lsis[i];
2368 time2posix_z(struct state *sp, time_t t)
2370 return t - leapcorr(sp, t);
2390 posix2time_z(struct state *sp, time_t t)
2400 x = t + leapcorr(sp, t);
2401 y = x - leapcorr(sp, x);
2405 y = x - leapcorr(sp, x);
2411 y = x - leapcorr(sp, x);