summaryrefslogtreecommitdiff
path: root/elsie.nci.nih.gov/src/localtime.c
diff options
context:
space:
mode:
authorMatt Nordhoff <mnordhoff@mattnordhoff.com>2007-12-03 23:21:08 -0500
committerMatt Nordhoff <mnordhoff@mattnordhoff.com>2007-12-03 23:21:08 -0500
commit732d79ac01a780014849a2cde4efa090797fe831 (patch)
treed534a6322130415aabdb6254c4c5bff7a85371fa /elsie.nci.nih.gov/src/localtime.c
parentef8cec71574ef6ad49f56dbac36678d0373e2c7a (diff)
downloadpytz-732d79ac01a780014849a2cde4efa090797fe831.tar.gz
Update to 2007j.
Diffstat (limited to 'elsie.nci.nih.gov/src/localtime.c')
-rw-r--r--elsie.nci.nih.gov/src/localtime.c148
1 files changed, 84 insertions, 64 deletions
diff --git a/elsie.nci.nih.gov/src/localtime.c b/elsie.nci.nih.gov/src/localtime.c
index 1fdfbdb..cfebf8b 100644
--- a/elsie.nci.nih.gov/src/localtime.c
+++ b/elsie.nci.nih.gov/src/localtime.c
@@ -5,7 +5,7 @@
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)localtime.c 8.5";
+static char elsieid[] = "@(#)localtime.c 8.8";
#endif /* !defined NOID */
#endif /* !defined lint */
@@ -136,51 +136,52 @@ struct rule {
** Prototypes for static functions.
*/
-static long detzcode P((const char * codep));
-static time_t detzcode64 P((const char * codep));
-static int differ_by_repeat P((time_t t1, time_t t0));
-static const char * getzname P((const char * strp));
-static const char * getqzname P((const char * strp, const int delim));
-static const char * getnum P((const char * strp, int * nump, int min,
- int max));
-static const char * getsecs P((const char * strp, long * secsp));
-static const char * getoffset P((const char * strp, long * offsetp));
-static const char * getrule P((const char * strp, struct rule * rulep));
-static void gmtload P((struct state * sp));
-static struct tm * gmtsub P((const time_t * timep, long offset,
- struct tm * tmp));
-static struct tm * localsub P((const time_t * timep, long offset,
- struct tm * tmp));
-static int increment_overflow P((int * number, int delta));
-static int leaps_thru_end_of P((int y));
-static int long_increment_overflow P((long * number, int delta));
-static int long_normalize_overflow P((long * tensptr,
- int * unitsptr, int base));
-static int normalize_overflow P((int * tensptr, int * unitsptr,
- int base));
-static void settzname P((void));
-static time_t time1 P((struct tm * tmp,
- struct tm * (*funcp) P((const time_t *,
- long, struct tm *)),
- long offset));
-static time_t time2 P((struct tm *tmp,
- struct tm * (*funcp) P((const time_t *,
- long, struct tm*)),
- long offset, int * okayp));
-static time_t time2sub P((struct tm *tmp,
- struct tm * (*funcp) P((const time_t *,
- long, struct tm*)),
- long offset, int * okayp, int do_norm_secs));
-static struct tm * timesub P((const time_t * timep, long offset,
- const struct state * sp, struct tm * tmp));
-static int tmcomp P((const struct tm * atmp,
- const struct tm * btmp));
-static time_t transtime P((time_t janfirst, int year,
- const struct rule * rulep, long offset));
-static int tzload P((const char * name, struct state * sp,
- int doextend));
-static int tzparse P((const char * name, struct state * sp,
- int lastditch));
+static long detzcode(const char * codep);
+static time_t detzcode64(const char * codep);
+static int differ_by_repeat(time_t t1, time_t t0);
+static const char * getzname(const char * strp);
+static const char * getqzname(const char * strp, const int delim);
+static const char * getnum(const char * strp, int * nump, int min,
+ int max);
+static const char * getsecs(const char * strp, long * secsp);
+static const char * getoffset(const char * strp, long * offsetp);
+static const char * getrule(const char * strp, struct rule * rulep);
+static void gmtload(struct state * sp);
+static struct tm * gmtsub(const time_t * timep, long offset,
+ struct tm * tmp);
+static struct tm * localsub(const time_t * timep, long offset,
+ struct tm * tmp);
+static int increment_overflow(int * number, int delta);
+static int leaps_thru_end_of(int y);
+static int long_increment_overflow(long * number, int delta);
+static int long_normalize_overflow(long * tensptr,
+ int * unitsptr, int base);
+static int normalize_overflow(int * tensptr, int * unitsptr,
+ int base);
+static void settzname(void);
+static time_t time1(struct tm * tmp,
+ struct tm * (*funcp)(const time_t *,
+ long, struct tm *),
+ long offset);
+static time_t time2(struct tm *tmp,
+ struct tm * (*funcp)(const time_t *,
+ long, struct tm*),
+ long offset, int * okayp);
+static time_t time2sub(struct tm *tmp,
+ struct tm * (*funcp)(const time_t *,
+ long, struct tm*),
+ long offset, int * okayp, int do_norm_secs);
+static struct tm * timesub(const time_t * timep, long offset,
+ const struct state * sp, struct tm * tmp);
+static int tmcomp(const struct tm * atmp,
+ const struct tm * btmp);
+static time_t transtime(time_t janfirst, int year,
+ const struct rule * rulep, long offset);
+static int typesequiv(const struct state * sp, int a, int b);
+static int tzload(const char * name, struct state * sp,
+ int doextend);
+static int tzparse(const char * name, struct state * sp,
+ int lastditch);
#ifdef ALL_STATE
static struct state * lclptr;
@@ -253,7 +254,7 @@ const char * const codep;
}
static void
-settzname P((void))
+settzname(void)
{
register struct state * const sp = lclptr;
register int i;
@@ -556,15 +557,42 @@ register const int doextend;
}
i = 2 * YEARSPERREPEAT;
sp->goback = sp->goahead = sp->timecnt > i;
- sp->goback = sp->goback && sp->types[i] == sp->types[0] &&
+ sp->goback = sp->goback &&
+ typesequiv(sp, sp->types[i], sp->types[0]) &&
differ_by_repeat(sp->ats[i], sp->ats[0]);
sp->goahead = sp->goahead &&
- sp->types[sp->timecnt - 1] == sp->types[sp->timecnt - 1 - i] &&
+ typesequiv(sp, sp->types[sp->timecnt - 1],
+ sp->types[sp->timecnt - 1 - i]) &&
differ_by_repeat(sp->ats[sp->timecnt - 1],
sp->ats[sp->timecnt - 1 - i]);
return 0;
}
+static int
+typesequiv(sp, a, b)
+const struct state * const sp;
+const int a;
+const int b;
+{
+ register int result;
+
+ if (sp == NULL ||
+ a < 0 || a >= sp->typecnt ||
+ b < 0 || b >= sp->typecnt)
+ result = FALSE;
+ else {
+ register const struct ttinfo * ap = &sp->ttis[a];
+ register const struct ttinfo * bp = &sp->ttis[b];
+ result = ap->tt_gmtoff == bp->tt_gmtoff &&
+ ap->tt_isdst == bp->tt_isdst &&
+ ap->tt_ttisstd == bp->tt_ttisstd &&
+ ap->tt_ttisgmt == bp->tt_ttisgmt &&
+ strcmp(&sp->chars[ap->tt_abbrind],
+ &sp->chars[bp->tt_abbrind]) == 0;
+ }
+ return result;
+}
+
static const int mon_lengths[2][MONSPERYEAR] = {
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
@@ -1120,7 +1148,7 @@ struct state * const sp;
static
#endif /* !defined STD_INSPIRED */
void
-tzsetwall P((void))
+tzsetwall(void)
{
if (lcl_is_set < 0)
return;
@@ -1141,7 +1169,7 @@ tzsetwall P((void))
}
void
-tzset P((void))
+tzset(void)
{
register const char * name;
@@ -1639,7 +1667,7 @@ register const struct tm * const btmp;
static time_t
time2sub(tmp, funcp, offset, okayp, do_norm_secs)
struct tm * const tmp;
-struct tm * (* const funcp) P((const time_t*, long, struct tm*));
+struct tm * (* const funcp)(const time_t*, long, struct tm*);
const long offset;
int * const okayp;
const int do_norm_secs;
@@ -1781,12 +1809,8 @@ const int do_norm_secs;
** It's okay to guess wrong since the guess
** gets checked.
*/
- /*
- ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's.
- */
sp = (const struct state *)
- (((void *) funcp == (void *) localsub) ?
- lclptr : gmtptr);
+ ((funcp == localsub) ? lclptr : gmtptr);
#ifdef ALL_STATE
if (sp == NULL)
return WRONG;
@@ -1827,7 +1851,7 @@ label:
static time_t
time2(tmp, funcp, offset, okayp)
struct tm * const tmp;
-struct tm * (* const funcp) P((const time_t*, long, struct tm*));
+struct tm * (* const funcp)(const time_t*, long, struct tm*);
const long offset;
int * const okayp;
{
@@ -1845,7 +1869,7 @@ int * const okayp;
static time_t
time1(tmp, funcp, offset)
struct tm * const tmp;
-struct tm * (* const funcp) P((const time_t *, long, struct tm *));
+struct tm * (* const funcp)(const time_t *, long, struct tm *);
const long offset;
{
register time_t t;
@@ -1880,11 +1904,7 @@ const long offset;
** We try to divine the type they started from and adjust to the
** type they need.
*/
- /*
- ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's.
- */
- sp = (const struct state *) (((void *) funcp == (void *) localsub) ?
- lclptr : gmtptr);
+ sp = (const struct state *) ((funcp == localsub) ? lclptr : gmtptr);
#ifdef ALL_STATE
if (sp == NULL)
return WRONG;