mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
pgindent did a pretty awful job on the timezone code, particularly with
respect to doubly-starred comment blocks. Do some manual cleanup.
This commit is contained in:
parent
13f96c4b6b
commit
d584db6086
@ -1,3 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* This file is in the public domain, so clarified as of
|
||||||
|
* 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
|
||||||
|
*
|
||||||
|
* IDENTIFICATION
|
||||||
|
* $PostgreSQL: pgsql/src/timezone/ialloc.c,v 1.5 2004/05/21 20:59:10 tgl Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
** This file is in the public domain, so clarified as of
|
* This file is in the public domain, so clarified as of
|
||||||
** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
|
* 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
|
||||||
*/
|
*
|
||||||
|
* IDENTIFICATION
|
||||||
|
* $PostgreSQL: pgsql/src/timezone/localtime.c,v 1.6 2004/05/21 20:59:10 tgl Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu).
|
* Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu).
|
||||||
** POSIX-style TZ environment variable handling from Guy Harris
|
* POSIX-style TZ environment variable handling from Guy Harris
|
||||||
** (guy@auspex.com).
|
* (guy@auspex.com).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
@ -19,25 +22,26 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef WILDABBR
|
#ifndef WILDABBR
|
||||||
/*
|
/*----------
|
||||||
** Someone might make incorrect use of a time zone abbreviation:
|
* Someone might make incorrect use of a time zone abbreviation:
|
||||||
** 1. They might reference tzname[0] before calling tzset (explicitly
|
* 1. They might reference tzname[0] before calling tzset (explicitly
|
||||||
** or implicitly).
|
* or implicitly).
|
||||||
** 2. They might reference tzname[1] before calling tzset (explicitly
|
* 2. They might reference tzname[1] before calling tzset (explicitly
|
||||||
** or implicitly).
|
* or implicitly).
|
||||||
** 3. They might reference tzname[1] after setting to a time zone
|
* 3. They might reference tzname[1] after setting to a time zone
|
||||||
** in which Daylight Saving Time is never observed.
|
* in which Daylight Saving Time is never observed.
|
||||||
** 4. They might reference tzname[0] after setting to a time zone
|
* 4. They might reference tzname[0] after setting to a time zone
|
||||||
** in which Standard Time is never observed.
|
* in which Standard Time is never observed.
|
||||||
** 5. They might reference tm.TM_ZONE after calling offtime.
|
* 5. They might reference tm.TM_ZONE after calling offtime.
|
||||||
** What's best to do in the above cases is open to debate;
|
* What's best to do in the above cases is open to debate;
|
||||||
** for now, we just set things up so that in any of the five cases
|
* for now, we just set things up so that in any of the five cases
|
||||||
** WILDABBR is used. Another possibility: initialize tzname[0] to the
|
* WILDABBR is used. Another possibility: initialize tzname[0] to the
|
||||||
** string "tzname[0] used before set", and similarly for the other cases.
|
* string "tzname[0] used before set", and similarly for the other cases.
|
||||||
** And another: initialize tzname[0] to "ERA", with an explanation in the
|
* And another: initialize tzname[0] to "ERA", with an explanation in the
|
||||||
** manual page of what this "time zone abbreviation" means (doing this so
|
* manual page of what this "time zone abbreviation" means (doing this so
|
||||||
** that tzname[0] has the "normal" length of three characters).
|
* that tzname[0] has the "normal" length of three characters).
|
||||||
*/
|
*----------
|
||||||
|
*/
|
||||||
#define WILDABBR " "
|
#define WILDABBR " "
|
||||||
#endif /* !defined WILDABBR */
|
#endif /* !defined WILDABBR */
|
||||||
|
|
||||||
@ -46,12 +50,12 @@ static char wildabbr[] = "WILDABBR";
|
|||||||
static const char gmt[] = "GMT";
|
static const char gmt[] = "GMT";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The DST rules to use if TZ has no rules and we can't load TZDEFRULES.
|
* The DST rules to use if TZ has no rules and we can't load TZDEFRULES.
|
||||||
** We default to US rules as of 1999-08-17.
|
* We default to US rules as of 1999-08-17.
|
||||||
** POSIX 1003.1 section 8.1.1 says that the default DST rules are
|
* POSIX 1003.1 section 8.1.1 says that the default DST rules are
|
||||||
** implementation dependent; for historical reasons, US rules are a
|
* implementation dependent; for historical reasons, US rules are a
|
||||||
** common default.
|
* common default.
|
||||||
*/
|
*/
|
||||||
#define TZDEFRULESTRING ",M4.1.0,M10.5.0"
|
#define TZDEFRULESTRING ",M4.1.0,M10.5.0"
|
||||||
|
|
||||||
struct ttinfo
|
struct ttinfo
|
||||||
@ -100,8 +104,8 @@ struct rule
|
|||||||
* week */
|
* week */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Prototypes for static functions.
|
* Prototypes for static functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static long detzcode(const char *codep);
|
static long detzcode(const char *codep);
|
||||||
static const char *getzname(const char *strp);
|
static const char *getzname(const char *strp);
|
||||||
@ -114,12 +118,20 @@ static void gmtsub(const time_t *timep, long offset, struct pg_tm * tmp);
|
|||||||
static void localsub(const time_t *timep, long offset, struct pg_tm * tmp);
|
static void localsub(const time_t *timep, long offset, struct pg_tm * tmp);
|
||||||
static int increment_overflow(int *number, int delta);
|
static int increment_overflow(int *number, int delta);
|
||||||
static int normalize_overflow(int *tensptr, int *unitsptr, int base);
|
static int normalize_overflow(int *tensptr, int *unitsptr, int base);
|
||||||
static time_t time1(struct pg_tm * tmp, void (*funcp) (const time_t *, long, struct pg_tm *), long offset);
|
static time_t time1(struct pg_tm * tmp,
|
||||||
static time_t time2(struct pg_tm * tmp, void (*funcp) (const time_t *, long, struct pg_tm *), long offset, int *okayp);
|
void (*funcp) (const time_t *, long, struct pg_tm *),
|
||||||
static time_t time2sub(struct pg_tm * tmp, void (*funcp) (const time_t *, long, struct pg_tm *), long offset, int *okayp, int do_norm_secs);
|
long offset);
|
||||||
static void timesub(const time_t *timep, long offset, const struct state * sp, struct pg_tm * tmp);
|
static time_t time2(struct pg_tm * tmp,
|
||||||
|
void (*funcp) (const time_t *, long, struct pg_tm *),
|
||||||
|
long offset, int *okayp);
|
||||||
|
static time_t time2sub(struct pg_tm * tmp,
|
||||||
|
void (*funcp) (const time_t *, long, struct pg_tm *),
|
||||||
|
long offset, int *okayp, int do_norm_secs);
|
||||||
|
static void timesub(const time_t *timep, long offset,
|
||||||
|
const struct state * sp, struct pg_tm * tmp);
|
||||||
static int tmcomp(const struct pg_tm * atmp, const struct pg_tm * btmp);
|
static int tmcomp(const struct pg_tm * atmp, const struct pg_tm * btmp);
|
||||||
static time_t transtime(time_t janfirst, int year, const struct rule * rulep, long offset);
|
static time_t transtime(time_t janfirst, int year,
|
||||||
|
const struct rule * rulep, long offset);
|
||||||
static int tzload(const char *name, struct state * sp);
|
static int tzload(const char *name, struct state * sp);
|
||||||
static int tzparse(const char *name, struct state * sp, int lastditch);
|
static int tzparse(const char *name, struct state * sp, int lastditch);
|
||||||
|
|
||||||
@ -134,12 +146,12 @@ static int lcl_is_set = 0;
|
|||||||
static int gmt_is_set = 0;
|
static int gmt_is_set = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Section 4.12.3 of X3.159-1989 requires that
|
* Section 4.12.3 of X3.159-1989 requires that
|
||||||
** Except for the strftime function, these functions [asctime,
|
* Except for the strftime function, these functions [asctime,
|
||||||
** ctime, gmtime, localtime] return values in one of two static
|
* ctime, gmtime, localtime] return values in one of two static
|
||||||
** objects: a broken-down time structure and an array of char.
|
* objects: a broken-down time structure and an array of char.
|
||||||
** Thanks to Paul Eggert (eggert@twinsun.com) for noting this.
|
* Thanks to Paul Eggert (eggert@twinsun.com) for noting this.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static struct pg_tm tm;
|
static struct pg_tm tm;
|
||||||
|
|
||||||
@ -184,7 +196,7 @@ tzload(register const char *name, register struct state * sp)
|
|||||||
(void) strcat(fullname, name);
|
(void) strcat(fullname, name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Set doaccess if '.' (as in "../") shows up in name.
|
* Set doaccess if '.' (as in "../") shows up in name.
|
||||||
*/
|
*/
|
||||||
if (strchr(name, '.') != NULL)
|
if (strchr(name, '.') != NULL)
|
||||||
doaccess = TRUE;
|
doaccess = TRUE;
|
||||||
@ -313,11 +325,10 @@ static const int year_lengths[2] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Given a pointer into a time zone string, scan until a character that is not
|
* Given a pointer into a time zone string, scan until a character that is not
|
||||||
** a valid character in a zone name is found. Return a pointer to that
|
* a valid character in a zone name is found. Return a pointer to that
|
||||||
** character.
|
* character.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
getzname(register const char *strp)
|
getzname(register const char *strp)
|
||||||
{
|
{
|
||||||
@ -330,12 +341,11 @@ getzname(register const char *strp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Given a pointer into a time zone string, extract a number from that string.
|
* Given a pointer into a time zone string, extract a number from that string.
|
||||||
** Check that the number is within a specified range; if it is not, return
|
* Check that the number is within a specified range; if it is not, return
|
||||||
** NULL.
|
* NULL.
|
||||||
** Otherwise, return a pointer to the first character not part of the number.
|
* Otherwise, return a pointer to the first character not part of the number.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
getnum(register const char *strp, int *nump, const int min, const int max)
|
getnum(register const char *strp, int *nump, const int min, const int max)
|
||||||
{
|
{
|
||||||
@ -359,22 +369,21 @@ getnum(register const char *strp, int *nump, const int min, const int max)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Given a pointer into a time zone string, extract a number of seconds,
|
* Given a pointer into a time zone string, extract a number of seconds,
|
||||||
** in hh[:mm[:ss]] form, from the string.
|
* in hh[:mm[:ss]] form, from the string.
|
||||||
** If any error occurs, return NULL.
|
* If any error occurs, return NULL.
|
||||||
** Otherwise, return a pointer to the first character not part of the number
|
* Otherwise, return a pointer to the first character not part of the number
|
||||||
** of seconds.
|
* of seconds.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
getsecs(register const char *strp, long *secsp)
|
getsecs(register const char *strp, long *secsp)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * `HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like *
|
* `HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like
|
||||||
* "M10.4.6/26", which does not conform to Posix, * but which
|
* "M10.4.6/26", which does not conform to Posix, but which
|
||||||
* specifies the equivalent of * ``02:00 on the first Sunday on or
|
* specifies the equivalent of ``02:00 on the first Sunday on or
|
||||||
* after 23 Oct''.
|
* after 23 Oct''.
|
||||||
*/
|
*/
|
||||||
strp = getnum(strp, &num, 0, HOURSPERDAY * DAYSPERWEEK - 1);
|
strp = getnum(strp, &num, 0, HOURSPERDAY * DAYSPERWEEK - 1);
|
||||||
@ -402,12 +411,11 @@ getsecs(register const char *strp, long *secsp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Given a pointer into a time zone string, extract an offset, in
|
* Given a pointer into a time zone string, extract an offset, in
|
||||||
** [+-]hh[:mm[:ss]] form, from the string.
|
* [+-]hh[:mm[:ss]] form, from the string.
|
||||||
** If any error occurs, return NULL.
|
* If any error occurs, return NULL.
|
||||||
** Otherwise, return a pointer to the first character not part of the time.
|
* Otherwise, return a pointer to the first character not part of the time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
getoffset(register const char *strp, long *offsetp)
|
getoffset(register const char *strp, long *offsetp)
|
||||||
{
|
{
|
||||||
@ -429,19 +437,18 @@ getoffset(register const char *strp, long *offsetp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Given a pointer into a time zone string, extract a rule in the form
|
* Given a pointer into a time zone string, extract a rule in the form
|
||||||
** date[/time]. See POSIX section 8 for the format of "date" and "time".
|
* date[/time]. See POSIX section 8 for the format of "date" and "time".
|
||||||
** If a valid rule is not found, return NULL.
|
* If a valid rule is not found, return NULL.
|
||||||
** Otherwise, return a pointer to the first character not part of the rule.
|
* Otherwise, return a pointer to the first character not part of the rule.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
getrule(const char *strp, register struct rule * rulep)
|
getrule(const char *strp, register struct rule * rulep)
|
||||||
{
|
{
|
||||||
if (*strp == 'J')
|
if (*strp == 'J')
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* * Julian day.
|
* Julian day.
|
||||||
*/
|
*/
|
||||||
rulep->r_type = JULIAN_DAY;
|
rulep->r_type = JULIAN_DAY;
|
||||||
++strp;
|
++strp;
|
||||||
@ -450,7 +457,7 @@ getrule(const char *strp, register struct rule * rulep)
|
|||||||
else if (*strp == 'M')
|
else if (*strp == 'M')
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* * Month, week, day.
|
* Month, week, day.
|
||||||
*/
|
*/
|
||||||
rulep->r_type = MONTH_NTH_DAY_OF_WEEK;
|
rulep->r_type = MONTH_NTH_DAY_OF_WEEK;
|
||||||
++strp;
|
++strp;
|
||||||
@ -469,7 +476,7 @@ getrule(const char *strp, register struct rule * rulep)
|
|||||||
else if (is_digit(*strp))
|
else if (is_digit(*strp))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* * Day of year.
|
* Day of year.
|
||||||
*/
|
*/
|
||||||
rulep->r_type = DAY_OF_YEAR;
|
rulep->r_type = DAY_OF_YEAR;
|
||||||
strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1);
|
strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1);
|
||||||
@ -481,7 +488,7 @@ getrule(const char *strp, register struct rule * rulep)
|
|||||||
if (*strp == '/')
|
if (*strp == '/')
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* * Time specified.
|
* Time specified.
|
||||||
*/
|
*/
|
||||||
++strp;
|
++strp;
|
||||||
strp = getsecs(strp, &rulep->r_time);
|
strp = getsecs(strp, &rulep->r_time);
|
||||||
@ -492,13 +499,13 @@ getrule(const char *strp, register struct rule * rulep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Given the Epoch-relative time of January 1, 00:00:00 UTC, in a year, the
|
* Given the Epoch-relative time of January 1, 00:00:00 UTC, in a year, the
|
||||||
** year, a rule, and the offset from UTC at the time that rule takes effect,
|
* year, a rule, and the offset from UTC at the time that rule takes effect,
|
||||||
** calculate the Epoch-relative time that rule takes effect.
|
* calculate the Epoch-relative time that rule takes effect.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static time_t
|
static time_t
|
||||||
transtime(const time_t janfirst, const int year, register const struct rule * rulep, const long offset)
|
transtime(const time_t janfirst, const int year,
|
||||||
|
register const struct rule * rulep, const long offset)
|
||||||
{
|
{
|
||||||
register int leapyear;
|
register int leapyear;
|
||||||
register time_t value = 0;
|
register time_t value = 0;
|
||||||
@ -517,10 +524,10 @@ transtime(const time_t janfirst, const int year, register const struct rule * ru
|
|||||||
case JULIAN_DAY:
|
case JULIAN_DAY:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Jn - Julian day, 1 == January 1, 60 == March 1 even in
|
* Jn - Julian day, 1 == January 1, 60 == March 1 even in
|
||||||
* leap * years. * In non-leap years, or if the day number is
|
* leap years. In non-leap years, or if the day number is
|
||||||
* 59 or less, just * add SECSPERDAY times the day number-1 to
|
* 59 or less, just add SECSPERDAY times the day number-1 to
|
||||||
* the time of * January 1, midnight, to get the day.
|
* the time of January 1, midnight, to get the day.
|
||||||
*/
|
*/
|
||||||
value = janfirst + (rulep->r_day - 1) * SECSPERDAY;
|
value = janfirst + (rulep->r_day - 1) * SECSPERDAY;
|
||||||
if (leapyear && rulep->r_day >= 60)
|
if (leapyear && rulep->r_day >= 60)
|
||||||
@ -530,8 +537,8 @@ transtime(const time_t janfirst, const int year, register const struct rule * ru
|
|||||||
case DAY_OF_YEAR:
|
case DAY_OF_YEAR:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * n - day of year. * Just add SECSPERDAY times the day
|
* n - day of year. Just add SECSPERDAY times the day
|
||||||
* number to the time of * January 1, midnight, to get the
|
* number to the time of January 1, midnight, to get the
|
||||||
* day.
|
* day.
|
||||||
*/
|
*/
|
||||||
value = janfirst + rulep->r_day * SECSPERDAY;
|
value = janfirst + rulep->r_day * SECSPERDAY;
|
||||||
@ -540,15 +547,15 @@ transtime(const time_t janfirst, const int year, register const struct rule * ru
|
|||||||
case MONTH_NTH_DAY_OF_WEEK:
|
case MONTH_NTH_DAY_OF_WEEK:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Mm.n.d - nth "dth day" of month m.
|
* Mm.n.d - nth "dth day" of month m.
|
||||||
*/
|
*/
|
||||||
value = janfirst;
|
value = janfirst;
|
||||||
for (i = 0; i < rulep->r_mon - 1; ++i)
|
for (i = 0; i < rulep->r_mon - 1; ++i)
|
||||||
value += mon_lengths[leapyear][i] * SECSPERDAY;
|
value += mon_lengths[leapyear][i] * SECSPERDAY;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Use Zeller's Congruence to get day-of-week of first day
|
* Use Zeller's Congruence to get day-of-week of first day
|
||||||
* of * month.
|
* of month.
|
||||||
*/
|
*/
|
||||||
m1 = (rulep->r_mon + 9) % 12 + 1;
|
m1 = (rulep->r_mon + 9) % 12 + 1;
|
||||||
yy0 = (rulep->r_mon <= 2) ? (year - 1) : year;
|
yy0 = (rulep->r_mon <= 2) ? (year - 1) : year;
|
||||||
@ -560,9 +567,9 @@ transtime(const time_t janfirst, const int year, register const struct rule * ru
|
|||||||
dow += DAYSPERWEEK;
|
dow += DAYSPERWEEK;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * "dow" is the day-of-week of the first day of the month.
|
* "dow" is the day-of-week of the first day of the month.
|
||||||
* Get * the day-of-month (zero-origin) of the first "dow" day
|
* Get the day-of-month (zero-origin) of the first "dow" day
|
||||||
* of the * month.
|
* of the month.
|
||||||
*/
|
*/
|
||||||
d = rulep->r_day - dow;
|
d = rulep->r_day - dow;
|
||||||
if (d < 0)
|
if (d < 0)
|
||||||
@ -576,25 +583,25 @@ transtime(const time_t janfirst, const int year, register const struct rule * ru
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * "d" is the day-of-month (zero-origin) of the day we want.
|
* "d" is the day-of-month (zero-origin) of the day we want.
|
||||||
*/
|
*/
|
||||||
value += d * SECSPERDAY;
|
value += d * SECSPERDAY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * "value" is the Epoch-relative time of 00:00:00 UTC on the day in *
|
* "value" is the Epoch-relative time of 00:00:00 UTC on the day in
|
||||||
* question. To get the Epoch-relative time of the specified local *
|
* question. To get the Epoch-relative time of the specified local
|
||||||
* time on that day, add the transition time and the current offset *
|
* time on that day, add the transition time and the current offset
|
||||||
* from UTC.
|
* from UTC.
|
||||||
*/
|
*/
|
||||||
return value + rulep->r_time + offset;
|
return value + rulep->r_time + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Given a POSIX section 8-style TZ string, fill in the rule tables as
|
* Given a POSIX section 8-style TZ string, fill in the rule tables as
|
||||||
** appropriate.
|
* appropriate.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
tzparse(const char *name, register struct state * sp, const int lastditch)
|
tzparse(const char *name, register struct state * sp, const int lastditch)
|
||||||
@ -672,7 +679,7 @@ tzparse(const char *name, register struct state * sp, const int lastditch)
|
|||||||
sp->typecnt = 2; /* standard time and DST */
|
sp->typecnt = 2; /* standard time and DST */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Two transitions per year, from EPOCH_YEAR to 2037.
|
* Two transitions per year, from EPOCH_YEAR to 2037.
|
||||||
*/
|
*/
|
||||||
sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1);
|
sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1);
|
||||||
if (sp->timecnt > TZ_MAX_TIMES)
|
if (sp->timecnt > TZ_MAX_TIMES)
|
||||||
@ -723,7 +730,7 @@ tzparse(const char *name, register struct state * sp, const int lastditch)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Initial values of theirstdoffset and theirdstoffset.
|
* Initial values of theirstdoffset and theirdstoffset.
|
||||||
*/
|
*/
|
||||||
theirstdoffset = 0;
|
theirstdoffset = 0;
|
||||||
for (i = 0; i < sp->timecnt; ++i)
|
for (i = 0; i < sp->timecnt; ++i)
|
||||||
@ -749,13 +756,13 @@ tzparse(const char *name, register struct state * sp, const int lastditch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Initially we're assumed to be in standard time.
|
* Initially we're assumed to be in standard time.
|
||||||
*/
|
*/
|
||||||
isdst = FALSE;
|
isdst = FALSE;
|
||||||
theiroffset = theirstdoffset;
|
theiroffset = theirstdoffset;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Now juggle transition times and types * tracking offsets
|
* Now juggle transition times and types tracking offsets
|
||||||
* as you do.
|
* as you do.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < sp->timecnt; ++i)
|
for (i = 0; i < sp->timecnt; ++i)
|
||||||
@ -769,16 +776,16 @@ tzparse(const char *name, register struct state * sp, const int lastditch)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* * If summer time is in effect, and the * transition
|
* If summer time is in effect, and the transition
|
||||||
* time was not specified as * standard time, add the
|
* time was not specified as standard time, add the
|
||||||
* summer time * offset to the transition time; *
|
* summer time offset to the transition time;
|
||||||
* otherwise, add the standard time * offset to the
|
* otherwise, add the standard time offset to the
|
||||||
* transition time.
|
* transition time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Transitions from DST to DDST * will effectively
|
* Transitions from DST to DDST will effectively
|
||||||
* disappear since * POSIX provides for only one DST *
|
* disappear since POSIX provides for only one DST
|
||||||
* offset.
|
* offset.
|
||||||
*/
|
*/
|
||||||
if (isdst && !sp->ttis[j].tt_ttisstd)
|
if (isdst && !sp->ttis[j].tt_ttisstd)
|
||||||
@ -800,7 +807,7 @@ tzparse(const char *name, register struct state * sp, const int lastditch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Finally, fill in ttis. * ttisstd and ttisgmt need not be
|
* Finally, fill in ttis. ttisstd and ttisgmt need not be
|
||||||
* handled.
|
* handled.
|
||||||
*/
|
*/
|
||||||
sp->ttis[0].tt_gmtoff = -stdoffset;
|
sp->ttis[0].tt_gmtoff = -stdoffset;
|
||||||
@ -871,14 +878,13 @@ pg_tzset(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The easy way to behave "as if no library function calls" localtime
|
* The easy way to behave "as if no library function calls" localtime
|
||||||
** is to not call it--so we drop its guts into "localsub", which can be
|
* is to not call it--so we drop its guts into "localsub", which can be
|
||||||
** freely called. (And no, the PANS doesn't require the above behavior--
|
* freely called. (And no, the PANS doesn't require the above behavior--
|
||||||
** but it *is* desirable.)
|
* but it *is* desirable.)
|
||||||
**
|
*
|
||||||
** The unused offset argument is for the benefit of mktime variants.
|
* The unused offset argument is for the benefit of mktime variants.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
localsub(const time_t *timep, const long offset, struct pg_tm * tmp)
|
localsub(const time_t *timep, const long offset, struct pg_tm * tmp)
|
||||||
{
|
{
|
||||||
@ -907,16 +913,12 @@ localsub(const time_t *timep, const long offset, struct pg_tm * tmp)
|
|||||||
}
|
}
|
||||||
ttisp = &sp->ttis[i];
|
ttisp = &sp->ttis[i];
|
||||||
|
|
||||||
/*
|
|
||||||
* * To get (wrong) behavior that's compatible with System V Release
|
|
||||||
* 2.0 * you'd replace the statement below with * t +=
|
|
||||||
* ttisp->tt_gmtoff; * timesub(&t, 0L, sp, tmp);
|
|
||||||
*/
|
|
||||||
timesub(&t, ttisp->tt_gmtoff, sp, tmp);
|
timesub(&t, ttisp->tt_gmtoff, sp, tmp);
|
||||||
tmp->tm_isdst = ttisp->tt_isdst;
|
tmp->tm_isdst = ttisp->tt_isdst;
|
||||||
tmp->tm_zone = &sp->chars[ttisp->tt_abbrind];
|
tmp->tm_zone = &sp->chars[ttisp->tt_abbrind];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct pg_tm *
|
struct pg_tm *
|
||||||
pg_localtime(const time_t *timep)
|
pg_localtime(const time_t *timep)
|
||||||
{
|
{
|
||||||
@ -926,9 +928,8 @@ pg_localtime(const time_t *timep)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** gmtsub is to gmtime as localsub is to localtime.
|
* gmtsub is to gmtime as localsub is to localtime.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gmtsub(const time_t *timep, const long offset, struct pg_tm * tmp)
|
gmtsub(const time_t *timep, const long offset, struct pg_tm * tmp)
|
||||||
{
|
{
|
||||||
@ -940,8 +941,8 @@ gmtsub(const time_t *timep, const long offset, struct pg_tm * tmp)
|
|||||||
timesub(timep, offset, gmtptr, tmp);
|
timesub(timep, offset, gmtptr, tmp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Could get fancy here and deliver something such as * "UTC+xxxx"
|
* Could get fancy here and deliver something such as "UTC+xxxx"
|
||||||
* or "UTC-xxxx" if offset is non-zero, * but this is no time for a
|
* or "UTC-xxxx" if offset is non-zero, but this is no time for a
|
||||||
* treasure hunt.
|
* treasure hunt.
|
||||||
*/
|
*/
|
||||||
if (offset != 0)
|
if (offset != 0)
|
||||||
@ -959,7 +960,8 @@ pg_gmtime(const time_t *timep)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
timesub(const time_t *timep, const long offset, register const struct state * sp, register struct pg_tm * tmp)
|
timesub(const time_t *timep, const long offset,
|
||||||
|
register const struct state * sp, register struct pg_tm * tmp)
|
||||||
{
|
{
|
||||||
register const struct lsinfo *lp;
|
register const struct lsinfo *lp;
|
||||||
register long days;
|
register long days;
|
||||||
@ -1004,7 +1006,7 @@ timesub(const time_t *timep, const long offset, register const struct state * sp
|
|||||||
if (*timep == 0x80000000)
|
if (*timep == 0x80000000)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* * A 3B1 muffs the division on the most negative number.
|
* A 3B1 muffs the division on the most negative number.
|
||||||
*/
|
*/
|
||||||
days = -24855;
|
days = -24855;
|
||||||
rem = -11648;
|
rem = -11648;
|
||||||
@ -1026,7 +1028,7 @@ timesub(const time_t *timep, const long offset, register const struct state * sp
|
|||||||
tmp->tm_min = (int) (rem / SECSPERMIN);
|
tmp->tm_min = (int) (rem / SECSPERMIN);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * A positive leap second requires a special * representation. This
|
* A positive leap second requires a special representation. This
|
||||||
* uses "... ??:59:60" et seq.
|
* uses "... ??:59:60" et seq.
|
||||||
*/
|
*/
|
||||||
tmp->tm_sec = (int) (rem % SECSPERMIN) + hit;
|
tmp->tm_sec = (int) (rem % SECSPERMIN) + hit;
|
||||||
@ -1058,20 +1060,20 @@ timesub(const time_t *timep, const long offset, register const struct state * sp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Adapted from code provided by Robert Elz, who writes:
|
* Adapted from code provided by Robert Elz, who writes:
|
||||||
** The "best" way to do mktime I think is based on an idea of Bob
|
* The "best" way to do mktime I think is based on an idea of Bob
|
||||||
** Kridle's (so its said...) from a long time ago.
|
* Kridle's (so its said...) from a long time ago.
|
||||||
** [kridle@xinet.com as of 1996-01-16.]
|
* [kridle@xinet.com as of 1996-01-16.]
|
||||||
** It does a binary search of the time_t space. Since time_t's are
|
* It does a binary search of the time_t space. Since time_t's are
|
||||||
** just 32 bits, its a max of 32 iterations (even at 64 bits it
|
* just 32 bits, its a max of 32 iterations (even at 64 bits it
|
||||||
** would still be very reasonable).
|
* would still be very reasonable).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WRONG (-1)
|
#define WRONG (-1)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Simplified normalize logic courtesy Paul Eggert (eggert@twinsun.com).
|
* Simplified normalize logic courtesy Paul Eggert (eggert@twinsun.com).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
increment_overflow(int *number, int delta)
|
increment_overflow(int *number, int delta)
|
||||||
@ -1109,7 +1111,10 @@ tmcomp(register const struct pg_tm * atmp, register const struct pg_tm * btmp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static time_t time2sub(struct pg_tm * tmp, void (*funcp) (const time_t *, long, struct pg_tm *), const long offset, int *okayp, const int do_norm_secs)
|
static time_t
|
||||||
|
time2sub(struct pg_tm * tmp,
|
||||||
|
void (*funcp) (const time_t *, long, struct pg_tm *),
|
||||||
|
const long offset, int *okayp, const int do_norm_secs)
|
||||||
{
|
{
|
||||||
register const struct state *sp;
|
register const struct state *sp;
|
||||||
register int dir;
|
register int dir;
|
||||||
@ -1138,7 +1143,7 @@ static time_t time2sub(struct pg_tm * tmp, void (*funcp) (const time_t *, long,
|
|||||||
return WRONG;
|
return WRONG;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Turn yourtm.tm_year into an actual year number for now. * It is
|
* Turn yourtm.tm_year into an actual year number for now. It is
|
||||||
* converted back to an offset from TM_YEAR_BASE later.
|
* converted back to an offset from TM_YEAR_BASE later.
|
||||||
*/
|
*/
|
||||||
if (increment_overflow(&yourtm.tm_year, TM_YEAR_BASE))
|
if (increment_overflow(&yourtm.tm_year, TM_YEAR_BASE))
|
||||||
@ -1177,10 +1182,10 @@ static time_t time2sub(struct pg_tm * tmp, void (*funcp) (const time_t *, long,
|
|||||||
else if (yourtm.tm_year + TM_YEAR_BASE < EPOCH_YEAR)
|
else if (yourtm.tm_year + TM_YEAR_BASE < EPOCH_YEAR)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* * We can't set tm_sec to 0, because that might push the * time
|
* We can't set tm_sec to 0, because that might push the time
|
||||||
* below the minimum representable time. * Set tm_sec to 59
|
* below the minimum representable time. Set tm_sec to 59
|
||||||
* instead. * This assumes that the minimum representable time is *
|
* instead. This assumes that the minimum representable time is
|
||||||
* not in the same minute that a leap second was deleted from, *
|
* not in the same minute that a leap second was deleted from,
|
||||||
* which is a safer assumption than using 58 would be.
|
* which is a safer assumption than using 58 would be.
|
||||||
*/
|
*/
|
||||||
if (increment_overflow(&yourtm.tm_sec, 1 - SECSPERMIN))
|
if (increment_overflow(&yourtm.tm_sec, 1 - SECSPERMIN))
|
||||||
@ -1195,14 +1200,14 @@ static time_t time2sub(struct pg_tm * tmp, void (*funcp) (const time_t *, long,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Divide the search space in half * (this works whether time_t is
|
* Divide the search space in half (this works whether time_t is
|
||||||
* signed or unsigned).
|
* signed or unsigned).
|
||||||
*/
|
*/
|
||||||
bits = TYPE_BIT(time_t) -1;
|
bits = TYPE_BIT(time_t) -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * If time_t is signed, then 0 is just above the median, * assuming
|
* If time_t is signed, then 0 is just above the median, assuming
|
||||||
* two's complement arithmetic. * If time_t is unsigned, then (1 <<
|
* two's complement arithmetic. If time_t is unsigned, then (1 <<
|
||||||
* bits) is just above the median.
|
* bits) is just above the median.
|
||||||
*/
|
*/
|
||||||
t = TYPE_SIGNED(time_t) ? 0 : (((time_t) 1) << bits);
|
t = TYPE_SIGNED(time_t) ? 0 : (((time_t) 1) << bits);
|
||||||
@ -1226,12 +1231,12 @@ static time_t time2sub(struct pg_tm * tmp, void (*funcp) (const time_t *, long,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Right time, wrong type. * Hunt for right time, right type. *
|
* Right time, wrong type. Hunt for right time, right type.
|
||||||
* It's okay to guess wrong since the guess * gets checked.
|
* 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.
|
* The (void *) casts are the benefit of SunOS 3.3 on Sun 2's.
|
||||||
*/
|
*/
|
||||||
sp = (const struct state *)
|
sp = (const struct state *)
|
||||||
(((void *) funcp == (void *) localsub) ?
|
(((void *) funcp == (void *) localsub) ?
|
||||||
@ -1253,7 +1258,7 @@ static time_t time2sub(struct pg_tm * tmp, void (*funcp) (const time_t *, long,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * We have a match.
|
* We have a match.
|
||||||
*/
|
*/
|
||||||
t = newt;
|
t = newt;
|
||||||
goto label;
|
goto label;
|
||||||
@ -1271,20 +1276,26 @@ label:
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static time_t time2(struct pg_tm * tmp, void (*funcp) (const time_t *, long, struct pg_tm *), const long offset, int *okayp)
|
static time_t
|
||||||
|
time2(struct pg_tm * tmp,
|
||||||
|
void (*funcp) (const time_t *, long, struct pg_tm *),
|
||||||
|
const long offset, int *okayp)
|
||||||
{
|
{
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * First try without normalization of seconds * (in case tm_sec
|
* First try without normalization of seconds (in case tm_sec
|
||||||
* contains a value associated with a leap second). * If that fails,
|
* contains a value associated with a leap second). If that fails,
|
||||||
* try with normalization of seconds.
|
* try with normalization of seconds.
|
||||||
*/
|
*/
|
||||||
t = time2sub(tmp, funcp, offset, okayp, FALSE);
|
t = time2sub(tmp, funcp, offset, okayp, FALSE);
|
||||||
return *okayp ? t : time2sub(tmp, funcp, offset, okayp, TRUE);
|
return *okayp ? t : time2sub(tmp, funcp, offset, okayp, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static time_t time1(struct pg_tm * tmp, void (*funcp) (const time_t *, long, struct pg_tm *), const long offset)
|
static time_t
|
||||||
|
time1(struct pg_tm * tmp,
|
||||||
|
void (*funcp) (const time_t *, long, struct pg_tm *),
|
||||||
|
const long offset)
|
||||||
{
|
{
|
||||||
register time_t t;
|
register time_t t;
|
||||||
register const struct state *sp;
|
register const struct state *sp;
|
||||||
@ -1305,14 +1316,14 @@ static time_t time1(struct pg_tm * tmp, void (*funcp) (const time_t *, long, str
|
|||||||
return t;
|
return t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * We're supposed to assume that somebody took a time of one type *
|
* We're supposed to assume that somebody took a time of one type
|
||||||
* and did some math on it that yielded a "struct pg_tm" that's bad. *
|
* and did some math on it that yielded a "struct pg_tm" that's bad.
|
||||||
* We try to divine the type they started from and adjust to the *
|
* We try to divine the type they started from and adjust to the
|
||||||
* type they need.
|
* type they need.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * The (void *) casts are the benefit of SunOS 3.3 on Sun 2's.
|
* The (void *) casts are the benefit of SunOS 3.3 on Sun 2's.
|
||||||
*/
|
*/
|
||||||
sp = (const struct state *) (((void *) funcp == (void *) localsub) ?
|
sp = (const struct state *) (((void *) funcp == (void *) localsub) ?
|
||||||
lclptr : gmtptr);
|
lclptr : gmtptr);
|
||||||
|
@ -2,17 +2,20 @@
|
|||||||
#define PRIVATE_H
|
#define PRIVATE_H
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This file is in the public domain, so clarified as of
|
* This file is in the public domain, so clarified as of
|
||||||
** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
|
* 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
|
||||||
*/
|
*
|
||||||
|
* IDENTIFICATION
|
||||||
|
* $PostgreSQL: pgsql/src/timezone/private.h,v 1.8 2004/05/21 20:59:10 tgl Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This header is for use ONLY with the time conversion code.
|
* This header is for use ONLY with the time conversion code.
|
||||||
** There is no guarantee that it will remain unchanged,
|
* There is no guarantee that it will remain unchanged,
|
||||||
** or that it will remain at all.
|
* or that it will remain at all.
|
||||||
** Do NOT copy it to any system include directory.
|
* Do NOT copy it to any system include directory.
|
||||||
** Thank you!
|
* Thank you!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <limits.h> /* for CHAR_BIT */
|
#include <limits.h> /* for CHAR_BIT */
|
||||||
#include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
|
#include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
|
||||||
@ -28,32 +31,31 @@
|
|||||||
#define WEXITSTATUS(status) (((status) >> 8) & 0xff)
|
#define WEXITSTATUS(status) (((status) >> 8) & 0xff)
|
||||||
#endif /* !defined WEXITSTATUS */
|
#endif /* !defined WEXITSTATUS */
|
||||||
|
|
||||||
/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
|
/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
|
||||||
#define is_digit(c) ((unsigned)(c) - '0' <= 9)
|
#define is_digit(c) ((unsigned)(c) - '0' <= 9)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** SunOS 4.1.1 headers lack EXIT_SUCCESS.
|
* SunOS 4.1.1 headers lack EXIT_SUCCESS.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef EXIT_SUCCESS
|
#ifndef EXIT_SUCCESS
|
||||||
#define EXIT_SUCCESS 0
|
#define EXIT_SUCCESS 0
|
||||||
#endif /* !defined EXIT_SUCCESS */
|
#endif /* !defined EXIT_SUCCESS */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** SunOS 4.1.1 headers lack EXIT_FAILURE.
|
* SunOS 4.1.1 headers lack EXIT_FAILURE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef EXIT_FAILURE
|
#ifndef EXIT_FAILURE
|
||||||
#define EXIT_FAILURE 1
|
#define EXIT_FAILURE 1
|
||||||
#endif /* !defined EXIT_FAILURE */
|
#endif /* !defined EXIT_FAILURE */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** SunOS 4.1.1 libraries lack remove.
|
* SunOS 4.1.1 libraries lack remove.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef remove
|
#ifndef remove
|
||||||
extern int unlink(const char *filename);
|
extern int unlink(const char *filename);
|
||||||
|
|
||||||
#define remove unlink
|
#define remove unlink
|
||||||
#endif /* !defined remove */
|
#endif /* !defined remove */
|
||||||
|
|
||||||
@ -92,11 +94,11 @@ extern char *scheck(const char *string, const char *format);
|
|||||||
|
|
||||||
#ifndef INT_STRLEN_MAXIMUM
|
#ifndef INT_STRLEN_MAXIMUM
|
||||||
/*
|
/*
|
||||||
** 302 / 1000 is log10(2.0) rounded up.
|
* 302 / 1000 is log10(2.0) rounded up.
|
||||||
** Subtract one for the sign bit if the type is signed;
|
* Subtract one for the sign bit if the type is signed;
|
||||||
** add one for integer division truncation;
|
* add one for integer division truncation;
|
||||||
** add one more for a minus sign if the type is signed.
|
* add one more for a minus sign if the type is signed.
|
||||||
*/
|
*/
|
||||||
#define INT_STRLEN_MAXIMUM(type) \
|
#define INT_STRLEN_MAXIMUM(type) \
|
||||||
((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
|
((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
|
||||||
#endif /* !defined INT_STRLEN_MAXIMUM */
|
#endif /* !defined INT_STRLEN_MAXIMUM */
|
||||||
@ -104,7 +106,7 @@ extern char *scheck(const char *string, const char *format);
|
|||||||
#define _(msgid) (msgid)
|
#define _(msgid) (msgid)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** UNIX was a registered trademark of The Open Group in 2003.
|
* UNIX was a registered trademark of The Open Group in 2003.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif /* !defined PRIVATE_H */
|
#endif /* !defined PRIVATE_H */
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* This file is in the public domain, so clarified as of
|
||||||
|
* 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
|
||||||
|
*
|
||||||
|
* IDENTIFICATION
|
||||||
|
* $PostgreSQL: pgsql/src/timezone/scheck.c,v 1.5 2004/05/21 20:59:10 tgl Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (c) 1989 The Regents of the University of California.
|
* Copyright (c) 1989 The Regents of the University of California.
|
||||||
** All rights reserved.
|
* All rights reserved.
|
||||||
**
|
*
|
||||||
** Redistribution and use in source and binary forms are permitted
|
* Redistribution and use in source and binary forms are permitted
|
||||||
** provided that the above copyright notice and this paragraph are
|
* provided that the above copyright notice and this paragraph are
|
||||||
** duplicated in all such forms and that any documentation,
|
* duplicated in all such forms and that any documentation,
|
||||||
** advertising materials, and other materials related to such
|
* advertising materials, and other materials related to such
|
||||||
** distribution and use acknowledge that the software was developed
|
* distribution and use acknowledge that the software was developed
|
||||||
** by the University of California, Berkeley. The name of the
|
* by the University of California, Berkeley. The name of the
|
||||||
** University may not be used to endorse or promote products derived
|
* University may not be used to endorse or promote products derived
|
||||||
** from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||||
** IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*/
|
*
|
||||||
|
* IDENTIFICATION
|
||||||
|
* $PostgreSQL: pgsql/src/timezone/strftime.c,v 1.3 2004/05/21 20:59:10 tgl Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
@ -60,15 +63,19 @@ static const struct lc_time_T C_time_locale = {
|
|||||||
"%H:%M:%S",
|
"%H:%M:%S",
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * x_fmt * C99 requires this format. * Using just numbers (as here)
|
* x_fmt
|
||||||
* makes Quakers happier; * it's also compatible with SVR4.
|
*
|
||||||
|
* C99 requires this format. Using just numbers (as here)
|
||||||
|
* makes Quakers happier; it's also compatible with SVR4.
|
||||||
*/
|
*/
|
||||||
"%m/%d/%y",
|
"%m/%d/%y",
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * c_fmt * C99 requires this format. * Previously this code used "%D
|
* c_fmt
|
||||||
* %X", but we now conform to C99. * Note that * "%a %b %d
|
*
|
||||||
* %H:%M:%S %Y" * is used by Solaris 2.3.
|
* C99 requires this format. Previously this code used "%D %X", but we now
|
||||||
|
* conform to C99. Note that "%a %b %d %H:%M:%S %Y" is used by Solaris
|
||||||
|
* 2.3.
|
||||||
*/
|
*/
|
||||||
"%a %b %e %T %Y",
|
"%a %b %e %T %Y",
|
||||||
|
|
||||||
@ -84,7 +91,8 @@ static const struct lc_time_T C_time_locale = {
|
|||||||
|
|
||||||
static char *_add(const char *, char *, const char *);
|
static char *_add(const char *, char *, const char *);
|
||||||
static char *_conv(int, const char *, char *, const char *);
|
static char *_conv(int, const char *, char *, const char *);
|
||||||
static char *_fmt(const char *, const struct pg_tm *, char *, const char *, int *);
|
static char *_fmt(const char *, const struct pg_tm *, char *,
|
||||||
|
const char *, int *);
|
||||||
|
|
||||||
#define IN_NONE 0
|
#define IN_NONE 0
|
||||||
#define IN_SOME 1
|
#define IN_SOME 1
|
||||||
@ -93,7 +101,8 @@ static char *_fmt(const char *, const struct pg_tm *, char *, const char *, int
|
|||||||
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
pg_strftime(char *s, size_t maxsize, const char *format, const struct pg_tm * t)
|
pg_strftime(char *s, size_t maxsize, const char *format,
|
||||||
|
const struct pg_tm *t)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
int warn;
|
int warn;
|
||||||
@ -107,7 +116,8 @@ pg_strftime(char *s, size_t maxsize, const char *format, const struct pg_tm * t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim, int *warnp)
|
_fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim,
|
||||||
|
int *warnp)
|
||||||
{
|
{
|
||||||
for (; *format; ++format)
|
for (; *format; ++format)
|
||||||
{
|
{
|
||||||
@ -147,9 +157,9 @@ _fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim, in
|
|||||||
case 'C':
|
case 'C':
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * %C used to do a... * _fmt("%a %b %e %X %Y", t); *
|
* %C used to do a... _fmt("%a %b %e %X %Y", t);
|
||||||
* ...whereas now POSIX 1003.2 calls for * something
|
* ...whereas now POSIX 1003.2 calls for something
|
||||||
* completely different. * (ado, 1993-05-24)
|
* completely different. (ado, 1993-05-24)
|
||||||
*/
|
*/
|
||||||
pt = _conv((t->tm_year + TM_YEAR_BASE) / 100,
|
pt = _conv((t->tm_year + TM_YEAR_BASE) / 100,
|
||||||
"%02d", pt, ptlim);
|
"%02d", pt, ptlim);
|
||||||
@ -175,10 +185,10 @@ _fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim, in
|
|||||||
case 'O':
|
case 'O':
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * C99 locale modifiers. * The sequences * %Ec %EC
|
* C99 locale modifiers. The sequences %Ec %EC
|
||||||
* %Ex %EX %Ey %EY * %Od %oe %OH %OI %Om %OM * %OS
|
* %Ex %EX %Ey %EY %Od %oe %OH %OI %Om %OM %OS
|
||||||
* %Ou %OU %OV %Ow %OW %Oy * are supposed to provide
|
* %Ou %OU %OV %Ow %OW %Oy are supposed to provide
|
||||||
* alternate * representations.
|
* alternate representations.
|
||||||
*/
|
*/
|
||||||
goto label;
|
goto label;
|
||||||
case 'e':
|
case 'e':
|
||||||
@ -201,12 +211,11 @@ _fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim, in
|
|||||||
case 'k':
|
case 'k':
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * This used to be... * _conv(t->tm_hour % 12 ? *
|
* This used to be... _conv(t->tm_hour % 12 ? t->tm_hour
|
||||||
* t->tm_hour % 12 : 12, 2, ' '); * ...and has been
|
* % 12 : 12, 2, ' '); ...and has been changed to the
|
||||||
* changed to the below to * match SunOS 4.1.1 and
|
* below to match SunOS 4.1.1 and Arnold Robbins' strftime
|
||||||
* Arnold Robbins' * strftime version 3.0. That is,
|
* version 3.0. That is, "%k" and "%l" have been
|
||||||
* "%k" and * "%l" have been swapped. * (ado,
|
* swapped. (ado, 1993-05-24)
|
||||||
* 1993-05-24)
|
|
||||||
*/
|
*/
|
||||||
pt = _conv(t->tm_hour, "%2d", pt, ptlim);
|
pt = _conv(t->tm_hour, "%2d", pt, ptlim);
|
||||||
continue;
|
continue;
|
||||||
@ -222,10 +231,10 @@ _fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim, in
|
|||||||
case 'l':
|
case 'l':
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * This used to be... * _conv(t->tm_hour, 2, ' '); *
|
* This used to be... _conv(t->tm_hour, 2, ' ');
|
||||||
* ...and has been changed to the below to * match
|
* ...and has been changed to the below to match
|
||||||
* SunOS 4.1.1 and Arnold Robbin's * strftime version
|
* SunOS 4.1.1 and Arnold Robbin's strftime version
|
||||||
* 3.0. That is, "%k" and * "%l" have been swapped. *
|
* 3.0. That is, "%k" and "%l" have been swapped.
|
||||||
* (ado, 1993-05-24)
|
* (ado, 1993-05-24)
|
||||||
*/
|
*/
|
||||||
pt = _conv((t->tm_hour % 12) ?
|
pt = _conv((t->tm_hour % 12) ?
|
||||||
@ -285,9 +294,9 @@ _fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim, in
|
|||||||
case 'u':
|
case 'u':
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * From Arnold Robbins' strftime version 3.0: * "ISO
|
* From Arnold Robbins' strftime version 3.0: "ISO 8601:
|
||||||
* 8601: Weekday as a decimal number * [1 (Monday) -
|
* Weekday as a decimal number [1 (Monday) - 7]"
|
||||||
* 7]" * (ado, 1993-05-24)
|
* (ado, 1993-05-24)
|
||||||
*/
|
*/
|
||||||
pt = _conv((t->tm_wday == 0) ?
|
pt = _conv((t->tm_wday == 0) ?
|
||||||
DAYSPERWEEK : t->tm_wday,
|
DAYSPERWEEK : t->tm_wday,
|
||||||
@ -297,23 +306,23 @@ _fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim, in
|
|||||||
case 'G': /* ISO 8601 year (four digits) */
|
case 'G': /* ISO 8601 year (four digits) */
|
||||||
case 'g': /* ISO 8601 year (two digits) */
|
case 'g': /* ISO 8601 year (two digits) */
|
||||||
/*
|
/*
|
||||||
** From Arnold Robbins' strftime version 3.0: "the week number of the
|
* From Arnold Robbins' strftime version 3.0: "the week number of the
|
||||||
** year (the first Monday as the first day of week 1) as a decimal number
|
* year (the first Monday as the first day of week 1) as a decimal number
|
||||||
** (01-53)."
|
* (01-53)."
|
||||||
** (ado, 1993-05-24)
|
* (ado, 1993-05-24)
|
||||||
**
|
*
|
||||||
** From "http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html" by Markus Kuhn:
|
* From "http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html" by Markus Kuhn:
|
||||||
** "Week 01 of a year is per definition the first week which has the
|
* "Week 01 of a year is per definition the first week which has the
|
||||||
** Thursday in this year, which is equivalent to the week which contains
|
* Thursday in this year, which is equivalent to the week which contains
|
||||||
** the fourth day of January. In other words, the first week of a new year
|
* the fourth day of January. In other words, the first week of a new year
|
||||||
** is the week which has the majority of its days in the new year. Week 01
|
* is the week which has the majority of its days in the new year. Week 01
|
||||||
** might also contain days from the previous year and the week before week
|
* might also contain days from the previous year and the week before week
|
||||||
** 01 of a year is the last week (52 or 53) of the previous year even if
|
* 01 of a year is the last week (52 or 53) of the previous year even if
|
||||||
** it contains days from the new year. A week starts with Monday (day 1)
|
* it contains days from the new year. A week starts with Monday (day 1)
|
||||||
** and ends with Sunday (day 7). For example, the first week of the year
|
* and ends with Sunday (day 7). For example, the first week of the year
|
||||||
** 1997 lasts from 1996-12-30 to 1997-01-05..."
|
* 1997 lasts from 1996-12-30 to 1997-01-05..."
|
||||||
** (ado, 1996-01-02)
|
* (ado, 1996-01-02)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int year;
|
int year;
|
||||||
int yday;
|
int yday;
|
||||||
@ -334,14 +343,14 @@ _fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim, in
|
|||||||
DAYSPERNYEAR;
|
DAYSPERNYEAR;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * What yday (-3 ... 3) does * the ISO year
|
* What yday (-3 ... 3) does the ISO year
|
||||||
* begin on?
|
* begin on?
|
||||||
*/
|
*/
|
||||||
bot = ((yday + 11 - wday) %
|
bot = ((yday + 11 - wday) %
|
||||||
DAYSPERWEEK) - 3;
|
DAYSPERWEEK) - 3;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * What yday does the NEXT * ISO year begin
|
* What yday does the NEXT ISO year begin
|
||||||
* on?
|
* on?
|
||||||
*/
|
*/
|
||||||
top = bot -
|
top = bot -
|
||||||
@ -383,8 +392,8 @@ _fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim, in
|
|||||||
case 'v':
|
case 'v':
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * From Arnold Robbins' strftime version 3.0: *
|
* From Arnold Robbins' strftime version 3.0:
|
||||||
* "date as dd-bbb-YYYY" * (ado, 1993-05-24)
|
* "date as dd-bbb-YYYY" (ado, 1993-05-24)
|
||||||
*/
|
*/
|
||||||
pt = _fmt("%e-%b-%Y", t, pt, ptlim, warnp);
|
pt = _fmt("%e-%b-%Y", t, pt, ptlim, warnp);
|
||||||
continue;
|
continue;
|
||||||
@ -426,8 +435,8 @@ _fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim, in
|
|||||||
pt = _add(t->tm_zone, pt, ptlim);
|
pt = _add(t->tm_zone, pt, ptlim);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * C99 says that %Z must be replaced by the * empty
|
* C99 says that %Z must be replaced by the empty
|
||||||
* string if the time zone is not * determinable.
|
* string if the time zone is not determinable.
|
||||||
*/
|
*/
|
||||||
continue;
|
continue;
|
||||||
case 'z':
|
case 'z':
|
||||||
@ -458,8 +467,8 @@ _fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim, in
|
|||||||
case '%':
|
case '%':
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * X311J/88-090 (4.12.3.5): if conversion char is *
|
* X311J/88-090 (4.12.3.5): if conversion char is
|
||||||
* undefined, behavior is undefined. Print out the *
|
* undefined, behavior is undefined. Print out the
|
||||||
* character itself as printf(3) also does.
|
* character itself as printf(3) also does.
|
||||||
*/
|
*/
|
||||||
default:
|
default:
|
||||||
|
@ -1,30 +1,32 @@
|
|||||||
#ifndef TZFILE_H
|
#ifndef TZFILE_H
|
||||||
|
|
||||||
#define TZFILE_H
|
#define TZFILE_H
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This file is in the public domain, so clarified as of
|
* This file is in the public domain, so clarified as of
|
||||||
** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
|
* 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
|
||||||
*/
|
*
|
||||||
|
* IDENTIFICATION
|
||||||
|
* $PostgreSQL: pgsql/src/timezone/tzfile.h,v 1.5 2004/05/21 20:59:10 tgl Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This header is for use ONLY with the time conversion code.
|
* This header is for use ONLY with the time conversion code.
|
||||||
** There is no guarantee that it will remain unchanged,
|
* There is no guarantee that it will remain unchanged,
|
||||||
** or that it will remain at all.
|
* or that it will remain at all.
|
||||||
** Do NOT copy it to any system include directory.
|
* Do NOT copy it to any system include directory.
|
||||||
** Thank you!
|
* Thank you!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Information about time zone files.
|
* Information about time zone files.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TZDEFAULT "localtime"
|
#define TZDEFAULT "localtime"
|
||||||
#define TZDEFRULES "posixrules"
|
#define TZDEFRULES "posixrules"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Each file begins with. . .
|
* Each file begins with. . .
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TZ_MAGIC "TZif"
|
#define TZ_MAGIC "TZif"
|
||||||
|
|
||||||
@ -42,42 +44,43 @@ struct tzhead
|
|||||||
char tzh_charcnt[4]; /* coded number of abbr. chars */
|
char tzh_charcnt[4]; /* coded number of abbr. chars */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*----------
|
||||||
** . . .followed by. . .
|
* . . .followed by. . .
|
||||||
**
|
*
|
||||||
** tzh_timecnt (char [4])s coded transition times a la time(2)
|
* tzh_timecnt (char [4])s coded transition times a la time(2)
|
||||||
** tzh_timecnt (unsigned char)s types of local time starting at above
|
* tzh_timecnt (unsigned char)s types of local time starting at above
|
||||||
** tzh_typecnt repetitions of
|
* tzh_typecnt repetitions of
|
||||||
** one (char [4]) coded UTC offset in seconds
|
* one (char [4]) coded UTC offset in seconds
|
||||||
** one (unsigned char) used to set tm_isdst
|
* one (unsigned char) used to set tm_isdst
|
||||||
** one (unsigned char) that's an abbreviation list index
|
* one (unsigned char) that's an abbreviation list index
|
||||||
** tzh_charcnt (char)s '\0'-terminated zone abbreviations
|
* tzh_charcnt (char)s '\0'-terminated zone abbreviations
|
||||||
** tzh_leapcnt repetitions of
|
* tzh_leapcnt repetitions of
|
||||||
** one (char [4]) coded leap second transition times
|
* one (char [4]) coded leap second transition times
|
||||||
** one (char [4]) total correction after above
|
* one (char [4]) total correction after above
|
||||||
** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
|
* tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
|
||||||
** time is standard time, if FALSE,
|
* time is standard time, if FALSE,
|
||||||
** transition time is wall clock time
|
* transition time is wall clock time
|
||||||
** if absent, transition times are
|
* if absent, transition times are
|
||||||
** assumed to be wall clock time
|
* assumed to be wall clock time
|
||||||
** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition
|
* tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition
|
||||||
** time is UTC, if FALSE,
|
* time is UTC, if FALSE,
|
||||||
** transition time is local time
|
* transition time is local time
|
||||||
** if absent, transition times are
|
* if absent, transition times are
|
||||||
** assumed to be local time
|
* assumed to be local time
|
||||||
*/
|
*----------
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** In the current implementation, "tzset()" refuses to deal with files that
|
* In the current implementation, "tzset()" refuses to deal with files that
|
||||||
** exceed any of the limits below.
|
* exceed any of the limits below.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The TZ_MAX_TIMES value below is enough to handle a bit more than a
|
* The TZ_MAX_TIMES value below is enough to handle a bit more than a
|
||||||
** year's worth of solar time (corrected daily to the nearest second) or
|
* year's worth of solar time (corrected daily to the nearest second) or
|
||||||
** 138 years of Pacific Presidential Election time
|
* 138 years of Pacific Presidential Election time
|
||||||
** (where there are three time zone transitions every fourth year).
|
* (where there are three time zone transitions every fourth year).
|
||||||
*/
|
*/
|
||||||
#define TZ_MAX_TIMES 370
|
#define TZ_MAX_TIMES 370
|
||||||
|
|
||||||
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can
|
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can
|
||||||
@ -127,9 +130,9 @@ struct tzhead
|
|||||||
#define EPOCH_WDAY TM_THURSDAY
|
#define EPOCH_WDAY TM_THURSDAY
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Accurate only for the past couple of centuries;
|
* Accurate only for the past couple of centuries;
|
||||||
** that will probably do.
|
* that will probably do.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
|
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
|
||||||
|
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* This file is in the public domain, so clarified as of
|
||||||
|
* 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
|
||||||
|
*
|
||||||
|
* IDENTIFICATION
|
||||||
|
* $PostgreSQL: pgsql/src/timezone/zic.c,v 1.7 2004/05/21 20:59:10 tgl Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
@ -26,13 +34,13 @@
|
|||||||
static char elsieid[] = "@(#)zic.c 7.115";
|
static char elsieid[] = "@(#)zic.c 7.115";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** On some ancient hosts, predicates like `isspace(C)' are defined
|
* On some ancient hosts, predicates like `isspace(C)' are defined
|
||||||
** only if isascii(C) || C == EOF. Modern hosts obey the C Standard,
|
* only if isascii(C) || C == EOF. Modern hosts obey the C Standard,
|
||||||
** which says they are defined only if C == ((unsigned char) C) || C == EOF.
|
* which says they are defined only if C == ((unsigned char) C) || C == EOF.
|
||||||
** Neither the C Standard nor Posix require that `isascii' exist.
|
* Neither the C Standard nor Posix require that `isascii' exist.
|
||||||
** For portability, we check both ancient and modern requirements.
|
* For portability, we check both ancient and modern requirements.
|
||||||
** If isascii is not defined, the isascii check succeeds trivially.
|
* If isascii is not defined, the isascii check succeeds trivially.
|
||||||
*/
|
*/
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#ifndef isascii
|
#ifndef isascii
|
||||||
#define isascii(x) 1
|
#define isascii(x) 1
|
||||||
@ -67,8 +75,8 @@ struct rule
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** r_dycode r_dayofmonth r_wday
|
* r_dycode r_dayofmonth r_wday
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DC_DOM 0 /* 1..31 */ /* unused */
|
#define DC_DOM 0 /* 1..31 */ /* unused */
|
||||||
#define DC_DOWGEQ 1 /* 1..31 */ /* 0..6 (Sun..Sat) */
|
#define DC_DOWGEQ 1 /* 1..31 */ /* 0..6 (Sun..Sat) */
|
||||||
@ -164,8 +172,8 @@ static int timecnt;
|
|||||||
static int typecnt;
|
static int typecnt;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Line codes.
|
* Line codes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LC_RULE 0
|
#define LC_RULE 0
|
||||||
#define LC_ZONE 1
|
#define LC_ZONE 1
|
||||||
@ -173,8 +181,8 @@ static int typecnt;
|
|||||||
#define LC_LEAP 3
|
#define LC_LEAP 3
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Which fields are which on a Zone line.
|
* Which fields are which on a Zone line.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ZF_NAME 1
|
#define ZF_NAME 1
|
||||||
#define ZF_GMTOFF 2
|
#define ZF_GMTOFF 2
|
||||||
@ -188,8 +196,8 @@ static int typecnt;
|
|||||||
#define ZONE_MAXFIELDS 9
|
#define ZONE_MAXFIELDS 9
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Which fields are which on a Zone continuation line.
|
* Which fields are which on a Zone continuation line.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ZFC_GMTOFF 0
|
#define ZFC_GMTOFF 0
|
||||||
#define ZFC_RULE 1
|
#define ZFC_RULE 1
|
||||||
@ -202,8 +210,8 @@ static int typecnt;
|
|||||||
#define ZONEC_MAXFIELDS 7
|
#define ZONEC_MAXFIELDS 7
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Which files are which on a Rule line.
|
* Which files are which on a Rule line.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define RF_NAME 1
|
#define RF_NAME 1
|
||||||
#define RF_LOYEAR 2
|
#define RF_LOYEAR 2
|
||||||
@ -217,16 +225,16 @@ static int typecnt;
|
|||||||
#define RULE_FIELDS 10
|
#define RULE_FIELDS 10
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Which fields are which on a Link line.
|
* Which fields are which on a Link line.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LF_FROM 1
|
#define LF_FROM 1
|
||||||
#define LF_TO 2
|
#define LF_TO 2
|
||||||
#define LINK_FIELDS 3
|
#define LINK_FIELDS 3
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Which fields are which on a Leap line.
|
* Which fields are which on a Leap line.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LP_YEAR 1
|
#define LP_YEAR 1
|
||||||
#define LP_MONTH 2
|
#define LP_MONTH 2
|
||||||
@ -237,8 +245,8 @@ static int typecnt;
|
|||||||
#define LEAP_FIELDS 7
|
#define LEAP_FIELDS 7
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Year synonyms.
|
* Year synonyms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define YR_MINIMUM 0
|
#define YR_MINIMUM 0
|
||||||
#define YR_MAXIMUM 1
|
#define YR_MAXIMUM 1
|
||||||
@ -360,8 +368,8 @@ static long corr[TZ_MAX_LEAPS];
|
|||||||
static char roll[TZ_MAX_LEAPS];
|
static char roll[TZ_MAX_LEAPS];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Memory allocation.
|
* Memory allocation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
memcheck(ptr)
|
memcheck(ptr)
|
||||||
@ -384,8 +392,8 @@ char *const ptr;
|
|||||||
#define ecatalloc(oldp, newp) memcheck(icatalloc((oldp), (newp)))
|
#define ecatalloc(oldp, newp) memcheck(icatalloc((oldp), (newp)))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Error handling.
|
* Error handling.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HAVE_STRERROR
|
#ifndef HAVE_STRERROR
|
||||||
static char *
|
static char *
|
||||||
@ -418,8 +426,8 @@ static void
|
|||||||
error(const char *string)
|
error(const char *string)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* * Match the format of "cc" to allow sh users to * zic ... 2>&1 |
|
* Match the format of "cc" to allow sh users to zic ... 2>&1 |
|
||||||
* error -t "*" -v * on BSD systems.
|
* error -t "*" -v on BSD systems.
|
||||||
*/
|
*/
|
||||||
(void) fprintf(stderr, _("\"%s\", line %d: %s"),
|
(void) fprintf(stderr, _("\"%s\", line %d: %s"),
|
||||||
filename, linenum, string);
|
filename, linenum, string);
|
||||||
@ -564,7 +572,7 @@ main(int argc, char *argv[])
|
|||||||
for (i = 0; i < nzones; i = j)
|
for (i = 0; i < nzones; i = j)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* * Find the next non-continuation zone entry.
|
* Find the next non-continuation zone entry.
|
||||||
*/
|
*/
|
||||||
for (j = i + 1; j < nzones && zones[j].z_name == NULL; ++j)
|
for (j = i + 1; j < nzones && zones[j].z_name == NULL; ++j)
|
||||||
continue;
|
continue;
|
||||||
@ -572,7 +580,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Make links.
|
* Make links.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < nlinks; ++i)
|
for (i = 0; i < nlinks; ++i)
|
||||||
{
|
{
|
||||||
@ -616,7 +624,7 @@ dolink(const char *fromfile, const char *tofile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * We get to be careful here since * there's a fair chance of root
|
* We get to be careful here since there's a fair chance of root
|
||||||
* running us.
|
* running us.
|
||||||
*/
|
*/
|
||||||
if (!itsdir(toname))
|
if (!itsdir(toname))
|
||||||
@ -670,11 +678,11 @@ dolink(const char *fromfile, const char *tofile)
|
|||||||
#endif /* !defined INT_MIN */
|
#endif /* !defined INT_MIN */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The tz file format currently allows at most 32-bit quantities.
|
* The tz file format currently allows at most 32-bit quantities.
|
||||||
** This restriction should be removed before signed 32-bit values
|
* This restriction should be removed before signed 32-bit values
|
||||||
** wrap around in 2038, but unfortunately this will require a
|
* wrap around in 2038, but unfortunately this will require a
|
||||||
** change to the tz file format.
|
* change to the tz file format.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAX_BITS_IN_FILE 32
|
#define MAX_BITS_IN_FILE 32
|
||||||
#define TIME_T_BITS_IN_FILE ((TYPE_BIT(time_t) < MAX_BITS_IN_FILE) ? TYPE_BIT(time_t) : MAX_BITS_IN_FILE)
|
#define TIME_T_BITS_IN_FILE ((TYPE_BIT(time_t) < MAX_BITS_IN_FILE) ? TYPE_BIT(time_t) : MAX_BITS_IN_FILE)
|
||||||
@ -717,12 +725,12 @@ itsdir(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Associate sets of rules with zones.
|
* Associate sets of rules with zones.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Sort by rule name.
|
* Sort by rule name.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rcomp(const void *cp1, const void *cp2)
|
rcomp(const void *cp1, const void *cp2)
|
||||||
@ -800,14 +808,14 @@ associate(void)
|
|||||||
if (zp->z_nrules == 0)
|
if (zp->z_nrules == 0)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* * Maybe we have a local standard time offset.
|
* Maybe we have a local standard time offset.
|
||||||
*/
|
*/
|
||||||
eat(zp->z_filename, zp->z_linenum);
|
eat(zp->z_filename, zp->z_linenum);
|
||||||
zp->z_stdoff = gethms(zp->z_rule, _("unruly zone"),
|
zp->z_stdoff = gethms(zp->z_rule, _("unruly zone"),
|
||||||
TRUE);
|
TRUE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Note, though, that if there's no rule, * a '%s' in the
|
* Note, though, that if there's no rule, a '%s' in the
|
||||||
* format is a bad thing.
|
* format is a bad thing.
|
||||||
*/
|
*/
|
||||||
if (strchr(zp->z_format, '%') != 0)
|
if (strchr(zp->z_format, '%') != 0)
|
||||||
@ -927,14 +935,14 @@ infile(const char *name)
|
|||||||
error(_("expected continuation line not found"));
|
error(_("expected continuation line not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*----------
|
||||||
** Convert a string of one of the forms
|
* Convert a string of one of the forms
|
||||||
** h -h hh:mm -hh:mm hh:mm:ss -hh:mm:ss
|
* h -h hh:mm -hh:mm hh:mm:ss -hh:mm:ss
|
||||||
** into a number of seconds.
|
* into a number of seconds.
|
||||||
** A null string maps to zero.
|
* A null string maps to zero.
|
||||||
** Call error with errstring and return zero on errors.
|
* Call error with errstring and return zero on errors.
|
||||||
*/
|
*----------
|
||||||
|
*/
|
||||||
static long
|
static long
|
||||||
gethms(const char *string, const char *errstring, const int signable)
|
gethms(const char *string, const char *errstring, const int signable)
|
||||||
{
|
{
|
||||||
@ -1144,7 +1152,7 @@ inzsub(register char **fields, const int nfields, const int iscont)
|
|||||||
zones[nzones++] = z;
|
zones[nzones++] = z;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * If there was an UNTIL field on this line, * there's more
|
* If there was an UNTIL field on this line, there's more
|
||||||
* information about the zone on the next line.
|
* information about the zone on the next line.
|
||||||
*/
|
*/
|
||||||
return hasuntil;
|
return hasuntil;
|
||||||
@ -1302,7 +1310,9 @@ inlink(register char **fields, const int nfields)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rulesub(register struct rule * rp, const char *loyearp, const char *hiyearp, const char *typep, const char *monthp, const char *dayp, const char *timep)
|
rulesub(register struct rule * rp, const char *loyearp, const char *hiyearp,
|
||||||
|
const char *typep, const char *monthp, const char *dayp,
|
||||||
|
const char *timep)
|
||||||
{
|
{
|
||||||
register const struct lookup *lp;
|
register const struct lookup *lp;
|
||||||
register const char *cp;
|
register const char *cp;
|
||||||
@ -1346,7 +1356,7 @@ rulesub(register struct rule * rp, const char *loyearp, const char *hiyearp, con
|
|||||||
ifree(dp);
|
ifree(dp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Year work.
|
* Year work.
|
||||||
*/
|
*/
|
||||||
cp = loyearp;
|
cp = loyearp;
|
||||||
lp = byword(cp, begin_years);
|
lp = byword(cp, begin_years);
|
||||||
@ -1428,8 +1438,7 @@ rulesub(register struct rule * rp, const char *loyearp, const char *hiyearp, con
|
|||||||
min_year = rp->r_loyear;
|
min_year = rp->r_loyear;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Day work. * Accept things such as: * 1 * last-Sunday * Sun<=20 *
|
* Day work. Accept things such as: 1 last-Sunday Sun<=20 Sun>=7
|
||||||
* Sun>=7
|
|
||||||
*/
|
*/
|
||||||
dp = ecpyalloc(dayp);
|
dp = ecpyalloc(dayp);
|
||||||
if ((lp = byword(dp, lasts)) != NULL)
|
if ((lp = byword(dp, lasts)) != NULL)
|
||||||
@ -1520,14 +1529,14 @@ writezone(const char *name)
|
|||||||
unsigned char types[TZ_MAX_TIMES];
|
unsigned char types[TZ_MAX_TIMES];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Sort.
|
* Sort.
|
||||||
*/
|
*/
|
||||||
if (timecnt > 1)
|
if (timecnt > 1)
|
||||||
(void) qsort((void *) attypes, (size_t) timecnt,
|
(void) qsort((void *) attypes, (size_t) timecnt,
|
||||||
(size_t) sizeof *attypes, atcomp);
|
(size_t) sizeof *attypes, atcomp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Optimize.
|
* Optimize.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int fromi;
|
int fromi;
|
||||||
@ -1560,7 +1569,7 @@ writezone(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Transfer.
|
* Transfer.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < timecnt; ++i)
|
for (i = 0; i < timecnt; ++i)
|
||||||
{
|
{
|
||||||
@ -1572,7 +1581,7 @@ writezone(const char *name)
|
|||||||
(void) sprintf(fullname, "%s/%s", directory, name);
|
(void) sprintf(fullname, "%s/%s", directory, name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Remove old file, if any, to snap links.
|
* Remove old file, if any, to snap links.
|
||||||
*/
|
*/
|
||||||
if (!itsdir(fullname) && remove(fullname) != 0 && errno != ENOENT)
|
if (!itsdir(fullname) && remove(fullname) != 0 && errno != ENOENT)
|
||||||
{
|
{
|
||||||
@ -1714,14 +1723,14 @@ outzone(const struct zone * zpfirst, const int zonecount)
|
|||||||
char startbuf[BUFSIZ];
|
char startbuf[BUFSIZ];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Now. . .finally. . .generate some useful data!
|
* Now. . .finally. . .generate some useful data!
|
||||||
*/
|
*/
|
||||||
timecnt = 0;
|
timecnt = 0;
|
||||||
typecnt = 0;
|
typecnt = 0;
|
||||||
charcnt = 0;
|
charcnt = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Thanks to Earl Chew (earl@dnd.icp.nec.com.au) * for noting the
|
* Thanks to Earl Chew (earl@dnd.icp.nec.com.au) for noting the
|
||||||
* need to unconditionally initialize startttisstd.
|
* need to unconditionally initialize startttisstd.
|
||||||
*/
|
*/
|
||||||
startttisstd = FALSE;
|
startttisstd = FALSE;
|
||||||
@ -1729,7 +1738,7 @@ outzone(const struct zone * zpfirst, const int zonecount)
|
|||||||
for (i = 0; i < zonecount; ++i)
|
for (i = 0; i < zonecount; ++i)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* * A guess that may well be corrected later.
|
* A guess that may well be corrected later.
|
||||||
*/
|
*/
|
||||||
stdoff = 0;
|
stdoff = 0;
|
||||||
zp = &zpfirst[i];
|
zp = &zpfirst[i];
|
||||||
@ -1764,7 +1773,7 @@ outzone(const struct zone * zpfirst, const int zonecount)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Mark which rules to do in the current year. * For
|
* Mark which rules to do in the current year. For
|
||||||
* those to do, calculate rpytime(rp, year);
|
* those to do, calculate rpytime(rp, year);
|
||||||
*/
|
*/
|
||||||
for (j = 0; j < zp->z_nrules; ++j)
|
for (j = 0; j < zp->z_nrules; ++j)
|
||||||
@ -1789,8 +1798,8 @@ outzone(const struct zone * zpfirst, const int zonecount)
|
|||||||
if (useuntil)
|
if (useuntil)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* * Turn untiltime into UTC * assuming the
|
* Turn untiltime into UTC assuming the
|
||||||
* current gmtoff and * stdoff values.
|
* current gmtoff and stdoff values.
|
||||||
*/
|
*/
|
||||||
untiltime = zp->z_untiltime;
|
untiltime = zp->z_untiltime;
|
||||||
if (!zp->z_untilrule.r_todisgmt)
|
if (!zp->z_untilrule.r_todisgmt)
|
||||||
@ -1802,7 +1811,7 @@ outzone(const struct zone * zpfirst, const int zonecount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Find the rule (of those to do, if any) * that
|
* Find the rule (of those to do, if any) that
|
||||||
* takes effect earliest in the year.
|
* takes effect earliest in the year.
|
||||||
*/
|
*/
|
||||||
k = -1;
|
k = -1;
|
||||||
@ -1885,7 +1894,7 @@ outzone(const struct zone * zpfirst, const int zonecount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Now we may get to set starttime for the next zone line.
|
* Now we may get to set starttime for the next zone line.
|
||||||
*/
|
*/
|
||||||
if (useuntil)
|
if (useuntil)
|
||||||
{
|
{
|
||||||
@ -1930,7 +1939,8 @@ addtt(const time_t starttime, int type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
addtype(const long gmtoff, const char *abbr, const int isdst, const int ttisstd, const int ttisgmt)
|
addtype(const long gmtoff, const char *abbr, const int isdst,
|
||||||
|
const int ttisstd, const int ttisgmt)
|
||||||
{
|
{
|
||||||
register int i,
|
register int i,
|
||||||
j;
|
j;
|
||||||
@ -1952,7 +1962,7 @@ addtype(const long gmtoff, const char *abbr, const int isdst, const int ttisstd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * See if there's already an entry for this zone type. * If so, just
|
* See if there's already an entry for this zone type. If so, just
|
||||||
* return its index.
|
* return its index.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < typecnt; ++i)
|
for (i = 0; i < typecnt; ++i)
|
||||||
@ -1965,7 +1975,7 @@ addtype(const long gmtoff, const char *abbr, const int isdst, const int ttisstd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * There isn't one; add a new one, unless there are already too *
|
* There isn't one; add a new one, unless there are already too
|
||||||
* many.
|
* many.
|
||||||
*/
|
*/
|
||||||
if (typecnt >= TZ_MAX_TYPES)
|
if (typecnt >= TZ_MAX_TYPES)
|
||||||
@ -2031,7 +2041,7 @@ adjleap(void)
|
|||||||
register long last = 0;
|
register long last = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * propagate leap seconds forward
|
* propagate leap seconds forward
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < leapcnt; ++i)
|
for (i = 0; i < leapcnt; ++i)
|
||||||
{
|
{
|
||||||
@ -2107,14 +2117,14 @@ byword(register const char *word, register const struct lookup * table)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Look for exact match.
|
* Look for exact match.
|
||||||
*/
|
*/
|
||||||
for (lp = table; lp->l_word != NULL; ++lp)
|
for (lp = table; lp->l_word != NULL; ++lp)
|
||||||
if (ciequal(word, lp->l_word))
|
if (ciequal(word, lp->l_word))
|
||||||
return lp;
|
return lp;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Look for inexact match.
|
* Look for inexact match.
|
||||||
*/
|
*/
|
||||||
foundlp = NULL;
|
foundlp = NULL;
|
||||||
for (lp = table; lp->l_word != NULL; ++lp)
|
for (lp = table; lp->l_word != NULL; ++lp)
|
||||||
@ -2200,9 +2210,9 @@ tadd(const time_t t1, const long t2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Given a rule, and a year, compute the date - in seconds since January 1,
|
* Given a rule, and a year, compute the date - in seconds since January 1,
|
||||||
** 1970, 00:00 LOCAL time - in that year that the rule refers to.
|
* 1970, 00:00 LOCAL time - in that year that the rule refers to.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static time_t
|
static time_t
|
||||||
rpytime(register const struct rule * rp, register const int wantedy)
|
rpytime(register const struct rule * rp, register const int wantedy)
|
||||||
@ -2261,7 +2271,7 @@ rpytime(register const struct rule * rp, register const int wantedy)
|
|||||||
wday = eitol(EPOCH_WDAY);
|
wday = eitol(EPOCH_WDAY);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Don't trust mod of negative numbers.
|
* Don't trust mod of negative numbers.
|
||||||
*/
|
*/
|
||||||
if (dayoff >= 0)
|
if (dayoff >= 0)
|
||||||
wday = (wday + dayoff) % LDAYSPERWEEK;
|
wday = (wday + dayoff) % LDAYSPERWEEK;
|
||||||
@ -2333,7 +2343,7 @@ mkdirs(char *argname)
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * DOS drive specifier?
|
* DOS drive specifier?
|
||||||
*/
|
*/
|
||||||
if (isalpha((unsigned char) name[0]) &&
|
if (isalpha((unsigned char) name[0]) &&
|
||||||
name[1] == ':' && name[2] == '\0')
|
name[1] == ':' && name[2] == '\0')
|
||||||
@ -2345,9 +2355,9 @@ mkdirs(char *argname)
|
|||||||
if (!itsdir(name))
|
if (!itsdir(name))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* * It doesn't seem to exist, so we try to create it. *
|
* It doesn't seem to exist, so we try to create it.
|
||||||
* Creation may fail because of the directory being * created
|
* Creation may fail because of the directory being created
|
||||||
* by some other multiprocessor, so we get * to do extra
|
* by some other multiprocessor, so we get to do extra
|
||||||
* checking.
|
* checking.
|
||||||
*/
|
*/
|
||||||
if (mkdir(name, MKDIR_UMASK) != 0)
|
if (mkdir(name, MKDIR_UMASK) != 0)
|
||||||
@ -2387,8 +2397,8 @@ eitol(const int i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** UNIX was a registered trademark of The Open Group in 2003.
|
* UNIX was a registered trademark of The Open Group in 2003.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user