MCPcopy Create free account
hub / github.com/eggert/tz / zoneinit

Function zoneinit

localtime.c:1841–1865  ·  view source on GitHub ↗

Initialize *SP to a value appropriate for the TZ setting NAME. Respect TZLOADFLAGS. Return 0 on success, an errno value on failure. */

Source from the content-addressed store, hash-verified

1839 Respect TZLOADFLAGS.
1840 Return 0 on success, an errno value on failure. */
1841static int
1842zoneinit(struct state *sp, char const *name, char tzloadflags)
1843{
1844 if (name && ! name[0]) {
1845 /*
1846 ** User wants it fast rather than right.
1847 */
1848 set_leapcount(sp, 0); /* so, we're off a little */
1849 sp->timecnt = 0;
1850 sp->typecnt = 0;
1851 sp->charcnt = 0;
1852 sp->goback = sp->goahead = false;
1853 init_ttinfo(&sp->ttis[0], 0, false, 0);
1854 strcpy(sp->chars, utc);
1855 return 0;
1856 } else {
1857 int err = tzload(name, sp, tzloadflags);
1858 if (err != 0 && name && name[0] != ':' && !(tzloadflags & TZLOAD_TZDIR_SUB)
1859 && tzparse(name, sp, NULL))
1860 err = 0;
1861 if (err == 0)
1862 err = scrub_abbrs(sp);
1863 return err;
1864 }
1865}
1866
1867/* If THREADED, upgrade a read lock to a write lock.
1868 Return 0 on success, a positive errno value otherwise. */

Callers 2

tzset_unlockedFunction · 0.85
tzallocFunction · 0.85

Calls 5

set_leapcountFunction · 0.85
init_ttinfoFunction · 0.85
tzloadFunction · 0.85
tzparseFunction · 0.85
scrub_abbrsFunction · 0.85

Tested by

no test coverage detected