mirror of
https://frontier.innolan.net/rainlance/amiga-tz.git
synced 2025-12-06 15:52:06 +00:00
simplified writing of extra types
SCCS-file: zic.c SCCS-SID: 8.22
This commit is contained in:
committed by
Paul Eggert
parent
a2c7896ecf
commit
26fe8ae5cc
102
zic.c
102
zic.c
@ -1588,11 +1588,7 @@ const char * const string;
|
||||
char thischars[TZ_MAX_CHARS];
|
||||
char thischarcnt;
|
||||
int indmap[TZ_MAX_CHARS];
|
||||
register int mrudst, mrustd;
|
||||
register int savedtypecnt;
|
||||
|
||||
savedtypecnt = typecnt;
|
||||
mrudst = mrustd = -1;
|
||||
if (pass == 1) {
|
||||
thistimei = timei32;
|
||||
thistimecnt = timecnt32;
|
||||
@ -1617,18 +1613,60 @@ const char * const string;
|
||||
writetype[typecnt - 1] = TRUE;
|
||||
} else {
|
||||
for (i = thistimei - 1; i < thistimelim; ++i)
|
||||
if (i >= 0) {
|
||||
if (i >= 0)
|
||||
writetype[types[i]] = TRUE;
|
||||
if (isdsts[types[i]])
|
||||
mrudst = types[i];
|
||||
else mrustd = types[i];
|
||||
}
|
||||
/*
|
||||
** For America/Godthab and Antarctica/Palmer
|
||||
*/
|
||||
if (thistimei == 0)
|
||||
writetype[0] = TRUE;
|
||||
}
|
||||
#ifndef LEAVE_SOME_PRE_2011_SYSTEMS_IN_THE_LURCH
|
||||
/*
|
||||
** For some pre-2011 systems: if the last-to-be-written
|
||||
** standard (or daylight) type has an offset different from the
|
||||
** most recently used offset,
|
||||
** append an (unused) copy of the most recently used type
|
||||
** (to help get global "altzone" and "timezone" variables
|
||||
** set correctly).
|
||||
*/
|
||||
{
|
||||
register int mrudst, mrustd, hidst, histd, type;
|
||||
|
||||
hidst = histd = mrudst = mrustd = -1;
|
||||
for (i = thistimei; i < thistimelim; ++i)
|
||||
if (isdsts[types[i]])
|
||||
mrudst = types[i];
|
||||
else mrustd = types[i];
|
||||
for (i = 0; i < typecnt; ++i)
|
||||
if (writetype[i])
|
||||
if (isdsts[i])
|
||||
hidst = i;
|
||||
else histd = i;
|
||||
if (hidst >= 0 && mrudst >= 0 && hidst != mrudst &&
|
||||
gmtoffs[hidst] != gmtoffs[mrudst]) {
|
||||
isdsts[mrudst] = -1;
|
||||
type = addtype(gmtoffs[mrudst],
|
||||
&chars[abbrinds[mrudst]],
|
||||
TRUE,
|
||||
ttisstds[mrudst],
|
||||
ttisgmts[mrudst]);
|
||||
isdsts[mrudst] = TRUE;
|
||||
writetype[type] = TRUE;
|
||||
}
|
||||
if (histd >= 0 && mrustd >= 0 && histd != mrustd &&
|
||||
gmtoffs[histd] != gmtoffs[mrustd]) {
|
||||
isdsts[mrustd] = -1;
|
||||
type = addtype(gmtoffs[mrustd],
|
||||
&chars[abbrinds[mrustd]],
|
||||
FALSE,
|
||||
ttisstds[mrustd],
|
||||
ttisgmts[mrustd]);
|
||||
isdsts[mrustd] = FALSE;
|
||||
writetype[type] = TRUE;
|
||||
}
|
||||
}
|
||||
#endif /* !defined LEAVE_SOME_PRE_2011_SYSTEMS_IN_THE_LURCH */
|
||||
thistypecnt = 0;
|
||||
for (i = 0; i < typecnt; ++i)
|
||||
typemap[i] = writetype[i] ? thistypecnt++ : -1;
|
||||
@ -1653,51 +1691,6 @@ const char * const string;
|
||||
}
|
||||
indmap[abbrinds[i]] = j;
|
||||
}
|
||||
/*
|
||||
** For pre-2011 systems: if the last-to-be-written standard
|
||||
** (or daylight) type has a different offset from the
|
||||
** most recently used offset,
|
||||
** append an (unused) copy of the most recently used type
|
||||
** (to help get global "altzone" and "timezone" variables
|
||||
** set correctly).
|
||||
*/
|
||||
{
|
||||
register int hidst, histd;
|
||||
|
||||
hidst = histd = -1;
|
||||
|
||||
for (i = 0; i < typecnt; ++i)
|
||||
if (writetype[i])
|
||||
if (isdsts[i])
|
||||
hidst = i;
|
||||
else histd = i;
|
||||
if (histd >= 0 && mrustd >= 0 && histd != mrustd &&
|
||||
gmtoffs[histd] != gmtoffs[mrustd] &&
|
||||
typecnt < TZ_MAX_TYPES) {
|
||||
gmtoffs[typecnt] = gmtoffs[mrustd];
|
||||
isdsts[typecnt] = isdsts[mrustd];
|
||||
abbrinds[typecnt] = abbrinds[mrustd];
|
||||
ttisstds[typecnt] = ttisstds[mrustd];
|
||||
ttisgmts[typecnt] = ttisgmts[mrustd];
|
||||
writetype[typecnt] = 1;
|
||||
typemap[typecnt] = thistypecnt;
|
||||
++typecnt;
|
||||
++thistypecnt;
|
||||
}
|
||||
if (hidst >= 0 && mrudst >= 0 && hidst != mrudst &&
|
||||
gmtoffs[hidst] != gmtoffs[mrudst] &&
|
||||
typecnt < TZ_MAX_TYPES) {
|
||||
gmtoffs[typecnt] = gmtoffs[mrudst];
|
||||
isdsts[typecnt] = isdsts[mrudst];
|
||||
abbrinds[typecnt] = abbrinds[mrudst];
|
||||
ttisstds[typecnt] = ttisstds[mrustd];
|
||||
ttisgmts[typecnt] = ttisgmts[mrudst];
|
||||
writetype[typecnt] = 1;
|
||||
typemap[typecnt] = thistypecnt;
|
||||
++typecnt;
|
||||
++thistypecnt;
|
||||
}
|
||||
}
|
||||
#define DO(field) (void) fwrite((void *) tzh.field, \
|
||||
(size_t) sizeof tzh.field, (size_t) 1, fp)
|
||||
tzh = tzh0;
|
||||
@ -1773,7 +1766,6 @@ const char * const string;
|
||||
for (i = 0; i < typecnt; ++i)
|
||||
if (writetype[i])
|
||||
(void) putc(ttisgmts[i], fp);
|
||||
typecnt = savedtypecnt;
|
||||
}
|
||||
(void) fprintf(fp, "\n%s\n", string);
|
||||
if (ferror(fp) || fclose(fp)) {
|
||||
|
||||
Reference in New Issue
Block a user