mirror of
https://frontier.innolan.net/rainlance/amiga-tz.git
synced 2026-05-06 18:50:27 +00:00
Remove TZ_MAX_TIMES restriction in zic.c.
This lets zic handle the time rules of Troll station, Antarctica. Adapted from a fix by Zefram in: http://mm.icann.org/pipermail/tz/2014-March/020759.html * zic.c (timecnt_alloc): New static var. (attypes): Now a pointer to an array, not a fixed size array. (writezone, addtt): Don't assume the number of times is less than TZ_MAX_TIMES. * NEWS: Document this.
This commit is contained in:
6
NEWS
6
NEWS
@@ -10,8 +10,10 @@ Unreleased, experimental changes
|
||||
|
||||
Changes affecting 'zic'
|
||||
|
||||
'zic' now is smarter about allocating memory.
|
||||
(Thanks to Andrew Main (Zefram).)
|
||||
'zic' no longer rejects locations needing four transitions per
|
||||
year for the forseeable future, such as Troll station, Antarctica.
|
||||
(Thanks to Andrew Main (Zefram).) Also, it avoids some unlikely
|
||||
failures due to integer overflow.
|
||||
|
||||
Changes affecting commentary and documentation
|
||||
|
||||
|
||||
14
zic.c
14
zic.c
@@ -162,6 +162,7 @@ static const char * rfilename;
|
||||
static int rlinenum;
|
||||
static const char * progname;
|
||||
static int timecnt;
|
||||
static int timecnt_alloc;
|
||||
static int typecnt;
|
||||
|
||||
/*
|
||||
@@ -349,7 +350,7 @@ static const int len_years[2] = {
|
||||
static struct attype {
|
||||
zic_t at;
|
||||
unsigned char type;
|
||||
} attypes[TZ_MAX_TIMES];
|
||||
} * attypes;
|
||||
static zic_t gmtoffs[TZ_MAX_TYPES];
|
||||
static char isdsts[TZ_MAX_TYPES];
|
||||
static unsigned char abbrinds[TZ_MAX_TYPES];
|
||||
@@ -1461,8 +1462,9 @@ writezone(const char *const name, const char *const string, char version)
|
||||
static char * fullname;
|
||||
static const struct tzhead tzh0;
|
||||
static struct tzhead tzh;
|
||||
zic_t ats[TZ_MAX_TIMES];
|
||||
unsigned char types[TZ_MAX_TIMES];
|
||||
zic_t *ats = emalloc(size_product(timecnt, sizeof *ats + 1));
|
||||
void *typesptr = ats + timecnt;
|
||||
unsigned char *types = typesptr;
|
||||
|
||||
/*
|
||||
** Sort.
|
||||
@@ -1778,6 +1780,7 @@ writezone(const char *const name, const char *const string, char version)
|
||||
progname, fullname);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
free(ats);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2397,10 +2400,7 @@ addtt(const zic_t starttime, int type)
|
||||
timecnt = 0;
|
||||
type = 0;
|
||||
}
|
||||
if (timecnt >= TZ_MAX_TIMES) {
|
||||
error(_("too many transitions?!"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
attypes = growalloc(attypes, sizeof *attypes, timecnt, &timecnt_alloc);
|
||||
attypes[timecnt].at = starttime;
|
||||
attypes[timecnt].type = type;
|
||||
++timecnt;
|
||||
|
||||
Reference in New Issue
Block a user