mirror of
https://frontier.innolan.net/rainlance/amiga-tz.git
synced 2026-05-06 23:30:28 +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'
|
Changes affecting 'zic'
|
||||||
|
|
||||||
'zic' now is smarter about allocating memory.
|
'zic' no longer rejects locations needing four transitions per
|
||||||
(Thanks to Andrew Main (Zefram).)
|
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
|
Changes affecting commentary and documentation
|
||||||
|
|
||||||
|
|||||||
14
zic.c
14
zic.c
@@ -162,6 +162,7 @@ static const char * rfilename;
|
|||||||
static int rlinenum;
|
static int rlinenum;
|
||||||
static const char * progname;
|
static const char * progname;
|
||||||
static int timecnt;
|
static int timecnt;
|
||||||
|
static int timecnt_alloc;
|
||||||
static int typecnt;
|
static int typecnt;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -349,7 +350,7 @@ static const int len_years[2] = {
|
|||||||
static struct attype {
|
static struct attype {
|
||||||
zic_t at;
|
zic_t at;
|
||||||
unsigned char type;
|
unsigned char type;
|
||||||
} attypes[TZ_MAX_TIMES];
|
} * attypes;
|
||||||
static zic_t gmtoffs[TZ_MAX_TYPES];
|
static zic_t gmtoffs[TZ_MAX_TYPES];
|
||||||
static char isdsts[TZ_MAX_TYPES];
|
static char isdsts[TZ_MAX_TYPES];
|
||||||
static unsigned char abbrinds[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 char * fullname;
|
||||||
static const struct tzhead tzh0;
|
static const struct tzhead tzh0;
|
||||||
static struct tzhead tzh;
|
static struct tzhead tzh;
|
||||||
zic_t ats[TZ_MAX_TIMES];
|
zic_t *ats = emalloc(size_product(timecnt, sizeof *ats + 1));
|
||||||
unsigned char types[TZ_MAX_TIMES];
|
void *typesptr = ats + timecnt;
|
||||||
|
unsigned char *types = typesptr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Sort.
|
** Sort.
|
||||||
@@ -1778,6 +1780,7 @@ writezone(const char *const name, const char *const string, char version)
|
|||||||
progname, fullname);
|
progname, fullname);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
free(ats);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2397,10 +2400,7 @@ addtt(const zic_t starttime, int type)
|
|||||||
timecnt = 0;
|
timecnt = 0;
|
||||||
type = 0;
|
type = 0;
|
||||||
}
|
}
|
||||||
if (timecnt >= TZ_MAX_TIMES) {
|
attypes = growalloc(attypes, sizeof *attypes, timecnt, &timecnt_alloc);
|
||||||
error(_("too many transitions?!"));
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
attypes[timecnt].at = starttime;
|
attypes[timecnt].at = starttime;
|
||||||
attypes[timecnt].type = type;
|
attypes[timecnt].type = type;
|
||||||
++timecnt;
|
++timecnt;
|
||||||
|
|||||||
Reference in New Issue
Block a user