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

Function addtype

zic.c:3779–3826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3777 }
3778 }
3779 writezone(zpfirst->z_name, envvar, version, defaulttype);
3780 free(startbuf);
3781 free(ab);
3782 free(envvar);
3783}
3784
3785static void
3786addtt(zic_t starttime, int type)
3787{
3788 attypes = growalloc(attypes, sizeof *attypes, timecnt, &timecnt_alloc);
3789 attypes[timecnt].at = starttime;
3790 attypes[timecnt].dontmerge = false;
3791 attypes[timecnt].type = type;
3792 ++timecnt;
3793}
3794
3795static int
3796addtype(zic_t utoff, char const *abbr, bool isdst, bool ttisstd, bool ttisut)
3797{
3798 register int i, j;
3799 int charcnt0;
3800
3801 /* RFC 9636 section 3.2 specifies this range for utoff. */
3802 if (! (-TWO_31_MINUS_1 <= utoff && utoff <= TWO_31_MINUS_1)) {
3803 error(N_("UT offset out of range"));
3804 exit(EXIT_FAILURE);
3805 }
3806 if (!want_bloat())
3807 ttisstd = ttisut = false;
3808
3809 checkabbr(abbr);
3810
3811 charcnt0 = charcnt;
3812 j = addabbr(chars, &charcnt, abbr);
3813 if (charcnt0 < charcnt) {
3814 /* If an abbreviation was inserted, increment indexes no
3815 earlier than the insert by the size of the insertion,
3816 so that they continue to point to the same contents. */
3817 for (i = 0; i < typecnt; i++)
3818 if (j <= desigidx[i])
3819 desigidx[i] += charcnt - charcnt0;
3820 } else {
3821 /* If there's already an entry, return its index. */
3822 for (i = 0; i < typecnt; i++)
3823 if (utoff == utoffs[i] && isdst == isdsts[i] && j == desigidx[i]
3824 && ttisstd == ttisstds[i] && ttisut == ttisuts[i])
3825 return i;
3826 }
3827 /*
3828 ** There isn't one; add a new one, unless there are already too
3829 ** many.

Callers 2

writezoneFunction · 0.85
outzoneFunction · 0.85

Calls 4

errorFunction · 0.85
want_bloatFunction · 0.85
checkabbrFunction · 0.85
addabbrFunction · 0.85

Tested by

no test coverage detected