respect to doubly-starred comment blocks. Do some manual cleanup.
+/*
+ * 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 "private.h"
/*
-** This file is in the public domain, so clarified as of
-** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
-*/
+ * 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/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).
-** POSIX-style TZ environment variable handling from Guy Harris
-** (guy@auspex.com).
-*/
+ * Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu).
+ * POSIX-style TZ environment variable handling from Guy Harris
+ * (guy@auspex.com).
+ */
#include "postgres.h"
#ifndef WILDABBR
-/*
-** Someone might make incorrect use of a time zone abbreviation:
-** 1. They might reference tzname[0] before calling tzset (explicitly
-** or implicitly).
-** 2. They might reference tzname[1] before calling tzset (explicitly
-** or implicitly).
-** 3. They might reference tzname[1] after setting to a time zone
-** in which Daylight Saving Time is never observed.
-** 4. They might reference tzname[0] after setting to a time zone
-** in which Standard Time is never observed.
-** 5. They might reference tm.TM_ZONE after calling offtime.
-** 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
-** WILDABBR is used. Another possibility: initialize tzname[0] to the
-** string "tzname[0] used before set", and similarly for the other cases.
-** And another: initialize tzname[0] to "ERA", with an explanation in the
-** manual page of what this "time zone abbreviation" means (doing this so
-** that tzname[0] has the "normal" length of three characters).
-*/
+/*----------
+ * Someone might make incorrect use of a time zone abbreviation:
+ * 1. They might reference tzname[0] before calling tzset (explicitly
+ * or implicitly).
+ * 2. They might reference tzname[1] before calling tzset (explicitly
+ * or implicitly).
+ * 3. They might reference tzname[1] after setting to a time zone
+ * in which Daylight Saving Time is never observed.
+ * 4. They might reference tzname[0] after setting to a time zone
+ * in which Standard Time is never observed.
+ * 5. They might reference tm.TM_ZONE after calling offtime.
+ * 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
+ * WILDABBR is used. Another possibility: initialize tzname[0] to the
+ * string "tzname[0] used before set", and similarly for the other cases.
+ * And another: initialize tzname[0] to "ERA", with an explanation in the
+ * manual page of what this "time zone abbreviation" means (doing this so
+ * that tzname[0] has the "normal" length of three characters).
+ *----------
+ */
#define WILDABBR " "
#endif /* !defined WILDABBR */
static const char gmt[] = "GMT";
/*
-** 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.
-** POSIX 1003.1 section 8.1.1 says that the default DST rules are
-** implementation dependent; for historical reasons, US rules are a
-** common default.
-*/
+ * 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.
+ * POSIX 1003.1 section 8.1.1 says that the default DST rules are
+ * implementation dependent; for historical reasons, US rules are a
+ * common default.
+ */
#define TZDEFRULESTRING ",M4.1.0,M10.5.0"
struct ttinfo
* week */
/*
-** Prototypes for static functions.
-*/
+ * Prototypes for static functions.
+ */
static long detzcode(const char *codep);
static const char *getzname(const char *strp);
static void localsub(const time_t *timep, long offset, struct pg_tm * tmp);
static int increment_overflow(int *number, int delta);
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 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 time_t time1(struct pg_tm * tmp,
+ void (*funcp) (const time_t *, long, struct pg_tm *),
+ long offset);
+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 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 tzparse(const char *name, struct state * sp, int lastditch);
static int gmt_is_set = 0;
/*
-** Section 4.12.3 of X3.159-1989 requires that
-** Except for the strftime function, these functions [asctime,
-** ctime, gmtime, localtime] return values in one of two static
-** objects: a broken-down time structure and an array of char.
-** Thanks to Paul Eggert (eggert@twinsun.com) for noting this.
-*/
+ * Section 4.12.3 of X3.159-1989 requires that
+ * Except for the strftime function, these functions [asctime,
+ * ctime, gmtime, localtime] return values in one of two static
+ * objects: a broken-down time structure and an array of char.
+ * Thanks to Paul Eggert (eggert@twinsun.com) for noting this.
+ */
static struct pg_tm tm;
(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)
doaccess = TRUE;
};
/*
-** 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
-** character.
-*/
-
+ * 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
+ * character.
+ */
static const char *
getzname(register const char *strp)
{
}
/*
-** 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
-** NULL.
-** Otherwise, return a pointer to the first character not part of the number.
-*/
-
+ * 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
+ * NULL.
+ * Otherwise, return a pointer to the first character not part of the number.
+ */
static const char *
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,
-** in hh[:mm[:ss]] form, from the string.
-** If any error occurs, return NULL.
-** Otherwise, return a pointer to the first character not part of the number
-** of seconds.
-*/
-
+ * Given a pointer into a time zone string, extract a number of seconds,
+ * in hh[:mm[:ss]] form, from the string.
+ * If any error occurs, return NULL.
+ * Otherwise, return a pointer to the first character not part of the number
+ * of seconds.
+ */
static const char *
getsecs(register const char *strp, long *secsp)
{
int num;
/*
- * * `HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like *
- * "M10.4.6/26", which does not conform to Posix, * but which
- * specifies the equivalent of * ``02:00 on the first Sunday on or
+ * `HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like
+ * "M10.4.6/26", which does not conform to Posix, but which
+ * specifies the equivalent of ``02:00 on the first Sunday on or
* after 23 Oct''.
*/
strp = getnum(strp, &num, 0, HOURSPERDAY * DAYSPERWEEK - 1);
}
/*
-** Given a pointer into a time zone string, extract an offset, in
-** [+-]hh[:mm[:ss]] form, from the string.
-** If any error occurs, return NULL.
-** Otherwise, return a pointer to the first character not part of the time.
-*/
-
+ * Given a pointer into a time zone string, extract an offset, in
+ * [+-]hh[:mm[:ss]] form, from the string.
+ * If any error occurs, return NULL.
+ * Otherwise, return a pointer to the first character not part of the time.
+ */
static const char *
getoffset(register const char *strp, long *offsetp)
{
}
/*
-** 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".
-** If a valid rule is not found, return NULL.
-** Otherwise, return a pointer to the first character not part of the rule.
-*/
-
+ * 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".
+ * If a valid rule is not found, return NULL.
+ * Otherwise, return a pointer to the first character not part of the rule.
+ */
static const char *
getrule(const char *strp, register struct rule * rulep)
{
if (*strp == 'J')
{
/*
- * * Julian day.
+ * Julian day.
*/
rulep->r_type = JULIAN_DAY;
++strp;
else if (*strp == 'M')
{
/*
- * * Month, week, day.
+ * Month, week, day.
*/
rulep->r_type = MONTH_NTH_DAY_OF_WEEK;
++strp;
else if (is_digit(*strp))
{
/*
- * * Day of year.
+ * Day of year.
*/
rulep->r_type = DAY_OF_YEAR;
strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1);
if (*strp == '/')
{
/*
- * * Time specified.
+ * Time specified.
*/
++strp;
strp = getsecs(strp, &rulep->r_time);
}
/*
-** 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,
-** calculate the Epoch-relative time that rule takes effect.
-*/
-
+ * 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,
+ * calculate the Epoch-relative time that rule takes effect.
+ */
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 time_t value = 0;
case JULIAN_DAY:
/*
- * * Jn - Julian day, 1 == January 1, 60 == March 1 even in
- * leap * years. * In non-leap years, or if the day number is
- * 59 or less, just * add SECSPERDAY times the day number-1 to
- * the time of * January 1, midnight, to get the day.
+ * Jn - Julian day, 1 == January 1, 60 == March 1 even in
+ * leap years. In non-leap years, or if the day number is
+ * 59 or less, just add SECSPERDAY times the day number-1 to
+ * the time of January 1, midnight, to get the day.
*/
value = janfirst + (rulep->r_day - 1) * SECSPERDAY;
if (leapyear && rulep->r_day >= 60)
case DAY_OF_YEAR:
/*
- * * n - day of year. * Just add SECSPERDAY times the day
- * number to the time of * January 1, midnight, to get the
+ * n - day of year. Just add SECSPERDAY times the day
+ * number to the time of January 1, midnight, to get the
* day.
*/
value = janfirst + rulep->r_day * SECSPERDAY;
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;
for (i = 0; i < rulep->r_mon - 1; ++i)
value += mon_lengths[leapyear][i] * SECSPERDAY;
/*
- * * Use Zeller's Congruence to get day-of-week of first day
- * of * month.
+ * Use Zeller's Congruence to get day-of-week of first day
+ * of month.
*/
m1 = (rulep->r_mon + 9) % 12 + 1;
yy0 = (rulep->r_mon <= 2) ? (year - 1) : year;
dow += DAYSPERWEEK;
/*
- * * "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
- * 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
+ * of the month.
*/
d = rulep->r_day - dow;
if (d < 0)
}
/*
- * * "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;
break;
}
/*
- * * "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 *
- * time on that day, add the transition time and the current offset *
+ * "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
+ * time on that day, add the transition time and the current offset
* from UTC.
*/
return value + rulep->r_time + offset;
}
/*
-** Given a POSIX section 8-style TZ string, fill in the rule tables as
-** appropriate.
-*/
+ * Given a POSIX section 8-style TZ string, fill in the rule tables as
+ * appropriate.
+ */
static int
tzparse(const char *name, register struct state * sp, const int lastditch)
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);
if (sp->timecnt > TZ_MAX_TIMES)
return -1;
/*
- * * Initial values of theirstdoffset and theirdstoffset.
+ * Initial values of theirstdoffset and theirdstoffset.
*/
theirstdoffset = 0;
for (i = 0; i < sp->timecnt; ++i)
}
/*
- * * Initially we're assumed to be in standard time.
+ * Initially we're assumed to be in standard time.
*/
isdst = FALSE;
theiroffset = theirstdoffset;
/*
- * * Now juggle transition times and types * tracking offsets
+ * Now juggle transition times and types tracking offsets
* as you do.
*/
for (i = 0; i < sp->timecnt; ++i)
else
{
/*
- * * If summer time is in effect, and the * transition
- * time was not specified as * standard time, add the
- * summer time * offset to the transition time; *
- * otherwise, add the standard time * offset to the
+ * If summer time is in effect, and the transition
+ * time was not specified as standard time, add the
+ * summer time offset to the transition time;
+ * otherwise, add the standard time offset to the
* transition time.
*/
/*
- * * Transitions from DST to DDST * will effectively
- * disappear since * POSIX provides for only one DST *
+ * Transitions from DST to DDST will effectively
+ * disappear since POSIX provides for only one DST
* offset.
*/
if (isdst && !sp->ttis[j].tt_ttisstd)
}
/*
- * * Finally, fill in ttis. * ttisstd and ttisgmt need not be
+ * Finally, fill in ttis. ttisstd and ttisgmt need not be
* handled.
*/
sp->ttis[0].tt_gmtoff = -stdoffset;
}
/*
-** 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
-** freely called. (And no, the PANS doesn't require the above behavior--
-** but it *is* desirable.)
-**
-** The unused offset argument is for the benefit of mktime variants.
-*/
-
+ * 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
+ * freely called. (And no, the PANS doesn't require the above behavior--
+ * but it *is* desirable.)
+ *
+ * The unused offset argument is for the benefit of mktime variants.
+ */
static void
localsub(const time_t *timep, const long offset, struct pg_tm * tmp)
{
}
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);
tmp->tm_isdst = ttisp->tt_isdst;
tmp->tm_zone = &sp->chars[ttisp->tt_abbrind];
}
+
struct pg_tm *
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
gmtsub(const time_t *timep, const long offset, struct pg_tm * tmp)
{
timesub(timep, offset, gmtptr, tmp);
/*
- * * 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
+ * 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
* treasure hunt.
*/
if (offset != 0)
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 long days;
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;
rem = -11648;
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.
*/
tmp->tm_sec = (int) (rem % SECSPERMIN) + hit;
}
/*
-** Adapted from code provided by Robert Elz, who writes:
-** 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@xinet.com as of 1996-01-16.]
-** 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
-** would still be very reasonable).
-*/
+ * Adapted from code provided by Robert Elz, who writes:
+ * 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@xinet.com as of 1996-01-16.]
+ * 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
+ * would still be very reasonable).
+ */
#define WRONG (-1)
/*
-** Simplified normalize logic courtesy Paul Eggert (eggert@twinsun.com).
-*/
+ * Simplified normalize logic courtesy Paul Eggert (eggert@twinsun.com).
+ */
static int
increment_overflow(int *number, int delta)
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 int dir;
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.
*/
if (increment_overflow(&yourtm.tm_year, TM_YEAR_BASE))
else if (yourtm.tm_year + TM_YEAR_BASE < EPOCH_YEAR)
{
/*
- * * We can't set tm_sec to 0, because that might push the * time
- * below the minimum representable time. * Set tm_sec to 59
- * instead. * This assumes that the minimum representable time is *
- * not in the same minute that a leap second was deleted from, *
+ * We can't set tm_sec to 0, because that might push the time
+ * below the minimum representable time. Set tm_sec to 59
+ * instead. This assumes that the minimum representable time is
+ * not in the same minute that a leap second was deleted from,
* which is a safer assumption than using 58 would be.
*/
if (increment_overflow(&yourtm.tm_sec, 1 - SECSPERMIN))
}
/*
- * * 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).
*/
bits = TYPE_BIT(time_t) -1;
/*
- * * If time_t is signed, then 0 is just above the median, * assuming
- * two's complement arithmetic. * If time_t is unsigned, then (1 <<
+ * If time_t is signed, then 0 is just above the median, assuming
+ * two's complement arithmetic. If time_t is unsigned, then (1 <<
* bits) is just above the median.
*/
t = TYPE_SIGNED(time_t) ? 0 : (((time_t) 1) << bits);
break;
/*
- * * Right time, wrong type. * Hunt for right time, right type. *
- * It's okay to guess wrong since the guess * gets checked.
+ * Right time, wrong type. Hunt for right time, right type.
+ * 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 *)
(((void *) funcp == (void *) localsub) ?
continue;
/*
- * * We have a match.
+ * We have a match.
*/
t = newt;
goto label;
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;
/*
- * * First try without normalization of seconds * (in case tm_sec
- * contains a value associated with a leap second). * If that fails,
+ * First try without normalization of seconds (in case tm_sec
+ * contains a value associated with a leap second). If that fails,
* try with normalization of seconds.
*/
t = time2sub(tmp, funcp, offset, okayp, FALSE);
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 const struct state *sp;
return t;
/*
- * * 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. *
- * We try to divine the type they started from and adjust to the *
+ * 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.
+ * 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.
+ * The (void *) casts are the benefit of SunOS 3.3 on Sun 2's.
*/
sp = (const struct state *) (((void *) funcp == (void *) localsub) ?
lclptr : gmtptr);
#define PRIVATE_H
/*
-** This file is in the public domain, so clarified as of
-** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
-*/
+ * 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/private.h,v 1.8 2004/05/21 20:59:10 tgl Exp $
+ */
/*
-** This header is for use ONLY with the time conversion code.
-** There is no guarantee that it will remain unchanged,
-** or that it will remain at all.
-** Do NOT copy it to any system include directory.
-** Thank you!
-*/
+ * This header is for use ONLY with the time conversion code.
+ * There is no guarantee that it will remain unchanged,
+ * or that it will remain at all.
+ * Do NOT copy it to any system include directory.
+ * Thank you!
+ */
#include <limits.h> /* for CHAR_BIT */
#include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
#define WEXITSTATUS(status) (((status) >> 8) & 0xff)
#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)
/*
-** SunOS 4.1.1 headers lack EXIT_SUCCESS.
-*/
+ * SunOS 4.1.1 headers lack EXIT_SUCCESS.
+ */
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif /* !defined EXIT_SUCCESS */
/*
-** SunOS 4.1.1 headers lack EXIT_FAILURE.
-*/
+ * SunOS 4.1.1 headers lack EXIT_FAILURE.
+ */
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif /* !defined EXIT_FAILURE */
/*
-** SunOS 4.1.1 libraries lack remove.
-*/
+ * SunOS 4.1.1 libraries lack remove.
+ */
#ifndef remove
extern int unlink(const char *filename);
-
#define remove unlink
#endif /* !defined remove */
#ifndef INT_STRLEN_MAXIMUM
/*
-** 302 / 1000 is log10(2.0) rounded up.
-** Subtract one for the sign bit if the type is signed;
-** add one for integer division truncation;
-** add one more for a minus sign if the type is signed.
-*/
+ * 302 / 1000 is log10(2.0) rounded up.
+ * Subtract one for the sign bit if the type is signed;
+ * add one for integer division truncation;
+ * add one more for a minus sign if the type is signed.
+ */
#define INT_STRLEN_MAXIMUM(type) \
((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
#endif /* !defined INT_STRLEN_MAXIMUM */
#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 */
+/*
+ * 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 "private.h"
/*
-** Copyright (c) 1989 The Regents of the University of California.
-** All rights reserved.
-**
-** Redistribution and use in source and binary forms are permitted
-** provided that the above copyright notice and this paragraph are
-** duplicated in all such forms and that any documentation,
-** advertising materials, and other materials related to such
-** distribution and use acknowledge that the software was developed
-** by the University of California, Berkeley. The name of the
-** University may not be used to endorse or promote products derived
-** from this software without specific prior written permission.
-** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-** IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-*/
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * 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"
"%H:%M:%S",
/*
- * * x_fmt * C99 requires this format. * Using just numbers (as here)
- * makes Quakers happier; * it's also compatible with SVR4.
+ * x_fmt
+ *
+ * C99 requires this format. Using just numbers (as here)
+ * makes Quakers happier; it's also compatible with SVR4.
*/
"%m/%d/%y",
/*
- * * c_fmt * 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.
+ * c_fmt
+ *
+ * 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",
static char *_add(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_SOME 1
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;
int warn;
}
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)
{
case 'C':
/*
- * * %C used to do a... * _fmt("%a %b %e %X %Y", t); *
- * ...whereas now POSIX 1003.2 calls for * something
- * completely different. * (ado, 1993-05-24)
+ * %C used to do a... _fmt("%a %b %e %X %Y", t);
+ * ...whereas now POSIX 1003.2 calls for something
+ * completely different. (ado, 1993-05-24)
*/
pt = _conv((t->tm_year + TM_YEAR_BASE) / 100,
"%02d", pt, ptlim);
case 'O':
/*
- * * C99 locale modifiers. * The sequences * %Ec %EC
- * %Ex %EX %Ey %EY * %Od %oe %OH %OI %Om %OM * %OS
- * %Ou %OU %OV %Ow %OW %Oy * are supposed to provide
- * alternate * representations.
+ * C99 locale modifiers. The sequences %Ec %EC
+ * %Ex %EX %Ey %EY %Od %oe %OH %OI %Om %OM %OS
+ * %Ou %OU %OV %Ow %OW %Oy are supposed to provide
+ * alternate representations.
*/
goto label;
case 'e':
case 'k':
/*
- * * This used to be... * _conv(t->tm_hour % 12 ? *
- * t->tm_hour % 12 : 12, 2, ' '); * ...and has been
- * changed to the below to * match SunOS 4.1.1 and
- * Arnold Robbins' * strftime version 3.0. That is,
- * "%k" and * "%l" have been swapped. * (ado,
- * 1993-05-24)
+ * This used to be... _conv(t->tm_hour % 12 ? t->tm_hour
+ * % 12 : 12, 2, ' '); ...and has been changed to the
+ * below to match SunOS 4.1.1 and Arnold Robbins' strftime
+ * version 3.0. That is, "%k" and "%l" have been
+ * swapped. (ado, 1993-05-24)
*/
pt = _conv(t->tm_hour, "%2d", pt, ptlim);
continue;
case 'l':
/*
- * * This used to be... * _conv(t->tm_hour, 2, ' '); *
- * ...and has been changed to the below to * match
- * SunOS 4.1.1 and Arnold Robbin's * strftime version
- * 3.0. That is, "%k" and * "%l" have been swapped. *
+ * This used to be... _conv(t->tm_hour, 2, ' ');
+ * ...and has been changed to the below to match
+ * SunOS 4.1.1 and Arnold Robbin's strftime version
+ * 3.0. That is, "%k" and "%l" have been swapped.
* (ado, 1993-05-24)
*/
pt = _conv((t->tm_hour % 12) ?
case 'u':
/*
- * * From Arnold Robbins' strftime version 3.0: * "ISO
- * 8601: Weekday as a decimal number * [1 (Monday) -
- * 7]" * (ado, 1993-05-24)
+ * From Arnold Robbins' strftime version 3.0: "ISO 8601:
+ * Weekday as a decimal number [1 (Monday) - 7]"
+ * (ado, 1993-05-24)
*/
pt = _conv((t->tm_wday == 0) ?
DAYSPERWEEK : t->tm_wday,
case 'G': /* ISO 8601 year (four digits) */
case 'g': /* ISO 8601 year (two digits) */
/*
-** 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
-** (01-53)."
-** (ado, 1993-05-24)
-**
-** 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
-** 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
-** 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
-** 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)
-** and ends with Sunday (day 7). For example, the first week of the year
-** 1997 lasts from 1996-12-30 to 1997-01-05..."
-** (ado, 1996-01-02)
-*/
+ * 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
+ * (01-53)."
+ * (ado, 1993-05-24)
+ *
+ * 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
+ * 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
+ * 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
+ * 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)
+ * and ends with Sunday (day 7). For example, the first week of the year
+ * 1997 lasts from 1996-12-30 to 1997-01-05..."
+ * (ado, 1996-01-02)
+ */
{
int year;
int yday;
DAYSPERNYEAR;
/*
- * * What yday (-3 ... 3) does * the ISO year
+ * What yday (-3 ... 3) does the ISO year
* begin on?
*/
bot = ((yday + 11 - wday) %
DAYSPERWEEK) - 3;
/*
- * * What yday does the NEXT * ISO year begin
+ * What yday does the NEXT ISO year begin
* on?
*/
top = bot -
case 'v':
/*
- * * From Arnold Robbins' strftime version 3.0: *
- * "date as dd-bbb-YYYY" * (ado, 1993-05-24)
+ * From Arnold Robbins' strftime version 3.0:
+ * "date as dd-bbb-YYYY" (ado, 1993-05-24)
*/
pt = _fmt("%e-%b-%Y", t, pt, ptlim, warnp);
continue;
pt = _add(t->tm_zone, pt, ptlim);
/*
- * * C99 says that %Z must be replaced by the * empty
- * string if the time zone is not * determinable.
+ * C99 says that %Z must be replaced by the empty
+ * string if the time zone is not determinable.
*/
continue;
case 'z':
case '%':
/*
- * * X311J/88-090 (4.12.3.5): if conversion char is *
- * undefined, behavior is undefined. Print out the *
+ * X311J/88-090 (4.12.3.5): if conversion char is
+ * undefined, behavior is undefined. Print out the
* character itself as printf(3) also does.
*/
default:
#ifndef TZFILE_H
-
#define TZFILE_H
/*
-** This file is in the public domain, so clarified as of
-** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
-*/
+ * 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/tzfile.h,v 1.5 2004/05/21 20:59:10 tgl Exp $
+ */
/*
-** This header is for use ONLY with the time conversion code.
-** There is no guarantee that it will remain unchanged,
-** or that it will remain at all.
-** Do NOT copy it to any system include directory.
-** Thank you!
-*/
+ * This header is for use ONLY with the time conversion code.
+ * There is no guarantee that it will remain unchanged,
+ * or that it will remain at all.
+ * Do NOT copy it to any system include directory.
+ * Thank you!
+ */
/*
-** Information about time zone files.
-*/
+ * Information about time zone files.
+ */
#define TZDEFAULT "localtime"
#define TZDEFRULES "posixrules"
/*
-** Each file begins with. . .
-*/
+ * Each file begins with. . .
+ */
#define TZ_MAGIC "TZif"
char tzh_charcnt[4]; /* coded number of abbr. chars */
};
-/*
-** . . .followed by. . .
-**
-** 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_typecnt repetitions of
-** one (char [4]) coded UTC offset in seconds
-** one (unsigned char) used to set tm_isdst
-** one (unsigned char) that's an abbreviation list index
-** tzh_charcnt (char)s '\0'-terminated zone abbreviations
-** tzh_leapcnt repetitions of
-** one (char [4]) coded leap second transition times
-** one (char [4]) total correction after above
-** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
-** time is standard time, if FALSE,
-** transition time is wall clock time
-** if absent, transition times are
-** assumed to be wall clock time
-** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition
-** time is UTC, if FALSE,
-** transition time is local time
-** if absent, transition times are
-** assumed to be local time
-*/
+/*----------
+ * . . .followed by. . .
+ *
+ * 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_typecnt repetitions of
+ * one (char [4]) coded UTC offset in seconds
+ * one (unsigned char) used to set tm_isdst
+ * one (unsigned char) that's an abbreviation list index
+ * tzh_charcnt (char)s '\0'-terminated zone abbreviations
+ * tzh_leapcnt repetitions of
+ * one (char [4]) coded leap second transition times
+ * one (char [4]) total correction after above
+ * tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
+ * time is standard time, if FALSE,
+ * transition time is wall clock time
+ * if absent, transition times are
+ * assumed to be wall clock time
+ * tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition
+ * time is UTC, if FALSE,
+ * transition time is local time
+ * if absent, transition times are
+ * assumed to be local time
+ *----------
+ */
/*
-** In the current implementation, "tzset()" refuses to deal with files that
-** exceed any of the limits below.
-*/
+ * In the current implementation, "tzset()" refuses to deal with files that
+ * exceed any of the limits below.
+ */
/*
-** 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
-** 138 years of Pacific Presidential Election time
-** (where there are three time zone transitions every fourth year).
-*/
+ * 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
+ * 138 years of Pacific Presidential Election time
+ * (where there are three time zone transitions every fourth year).
+ */
#define TZ_MAX_TIMES 370
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can
#define EPOCH_WDAY TM_THURSDAY
/*
-** Accurate only for the past couple of centuries;
-** that will probably do.
-*/
+ * Accurate only for the past couple of centuries;
+ * that will probably do.
+ */
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
+/*
+ * 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 <locale.h>
static char elsieid[] = "@(#)zic.c 7.115";
/*
-** On some ancient hosts, predicates like `isspace(C)' are defined
-** 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.
-** Neither the C Standard nor Posix require that `isascii' exist.
-** For portability, we check both ancient and modern requirements.
-** If isascii is not defined, the isascii check succeeds trivially.
-*/
+ * On some ancient hosts, predicates like `isspace(C)' are defined
+ * 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.
+ * Neither the C Standard nor Posix require that `isascii' exist.
+ * For portability, we check both ancient and modern requirements.
+ * If isascii is not defined, the isascii check succeeds trivially.
+ */
#include <ctype.h>
#ifndef isascii
#define isascii(x) 1
};
/*
-** r_dycode r_dayofmonth r_wday
-*/
+ * r_dycode r_dayofmonth r_wday
+ */
#define DC_DOM 0 /* 1..31 */ /* unused */
#define DC_DOWGEQ 1 /* 1..31 */ /* 0..6 (Sun..Sat) */
static int typecnt;
/*
-** Line codes.
-*/
+ * Line codes.
+ */
#define LC_RULE 0
#define LC_ZONE 1
#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_GMTOFF 2
#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_RULE 1
#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_LOYEAR 2
#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_TO 2
#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_MONTH 2
#define LEAP_FIELDS 7
/*
-** Year synonyms.
-*/
+ * Year synonyms.
+ */
#define YR_MINIMUM 0
#define YR_MAXIMUM 1
static char roll[TZ_MAX_LEAPS];
/*
-** Memory allocation.
-*/
+ * Memory allocation.
+ */
static char *
memcheck(ptr)
#define ecatalloc(oldp, newp) memcheck(icatalloc((oldp), (newp)))
/*
-** Error handling.
-*/
+ * Error handling.
+ */
#ifndef HAVE_STRERROR
static char *
error(const char *string)
{
/*
- * * Match the format of "cc" to allow sh users to * zic ... 2>&1 |
- * error -t "*" -v * on BSD systems.
+ * Match the format of "cc" to allow sh users to zic ... 2>&1 |
+ * error -t "*" -v on BSD systems.
*/
(void) fprintf(stderr, _("\"%s\", line %d: %s"),
filename, linenum, string);
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)
continue;
}
/*
- * * Make links.
+ * Make links.
*/
for (i = 0; i < nlinks; ++i)
{
}
/*
- * * 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.
*/
if (!itsdir(toname))
#endif /* !defined INT_MIN */
/*
-** The tz file format currently allows at most 32-bit quantities.
-** This restriction should be removed before signed 32-bit values
-** wrap around in 2038, but unfortunately this will require a
-** change to the tz file format.
-*/
+ * The tz file format currently allows at most 32-bit quantities.
+ * This restriction should be removed before signed 32-bit values
+ * wrap around in 2038, but unfortunately this will require a
+ * change to the tz file format.
+ */
#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)
}
/*
-** Associate sets of rules with zones.
-*/
+ * Associate sets of rules with zones.
+ */
/*
-** Sort by rule name.
-*/
+ * Sort by rule name.
+ */
static int
rcomp(const void *cp1, const void *cp2)
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);
zp->z_stdoff = gethms(zp->z_rule, _("unruly zone"),
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.
*/
if (strchr(zp->z_format, '%') != 0)
error(_("expected continuation line not found"));
}
-/*
-** Convert a string of one of the forms
-** h -h hh:mm -hh:mm hh:mm:ss -hh:mm:ss
-** into a number of seconds.
-** A null string maps to zero.
-** Call error with errstring and return zero on errors.
-*/
-
+/*----------
+ * Convert a string of one of the forms
+ * h -h hh:mm -hh:mm hh:mm:ss -hh:mm:ss
+ * into a number of seconds.
+ * A null string maps to zero.
+ * Call error with errstring and return zero on errors.
+ *----------
+ */
static long
gethms(const char *string, const char *errstring, const int signable)
{
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.
*/
return hasuntil;
}
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 char *cp;
ifree(dp);
/*
- * * Year work.
+ * Year work.
*/
cp = loyearp;
lp = byword(cp, begin_years);
min_year = rp->r_loyear;
/*
- * * Day work. * Accept things such as: * 1 * last-Sunday * Sun<=20 *
- * Sun>=7
+ * Day work. Accept things such as: 1 last-Sunday Sun<=20 Sun>=7
*/
dp = ecpyalloc(dayp);
if ((lp = byword(dp, lasts)) != NULL)
unsigned char types[TZ_MAX_TIMES];
/*
- * * Sort.
+ * Sort.
*/
if (timecnt > 1)
(void) qsort((void *) attypes, (size_t) timecnt,
(size_t) sizeof *attypes, atcomp);
/*
- * * Optimize.
+ * Optimize.
*/
{
int fromi;
}
/*
- * * Transfer.
+ * Transfer.
*/
for (i = 0; i < timecnt; ++i)
{
(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)
{
char startbuf[BUFSIZ];
/*
- * * Now. . .finally. . .generate some useful data!
+ * Now. . .finally. . .generate some useful data!
*/
timecnt = 0;
typecnt = 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.
*/
startttisstd = FALSE;
for (i = 0; i < zonecount; ++i)
{
/*
- * * A guess that may well be corrected later.
+ * A guess that may well be corrected later.
*/
stdoff = 0;
zp = &zpfirst[i];
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);
*/
for (j = 0; j < zp->z_nrules; ++j)
if (useuntil)
{
/*
- * * Turn untiltime into UTC * assuming the
- * current gmtoff and * stdoff values.
+ * Turn untiltime into UTC assuming the
+ * current gmtoff and stdoff values.
*/
untiltime = zp->z_untiltime;
if (!zp->z_untilrule.r_todisgmt)
}
/*
- * * 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.
*/
k = -1;
}
/*
- * * 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)
{
}
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,
j;
}
/*
- * * 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.
*/
for (i = 0; i < typecnt; ++i)
}
/*
- * * 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.
*/
if (typecnt >= TZ_MAX_TYPES)
register long last = 0;
/*
- * * propagate leap seconds forward
+ * propagate leap seconds forward
*/
for (i = 0; i < leapcnt; ++i)
{
return NULL;
/*
- * * Look for exact match.
+ * Look for exact match.
*/
for (lp = table; lp->l_word != NULL; ++lp)
if (ciequal(word, lp->l_word))
return lp;
/*
- * * Look for inexact match.
+ * Look for inexact match.
*/
foundlp = NULL;
for (lp = table; lp->l_word != NULL; ++lp)
}
/*
-** 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.
-*/
+ * 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.
+ */
static time_t
rpytime(register const struct rule * rp, register const int wantedy)
wday = eitol(EPOCH_WDAY);
/*
- * * Don't trust mod of negative numbers.
+ * Don't trust mod of negative numbers.
*/
if (dayoff >= 0)
wday = (wday + dayoff) % LDAYSPERWEEK;
#ifdef WIN32
/*
- * * DOS drive specifier?
+ * DOS drive specifier?
*/
if (isalpha((unsigned char) name[0]) &&
name[1] == ':' && name[2] == '\0')
if (!itsdir(name))
{
/*
- * * It doesn't seem to exist, so we try to create it. *
- * Creation may fail because of the directory being * created
- * by some other multiprocessor, so we get * to do extra
+ * It doesn't seem to exist, so we try to create it.
+ * Creation may fail because of the directory being created
+ * by some other multiprocessor, so we get to do extra
* checking.
*/
if (mkdir(name, MKDIR_UMASK) != 0)
}
/*
-** UNIX was a registered trademark of The Open Group in 2003.
-*/
+ * UNIX was a registered trademark of The Open Group in 2003.
+ */
#ifdef WIN32