136
136
** Prototypes for static functions.
139
static long detzcode P((const char * codep));
140
static time_t detzcode64 P((const char * codep));
141
static int differ_by_repeat P((time_t t1, time_t t0));
142
static const char * getzname P((const char * strp));
143
static const char * getqzname P((const char * strp, const int delim));
144
static const char * getnum P((const char * strp, int * nump, int min,
146
static const char * getsecs P((const char * strp, long * secsp));
147
static const char * getoffset P((const char * strp, long * offsetp));
148
static const char * getrule P((const char * strp, struct rule * rulep));
149
static void gmtload P((struct state * sp));
150
static struct tm * gmtsub P((const time_t * timep, long offset,
152
static struct tm * localsub P((const time_t * timep, long offset,
154
static int increment_overflow P((int * number, int delta));
155
static int leaps_thru_end_of P((int y));
156
static int long_increment_overflow P((long * number, int delta));
157
static int long_normalize_overflow P((long * tensptr,
158
int * unitsptr, int base));
159
static int normalize_overflow P((int * tensptr, int * unitsptr,
161
static void settzname P((void));
162
static time_t time1 P((struct tm * tmp,
163
struct tm * (*funcp) P((const time_t *,
166
static time_t time2 P((struct tm *tmp,
167
struct tm * (*funcp) P((const time_t *,
169
long offset, int * okayp));
170
static time_t time2sub P((struct tm *tmp,
171
struct tm * (*funcp) P((const time_t *,
173
long offset, int * okayp, int do_norm_secs));
174
static struct tm * timesub P((const time_t * timep, long offset,
175
const struct state * sp, struct tm * tmp));
176
static int tmcomp P((const struct tm * atmp,
177
const struct tm * btmp));
178
static time_t transtime P((time_t janfirst, int year,
179
const struct rule * rulep, long offset));
180
static int tzload P((const char * name, struct state * sp,
182
static int tzparse P((const char * name, struct state * sp,
139
static long detzcode(const char * codep);
140
static time_t detzcode64(const char * codep);
141
static int differ_by_repeat(time_t t1, time_t t0);
142
static const char * getzname(const char * strp);
143
static const char * getqzname(const char * strp, const int delim);
144
static const char * getnum(const char * strp, int * nump, int min,
146
static const char * getsecs(const char * strp, long * secsp);
147
static const char * getoffset(const char * strp, long * offsetp);
148
static const char * getrule(const char * strp, struct rule * rulep);
149
static void gmtload(struct state * sp);
150
static struct tm * gmtsub(const time_t * timep, long offset,
152
static struct tm * localsub(const time_t * timep, long offset,
154
static int increment_overflow(int * number, int delta);
155
static int leaps_thru_end_of(int y);
156
static int long_increment_overflow(long * number, int delta);
157
static int long_normalize_overflow(long * tensptr,
158
int * unitsptr, int base);
159
static int normalize_overflow(int * tensptr, int * unitsptr,
161
static void settzname(void);
162
static time_t time1(struct tm * tmp,
163
struct tm * (*funcp)(const time_t *,
166
static time_t time2(struct tm *tmp,
167
struct tm * (*funcp)(const time_t *,
169
long offset, int * okayp);
170
static time_t time2sub(struct tm *tmp,
171
struct tm * (*funcp)(const time_t *,
173
long offset, int * okayp, int do_norm_secs);
174
static struct tm * timesub(const time_t * timep, long offset,
175
const struct state * sp, struct tm * tmp);
176
static int tmcomp(const struct tm * atmp,
177
const struct tm * btmp);
178
static time_t transtime(time_t janfirst, int year,
179
const struct rule * rulep, long offset);
180
static int typesequiv(const struct state * sp, int a, int b);
181
static int tzload(const char * name, struct state * sp,
183
static int tzparse(const char * name, struct state * sp,
186
187
static struct state * lclptr;
557
558
i = 2 * YEARSPERREPEAT;
558
559
sp->goback = sp->goahead = sp->timecnt > i;
559
sp->goback = sp->goback && sp->types[i] == sp->types[0] &&
560
sp->goback = sp->goback &&
561
typesequiv(sp, sp->types[i], sp->types[0]) &&
560
562
differ_by_repeat(sp->ats[i], sp->ats[0]);
561
563
sp->goahead = sp->goahead &&
562
sp->types[sp->timecnt - 1] == sp->types[sp->timecnt - 1 - i] &&
564
typesequiv(sp, sp->types[sp->timecnt - 1],
565
sp->types[sp->timecnt - 1 - i]) &&
563
566
differ_by_repeat(sp->ats[sp->timecnt - 1],
564
567
sp->ats[sp->timecnt - 1 - i]);
573
const struct state * const sp;
580
a < 0 || a >= sp->typecnt ||
581
b < 0 || b >= sp->typecnt)
584
register const struct ttinfo * ap = &sp->ttis[a];
585
register const struct ttinfo * bp = &sp->ttis[b];
586
result = ap->tt_gmtoff == bp->tt_gmtoff &&
587
ap->tt_isdst == bp->tt_isdst &&
588
ap->tt_ttisstd == bp->tt_ttisstd &&
589
ap->tt_ttisgmt == bp->tt_ttisgmt &&
590
strcmp(&sp->chars[ap->tt_abbrind],
591
&sp->chars[bp->tt_abbrind]) == 0;
568
596
static const int mon_lengths[2][MONSPERYEAR] = {
569
597
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
570
598
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }