diff options
Diffstat (limited to 'src/timezone')
-rw-r--r-- | src/timezone/ialloc.c | 8 | ||||
-rw-r--r-- | src/timezone/localtime.c | 172 | ||||
-rw-r--r-- | src/timezone/pgtz.c | 229 | ||||
-rw-r--r-- | src/timezone/pgtz.h | 13 | ||||
-rw-r--r-- | src/timezone/scheck.c | 10 | ||||
-rw-r--r-- | src/timezone/strftime.c | 51 | ||||
-rw-r--r-- | src/timezone/tzfile.h | 17 | ||||
-rw-r--r-- | src/timezone/zic.c | 221 |
8 files changed, 354 insertions, 367 deletions
diff --git a/src/timezone/ialloc.c b/src/timezone/ialloc.c index a1335075714..547a786e34d 100644 --- a/src/timezone/ialloc.c +++ b/src/timezone/ialloc.c @@ -3,7 +3,7 @@ * 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/ialloc.c,v 1.6 2005/06/20 08:00:51 neilc Exp $ + * $PostgreSQL: pgsql/src/timezone/ialloc.c,v 1.7 2005/10/15 02:49:51 momjian Exp $ */ #include "postgres.h" @@ -38,9 +38,9 @@ irealloc(void *pointer, const int size) char * icatalloc(char *old, const char *new) { - char *result; - int oldsize, - newsize; + char *result; + int oldsize, + newsize; newsize = (new == NULL) ? 0 : strlen(new); if (old == NULL) diff --git a/src/timezone/localtime.c b/src/timezone/localtime.c index 098d6700f92..342bdc920c8 100644 --- a/src/timezone/localtime.c +++ b/src/timezone/localtime.c @@ -3,7 +3,7 @@ * 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/localtime.c,v 1.11 2005/06/20 08:00:51 neilc Exp $ + * $PostgreSQL: pgsql/src/timezone/localtime.c,v 1.12 2005/10/15 02:49:51 momjian Exp $ */ /* @@ -69,8 +69,7 @@ struct rule #define JULIAN_DAY 0 /* Jn - Julian day */ #define DAY_OF_YEAR 1 /* n - day of year */ -#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of - * week */ +#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */ /* * Prototypes for static functions. @@ -81,15 +80,15 @@ static const char *getzname(const char *strp); static const char *getnum(const char *strp, int *nump, int min, int max); static const char *getsecs(const char *strp, long *secsp); static const char *getoffset(const char *strp, long *offsetp); -static const char *getrule(const char *strp, struct rule *rulep); -static void gmtload(struct state *sp); -static void gmtsub(const pg_time_t *timep, long offset, struct pg_tm *tmp); -static void localsub(const pg_time_t *timep, long offset, struct pg_tm *tmp, const pg_tz *tz); +static const char *getrule(const char *strp, struct rule * rulep); +static void gmtload(struct state * sp); +static void gmtsub(const pg_time_t *timep, long offset, struct pg_tm * tmp); +static void localsub(const pg_time_t *timep, long offset, struct pg_tm * tmp, const pg_tz *tz); static void timesub(const pg_time_t *timep, long offset, - const struct state *sp, struct pg_tm *tmp); + const struct state * sp, struct pg_tm * tmp); static pg_time_t transtime(pg_time_t janfirst, int year, - const struct rule *rulep, long offset); -int tzparse(const char *name, struct state *sp, int lastditch); + const struct rule * rulep, long offset); +int tzparse(const char *name, struct state * sp, int lastditch); /* GMT timezone */ static struct state gmtmem; @@ -113,8 +112,8 @@ static struct pg_tm tm; static long detzcode(const char *codep) { - long result; - int i; + long result; + int i; result = (codep[0] & 0x80) ? ~0L : 0L; for (i = 0; i < 4; ++i) @@ -123,16 +122,16 @@ detzcode(const char *codep) } int -tzload(const char *name, struct state *sp) +tzload(const char *name, struct state * sp) { const char *p; - int i; - int fid; + int i; + int fid; if (name == NULL && (name = TZDEFAULT) == NULL) return -1; { - int doaccess; + int doaccess; char fullname[MAXPGPATH]; if (name[0] == ':') @@ -286,7 +285,7 @@ static const int year_lengths[2] = { static const char * getzname(const char *strp) { - char c; + char c; while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' && c != '+') @@ -303,8 +302,8 @@ getzname(const char *strp) static const char * getnum(const char *strp, int *nump, int min, int max) { - char c; - int num; + char c; + int num; if (strp == NULL || !is_digit(c = *strp)) return NULL; @@ -336,8 +335,8 @@ getsecs(const char *strp, long *secsp) /* * `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''. + * "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); if (strp == NULL) @@ -372,7 +371,7 @@ getsecs(const char *strp, long *secsp) static const char * getoffset(const char *strp, long *offsetp) { - int neg = 0; + int neg = 0; if (*strp == '-') { @@ -396,7 +395,7 @@ getoffset(const char *strp, long *offsetp) * Otherwise, return a pointer to the first character not part of the rule. */ static const char * -getrule(const char *strp, struct rule *rulep) +getrule(const char *strp, struct rule * rulep) { if (*strp == 'J') { @@ -458,10 +457,10 @@ getrule(const char *strp, struct rule *rulep) */ static pg_time_t transtime(const pg_time_t janfirst, int year, - const struct rule *rulep, long offset) + const struct rule * rulep, long offset) { - int leapyear; - pg_time_t value = 0; + int leapyear; + pg_time_t value = 0; int i, d, m1, @@ -478,9 +477,9 @@ transtime(const pg_time_t janfirst, int year, /* * 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. + * 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) @@ -490,8 +489,8 @@ transtime(const pg_time_t janfirst, int year, 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 day. + * 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; break; @@ -519,9 +518,8 @@ transtime(const pg_time_t janfirst, int 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) @@ -543,9 +541,8 @@ transtime(const pg_time_t janfirst, int year, /* * "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. + * 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; } @@ -556,7 +553,7 @@ transtime(const pg_time_t janfirst, int year, */ int -tzparse(const char *name, struct state *sp, int lastditch) +tzparse(const char *name, struct state * sp, int lastditch) { const char *stdname; const char *dstname = NULL; @@ -564,10 +561,10 @@ tzparse(const char *name, struct state *sp, int lastditch) size_t dstlen; long stdoffset; long dstoffset; - pg_time_t *atp; + pg_time_t *atp; unsigned char *typep; - char *cp; - int load_result; + char *cp; + int load_result; stdname = name; if (lastditch) @@ -614,8 +611,8 @@ tzparse(const char *name, struct state *sp, int lastditch) { struct rule start; struct rule end; - int year; - pg_time_t janfirst; + int year; + pg_time_t janfirst; pg_time_t starttime; pg_time_t endtime; @@ -671,12 +668,12 @@ tzparse(const char *name, struct state *sp, int lastditch) } else { - long theirstdoffset; - long theirdstoffset; - long theiroffset; - int isdst; - int i; - int j; + long theirstdoffset; + long theirdstoffset; + long theiroffset; + int isdst; + int i; + int j; if (*name != '\0') return -1; @@ -714,8 +711,8 @@ tzparse(const char *name, struct state *sp, int lastditch) theiroffset = theirstdoffset; /* - * Now juggle transition times and types tracking offsets as - * you do. + * Now juggle transition times and types tracking offsets as you + * do. */ for (i = 0; i < sp->timecnt; ++i) { @@ -728,17 +725,15 @@ tzparse(const char *name, struct state *sp, int lastditch) 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 - * transition time. + * 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 - * offset. + * Transitions from DST to DDST will effectively disappear + * since POSIX provides for only one DST offset. */ if (isdst && !sp->ttis[j].tt_ttisstd) { @@ -759,8 +754,7 @@ tzparse(const char *name, struct state *sp, int lastditch) } /* - * Finally, fill in ttis. ttisstd and ttisgmt need not be - * handled. + * Finally, fill in ttis. ttisstd and ttisgmt need not be handled. */ sp->ttis[0].tt_gmtoff = -stdoffset; sp->ttis[0].tt_isdst = FALSE; @@ -798,7 +792,7 @@ tzparse(const char *name, struct state *sp, int lastditch) } static void -gmtload(struct state *sp) +gmtload(struct state * sp) { if (tzload(gmt, sp) != 0) (void) tzparse(gmt, sp, TRUE); @@ -814,11 +808,11 @@ gmtload(struct state *sp) * The unused offset argument is for the benefit of mktime variants. */ static void -localsub(const pg_time_t *timep, long offset, struct pg_tm *tmp, const pg_tz *tz) +localsub(const pg_time_t *timep, long offset, struct pg_tm * tmp, const pg_tz *tz) { - const struct state *sp; + const struct state *sp; const struct ttinfo *ttisp; - int i; + int i; const pg_time_t t = *timep; sp = &tz->state; @@ -859,7 +853,7 @@ pg_localtime(const pg_time_t *timep, const pg_tz *tz) * gmtsub is to gmtime as localsub is to localtime. */ static void -gmtsub(const pg_time_t *timep, long offset, struct pg_tm *tmp) +gmtsub(const pg_time_t *timep, long offset, struct pg_tm * tmp) { if (!gmt_is_set) { @@ -870,8 +864,8 @@ gmtsub(const pg_time_t *timep, long offset, struct pg_tm *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 - * treasure hunt. + * "UTC-xxxx" if offset is non-zero, but this is no time for a treasure + * hunt. */ if (offset != 0) tmp->tm_zone = wildabbr; @@ -889,20 +883,20 @@ pg_gmtime(const pg_time_t *timep) static void timesub(const pg_time_t *timep, long offset, - const struct state *sp, struct pg_tm *tmp) + const struct state * sp, struct pg_tm * tmp) { const struct lsinfo *lp; /* expand days to 64 bits to support full Julian-day range */ - int64 days; - int idays; - long rem; - int y; - int yleap; - const int *ip; - long corr; - int hit; - int i; + int64 days; + int idays; + long rem; + int y; + int yleap; + const int *ip; + long corr; + int hit; + int i; corr = 0; hit = 0; @@ -959,8 +953,8 @@ timesub(const pg_time_t *timep, long offset, tmp->tm_min = (int) (rem / SECSPERMIN); /* - * A positive leap second requires a special representation. This - * uses "... ??:59:60" et seq. + * A positive leap second requires a special representation. This uses + * "... ??:59:60" et seq. */ tmp->tm_sec = (int) (rem % SECSPERMIN) + hit; tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK); @@ -970,16 +964,16 @@ timesub(const pg_time_t *timep, long offset, /* * Note: the point of adding 4800 is to ensure we make the same - * assumptions as Postgres' Julian-date routines about the placement - * of leap years in centuries BC, at least back to 4713BC which is as - * far as we'll go. This is effectively extending Gregorian - * timekeeping into pre-Gregorian centuries, which is a tad bogus but - * it conforms to the SQL spec... + * assumptions as Postgres' Julian-date routines about the placement of + * leap years in centuries BC, at least back to 4713BC which is as far as + * we'll go. This is effectively extending Gregorian timekeeping into + * pre-Gregorian centuries, which is a tad bogus but it conforms to the + * SQL spec... */ #define LEAPS_THRU_END_OF(y) (((y) + 4800) / 4 - ((y) + 4800) / 100 + ((y) + 4800) / 400) while (days < 0 || days >= (int64) year_lengths[yleap = isleap(y)]) { - int newy; + int newy; newy = y + days / DAYSPERNYEAR; if (days < 0) @@ -1027,12 +1021,12 @@ pg_next_dst_boundary(const pg_time_t *timep, pg_time_t *boundary, long int *after_gmtoff, int *after_isdst, - const pg_tz *tz) + const pg_tz *tz) { const struct state *sp; const struct ttinfo *ttisp; - int i; - int j; + int i; + int j; const pg_time_t t = *timep; sp = &tz->state; diff --git a/src/timezone/pgtz.c b/src/timezone/pgtz.c index 2512061222a..23165062bf7 100644 --- a/src/timezone/pgtz.c +++ b/src/timezone/pgtz.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.37 2005/09/09 02:31:50 tgl Exp $ + * $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.38 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,7 +29,7 @@ #include "utils/hsearch.h" /* Current global timezone */ -pg_tz *global_timezone = NULL; +pg_tz *global_timezone = NULL; static char tzdir[MAXPGPATH]; @@ -97,7 +97,7 @@ static void scan_available_timezones(char *tzdir, char *tzdirsub, * Get GMT offset from a system struct tm */ static int -get_timezone_offset(struct tm *tm) +get_timezone_offset(struct tm * tm) { #if defined(HAVE_STRUCT_TM_TM_ZONE) return tm->tm_gmtoff; @@ -128,7 +128,7 @@ build_time_t(int year, int month, int day) * Does a system tm value match one we computed ourselves? */ static bool -compare_tm(struct tm *s, struct pg_tm *p) +compare_tm(struct tm * s, struct pg_tm * p) { if (s->tm_sec != p->tm_sec || s->tm_min != p->tm_min || @@ -155,21 +155,25 @@ compare_tm(struct tm *s, struct pg_tm *p) * test time. */ static int -score_timezone(const char *tzname, struct tztry *tt) +score_timezone(const char *tzname, struct tztry * tt) { int i; pg_time_t pgtt; struct tm *systm; struct pg_tm *pgtm; char cbuf[TZ_STRLEN_MAX + 1]; - pg_tz tz; + pg_tz tz; - /* Load timezone directly. Don't use pg_tzset, because we don't want - * all timezones loaded in the cache at startup. */ - if (tzload(tzname, &tz.state) != 0) { - if (tzname[0] == ':' || tzparse(tzname, &tz.state, FALSE) != 0) { - return -1; /* can't handle the TZ name at all */ + /* + * Load timezone directly. Don't use pg_tzset, because we don't want all + * timezones loaded in the cache at startup. + */ + if (tzload(tzname, &tz.state) != 0) + { + if (tzname[0] == ':' || tzparse(tzname, &tz.state, FALSE) != 0) + { + return -1; /* can't handle the TZ name at all */ } } @@ -257,20 +261,19 @@ identify_system_timezone(void) /* * Set up the list of dates to be probed to see how well our timezone - * matches the system zone. We first probe January and July of 2004; - * this serves to quickly eliminate the vast majority of the TZ - * database entries. If those dates match, we probe every week from - * 2004 backwards to late 1904. (Weekly resolution is good enough to - * identify DST transition rules, since everybody switches on - * Sundays.) The further back the zone matches, the better we score - * it. This may seem like a rather random way of doing things, but - * experience has shown that system-supplied timezone definitions are - * likely to have DST behavior that is right for the recent past and - * not so accurate further back. Scoring in this way allows us to - * recognize zones that have some commonality with the zic database, - * without insisting on exact match. (Note: we probe Thursdays, not - * Sundays, to avoid triggering DST-transition bugs in localtime - * itself.) + * matches the system zone. We first probe January and July of 2004; this + * serves to quickly eliminate the vast majority of the TZ database + * entries. If those dates match, we probe every week from 2004 backwards + * to late 1904. (Weekly resolution is good enough to identify DST + * transition rules, since everybody switches on Sundays.) The further + * back the zone matches, the better we score it. This may seem like a + * rather random way of doing things, but experience has shown that + * system-supplied timezone definitions are likely to have DST behavior + * that is right for the recent past and not so accurate further back. + * Scoring in this way allows us to recognize zones that have some + * commonality with the zic database, without insisting on exact match. + * (Note: we probe Thursdays, not Sundays, to avoid triggering + * DST-transition bugs in localtime itself.) */ tt.n_test_times = 0; tt.test_times[tt.n_test_times++] = build_time_t(2004, 1, 15); @@ -292,12 +295,12 @@ identify_system_timezone(void) return resultbuf; /* - * Couldn't find a match in the database, so next we try constructed - * zone names (like "PST8PDT"). + * Couldn't find a match in the database, so next we try constructed zone + * names (like "PST8PDT"). * - * First we need to determine the names of the local standard and - * daylight zones. The idea here is to scan forward from today until - * we have seen both zones, if both are in use. + * First we need to determine the names of the local standard and daylight + * zones. The idea here is to scan forward from today until we have seen + * both zones, if both are in use. */ memset(std_zone_name, 0, sizeof(std_zone_name)); memset(dst_zone_name, 0, sizeof(dst_zone_name)); @@ -306,15 +309,15 @@ identify_system_timezone(void) tnow = time(NULL); /* - * Round back to a GMT midnight so results don't depend on local time - * of day + * Round back to a GMT midnight so results don't depend on local time of + * day */ tnow -= (tnow % T_DAY); /* - * We have to look a little further ahead than one year, in case today - * is just past a DST boundary that falls earlier in the year than the - * next similar boundary. Arbitrarily scan up to 14 months. + * We have to look a little further ahead than one year, in case today is + * just past a DST boundary that falls earlier in the year than the next + * similar boundary. Arbitrarily scan up to 14 months. */ for (t = tnow; t <= tnow + T_MONTH * 14; t += T_MONTH) { @@ -348,7 +351,7 @@ identify_system_timezone(void) { ereport(LOG, (errmsg("unable to determine system timezone, defaulting to \"%s\"", "GMT"), - errhint("You can specify the correct timezone in postgresql.conf."))); + errhint("You can specify the correct timezone in postgresql.conf."))); return NULL; /* go to GMT */ } @@ -373,19 +376,18 @@ identify_system_timezone(void) return resultbuf; /* - * Did not find the timezone. Fallback to use a GMT zone. Note that - * the zic timezone database names the GMT-offset zones in POSIX - * style: plus is west of Greenwich. It's unfortunate that this is - * opposite of SQL conventions. Should we therefore change the names? - * Probably not... + * Did not find the timezone. Fallback to use a GMT zone. Note that the + * zic timezone database names the GMT-offset zones in POSIX style: plus + * is west of Greenwich. It's unfortunate that this is opposite of SQL + * conventions. Should we therefore change the names? Probably not... */ snprintf(resultbuf, sizeof(resultbuf), "Etc/GMT%s%d", (-std_ofs > 0) ? "+" : "", -std_ofs / 3600); ereport(LOG, - (errmsg("could not recognize system timezone, defaulting to \"%s\"", - resultbuf), - errhint("You can specify the correct timezone in postgresql.conf."))); + (errmsg("could not recognize system timezone, defaulting to \"%s\"", + resultbuf), + errhint("You can specify the correct timezone in postgresql.conf."))); return resultbuf; } @@ -409,7 +411,7 @@ identify_system_timezone(void) * score. bestzonename must be a buffer of length TZ_STRLEN_MAX + 1. */ static void -scan_available_timezones(char *tzdir, char *tzdirsub, struct tztry *tt, +scan_available_timezones(char *tzdir, char *tzdirsub, struct tztry * tt, int *bestscore, char *bestzonename) { int tzdir_orig_len = strlen(tzdir); @@ -477,7 +479,6 @@ scan_available_timezones(char *tzdir, char *tzdirsub, struct tztry *tt, FreeDir(dirdesc); } - #else /* WIN32 */ static const struct @@ -490,12 +491,11 @@ static const struct { /* * This list was built from the contents of the registry at - * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows - * NT\CurrentVersion\Time Zones on Windows XP Professional SP1 + * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time + * Zones on Windows XP Professional SP1 * * The zones have been matched to zic timezones by looking at the cities - * listed in the win32 display name (in the comment here) in most - * cases. + * listed in the win32 display name (in the comment here) in most cases. */ { "Afghanistan Standard Time", "Afghanistan Daylight Time", @@ -560,8 +560,8 @@ static const struct { "Central Europe Standard Time", "Central Europe Daylight Time", "Europe/Belgrade" - }, /* (GMT+01:00) Belgrade, Bratislava, - * Budapest, Ljubljana, Prague */ + }, /* (GMT+01:00) Belgrade, Bratislava, Budapest, + * Ljubljana, Prague */ { "Central European Standard Time", "Central European Daylight Time", "Europe/Sarajevo" @@ -579,13 +579,12 @@ static const struct { "China Standard Time", "China Daylight Time", "Asia/Hong_Kong" - }, /* (GMT+08:00) Beijing, Chongqing, Hong - * Kong, Urumqi */ + }, /* (GMT+08:00) Beijing, Chongqing, Hong Kong, + * Urumqi */ { "Dateline Standard Time", "Dateline Daylight Time", "Etc/GMT+12" - }, /* (GMT-12:00) International Date Line - * West */ + }, /* (GMT-12:00) International Date Line West */ { "E. Africa Standard Time", "E. Africa Daylight Time", "Africa/Nairobi" @@ -617,13 +616,12 @@ static const struct { "Fiji Standard Time", "Fiji Daylight Time", "Pacific/Fiji" - }, /* (GMT+12:00) Fiji, Kamchatka, Marshall - * Is. */ + }, /* (GMT+12:00) Fiji, Kamchatka, Marshall Is. */ { "FLE Standard Time", "FLE Daylight Time", "Europe/Helsinki" - }, /* (GMT+02:00) Helsinki, Kyiv, Riga, - * Sofia, Tallinn, Vilnius */ + }, /* (GMT+02:00) Helsinki, Kyiv, Riga, Sofia, + * Tallinn, Vilnius */ { "GMT Standard Time", "GMT Daylight Time", "Europe/Dublin" @@ -648,8 +646,8 @@ static const struct { "India Standard Time", "India Daylight Time", "Asia/Calcutta" - }, /* (GMT+05:30) Chennai, Kolkata, Mumbai, - * New Delhi */ + }, /* (GMT+05:30) Chennai, Kolkata, Mumbai, New + * Delhi */ { "Iran Standard Time", "Iran Daylight Time", "Asia/Tehran" @@ -719,8 +717,8 @@ static const struct { "Romance Standard Time", "Romance Daylight Time", "Europe/Brussels" - }, /* (GMT+01:00) Brussels, Copenhagen, - * Madrid, Paris */ + }, /* (GMT+01:00) Brussels, Copenhagen, Madrid, + * Paris */ { "Russian Standard Time", "Russian Daylight Time", "Europe/Moscow" @@ -791,18 +789,17 @@ static const struct "Australia/Perth" }, /* (GMT+08:00) Perth */ /* {"W. Central Africa Standard Time", "W. Central Africa Daylight Time", - * * ""}, Could not find a match for this one. Excluded for now. *//* ( + * * * ""}, Could not find a match for this one. Excluded for now. *//* ( * G MT+01:00) West Central Africa */ { "W. Europe Standard Time", "W. Europe Daylight Time", "CET" - }, /* (GMT+01:00) Amsterdam, Berlin, Bern, - * Rome, Stockholm, Vienna */ + }, /* (GMT+01:00) Amsterdam, Berlin, Bern, Rome, + * Stockholm, Vienna */ { "West Asia Standard Time", "West Asia Daylight Time", "Asia/Karachi" - }, /* (GMT+05:00) Islamabad, Karachi, - * Tashkent */ + }, /* (GMT+05:00) Islamabad, Karachi, Tashkent */ { "West Pacific Standard Time", "West Pacific Daylight Time", "Pacific/Guam" @@ -821,11 +818,11 @@ identify_system_timezone(void) { int i; char tzname[128]; - char localtzname[256]; + char localtzname[256]; time_t t = time(NULL); struct tm *tm = localtime(&t); - HKEY rootKey; - int idx; + HKEY rootKey; + int idx; if (!tm) { @@ -849,62 +846,62 @@ identify_system_timezone(void) } /* - * Localized Windows versions return localized names for the - * timezone. Scan the registry to find the English name, - * and then try matching against our table again. + * Localized Windows versions return localized names for the timezone. + * Scan the registry to find the English name, and then try matching + * against our table again. */ memset(localtzname, 0, sizeof(localtzname)); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", 0, KEY_READ, &rootKey) != ERROR_SUCCESS) { ereport(WARNING, - (errmsg_internal("could not open registry key to identify Windows timezone: %i", (int)GetLastError()))); + (errmsg_internal("could not open registry key to identify Windows timezone: %i", (int) GetLastError()))); return NULL; } - - for (idx = 0; ; idx++) - { - char keyname[256]; - char zonename[256]; - DWORD namesize; - FILETIME lastwrite; - HKEY key; - LONG r; - + + for (idx = 0;; idx++) + { + char keyname[256]; + char zonename[256]; + DWORD namesize; + FILETIME lastwrite; + HKEY key; + LONG r; + memset(keyname, 0, sizeof(keyname)); namesize = sizeof(keyname); - if ((r=RegEnumKeyEx(rootKey, - idx, - keyname, - &namesize, - NULL, - NULL, - NULL, - &lastwrite)) != ERROR_SUCCESS) + if ((r = RegEnumKeyEx(rootKey, + idx, + keyname, + &namesize, + NULL, + NULL, + NULL, + &lastwrite)) != ERROR_SUCCESS) { if (r == ERROR_NO_MORE_ITEMS) break; ereport(WARNING, - (errmsg_internal("could not enumerate registry subkeys to identify Windows timezone: %i", (int)r))); + (errmsg_internal("could not enumerate registry subkeys to identify Windows timezone: %i", (int) r))); break; } - if ((r=RegOpenKeyEx(rootKey,keyname,0,KEY_READ,&key)) != ERROR_SUCCESS) + if ((r = RegOpenKeyEx(rootKey, keyname, 0, KEY_READ, &key)) != ERROR_SUCCESS) { ereport(WARNING, - (errmsg_internal("could not open registry subkey to identify Windows timezone: %i", (int)r))); + (errmsg_internal("could not open registry subkey to identify Windows timezone: %i", (int) r))); break; } - + memset(zonename, 0, sizeof(zonename)); namesize = sizeof(zonename); - if ((r=RegQueryValueEx(key, "Std", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS) + if ((r = RegQueryValueEx(key, "Std", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS) { ereport(WARNING, - (errmsg_internal("could not query value for 'std' to identify Windows timezone: %i", (int)r))); + (errmsg_internal("could not query value for 'std' to identify Windows timezone: %i", (int) r))); RegCloseKey(key); break; } @@ -917,10 +914,10 @@ identify_system_timezone(void) } memset(zonename, 0, sizeof(zonename)); namesize = sizeof(zonename); - if ((r=RegQueryValueEx(key, "Dlt", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS) + if ((r = RegQueryValueEx(key, "Dlt", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS) { ereport(WARNING, - (errmsg_internal("could not query value for 'dlt' to identify Windows timezone: %i", (int)r))); + (errmsg_internal("could not query value for 'dlt' to identify Windows timezone: %i", (int) r))); RegCloseKey(key); break; } @@ -994,9 +991,9 @@ init_timezone_hashtable(void) struct pg_tz * pg_tzset(const char *name) { - pg_tz *tzp; - pg_tz tz; - + pg_tz *tzp; + pg_tz tz; + if (strlen(name) > TZ_STRLEN_MAX) return NULL; /* not going to fit */ @@ -1004,10 +1001,10 @@ pg_tzset(const char *name) if (!init_timezone_hashtable()) return NULL; - tzp = (pg_tz *)hash_search(timezone_cache, - name, - HASH_FIND, - NULL); + tzp = (pg_tz *) hash_search(timezone_cache, + name, + HASH_FIND, + NULL); if (tzp) { /* Timezone found in cache, nothing more to do */ @@ -1030,7 +1027,7 @@ pg_tzset(const char *name) name, HASH_ENTER, NULL); - + strcpy(tzp->TZname, tz.TZname); memcpy(&tzp->state, &tz.state, sizeof(tz.state)); @@ -1055,9 +1052,9 @@ tz_acceptable(pg_tz *tz) pg_time_t time2000; /* - * To detect leap-second timekeeping, run pg_localtime for what should - * be GMT midnight, 2000-01-01. Insist that the tm_sec value be zero; - * any other result has to be due to leap seconds. + * To detect leap-second timekeeping, run pg_localtime for what should be + * GMT midnight, 2000-01-01. Insist that the tm_sec value be zero; any + * other result has to be due to leap seconds. */ time2000 = (POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY; tt = pg_localtime(&time2000, tz); @@ -1074,11 +1071,11 @@ tz_acceptable(pg_tz *tz) static bool set_global_timezone(const char *tzname) { - pg_tz *tznew; + pg_tz *tznew; if (!tzname || !tzname[0]) return false; - + tznew = pg_tzset(tzname); if (!tznew) return false; diff --git a/src/timezone/pgtz.h b/src/timezone/pgtz.h index 986122efd35..5f681cee36d 100644 --- a/src/timezone/pgtz.h +++ b/src/timezone/pgtz.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/pgtz.h,v 1.14 2005/07/04 19:54:51 momjian Exp $ + * $PostgreSQL: pgsql/src/timezone/pgtz.h,v 1.15 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,18 +46,19 @@ struct state pg_time_t ats[TZ_MAX_TIMES]; unsigned char types[TZ_MAX_TIMES]; struct ttinfo ttis[TZ_MAX_TYPES]; - char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, 3 /* sizeof gmt */), + char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, 3 /* sizeof gmt */ ), (2 * (TZ_STRLEN_MAX + 1)))]; struct lsinfo lsis[TZ_MAX_LEAPS]; }; -struct pg_tz { - char TZname[TZ_STRLEN_MAX + 1]; +struct pg_tz +{ + char TZname[TZ_STRLEN_MAX + 1]; struct state state; }; -int tzload(const char *name, struct state * sp); -int tzparse(const char *name, struct state * sp, int lastditch); +int tzload(const char *name, struct state * sp); +int tzparse(const char *name, struct state * sp, int lastditch); #endif /* _PGTZ_H */ diff --git a/src/timezone/scheck.c b/src/timezone/scheck.c index 2849e8b6a76..218d2467d5e 100644 --- a/src/timezone/scheck.c +++ b/src/timezone/scheck.c @@ -3,7 +3,7 @@ * 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/scheck.c,v 1.6 2005/06/20 08:00:51 neilc Exp $ + * $PostgreSQL: pgsql/src/timezone/scheck.c,v 1.7 2005/10/15 02:49:51 momjian Exp $ */ #include "postgres.h" @@ -14,11 +14,11 @@ char * scheck(const char *string, const char *format) { - char *fbuf; + char *fbuf; const char *fp; - char *tp; - int c; - char *result; + char *tp; + int c; + char *result; char dummy; static char nada; diff --git a/src/timezone/strftime.c b/src/timezone/strftime.c index e5490319c6e..7068a56a268 100644 --- a/src/timezone/strftime.c +++ b/src/timezone/strftime.c @@ -15,7 +15,7 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/strftime.c,v 1.7 2005/06/20 08:00:51 neilc Exp $ + * $PostgreSQL: pgsql/src/timezone/strftime.c,v 1.8 2005/10/15 02:49:51 momjian Exp $ */ #include "postgres.h" @@ -73,9 +73,9 @@ static const struct lc_time_T C_time_locale = { /* * 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. + * 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", @@ -102,7 +102,7 @@ static char *_fmt(const char *, const struct pg_tm *, char *, size_t pg_strftime(char *s, size_t maxsize, const char *format, - const struct pg_tm *t) + const struct pg_tm * t) { char *p; int warn; @@ -116,7 +116,7 @@ pg_strftime(char *s, size_t maxsize, const char *format, } static char * -_fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, +_fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim, int *warnp) { for (; *format; ++format) @@ -185,9 +185,9 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *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 + * 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; @@ -211,11 +211,11 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, 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; @@ -231,11 +231,10 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, 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. (ado, - * 1993-05-24) + * 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) ? (t->tm_hour % 12) : 12, @@ -279,9 +278,9 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, 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, @@ -328,8 +327,8 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, DAYSPERNYEAR; /* - * What yday (-3 ... 3) does the ISO year - * begin on? + * What yday (-3 ... 3) does the ISO year begin + * on? */ bot = ((yday + 11 - wday) % DAYSPERWEEK) - 3; @@ -419,8 +418,8 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, 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': diff --git a/src/timezone/tzfile.h b/src/timezone/tzfile.h index 29096f7d796..0f447a543dc 100644 --- a/src/timezone/tzfile.h +++ b/src/timezone/tzfile.h @@ -6,7 +6,7 @@ * 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 $ + * $PostgreSQL: pgsql/src/timezone/tzfile.h,v 1.6 2005/10/15 02:49:51 momjian Exp $ */ /* @@ -34,10 +34,8 @@ struct tzhead { char tzh_magic[4]; /* TZ_MAGIC */ char tzh_reserved[16]; /* reserved for future use */ - char tzh_ttisgmtcnt[4]; /* coded number of trans. time - * flags */ - char tzh_ttisstdcnt[4]; /* coded number of trans. time - * flags */ + char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */ + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ char tzh_leapcnt[4]; /* coded number of leap seconds */ char tzh_timecnt[4]; /* coded number of transition times */ char tzh_typecnt[4]; /* coded number of local time types */ @@ -83,15 +81,12 @@ struct tzhead */ #define TZ_MAX_TIMES 370 -#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can - * hold */ +#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ -#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation - * characters */ +#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ /* (limited by what unsigned chars can hold) */ -#define TZ_MAX_LEAPS 50 /* Maximum number of leap second - * corrections */ +#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ #define SECSPERMIN 60 #define MINSPERHOUR 60 diff --git a/src/timezone/zic.c b/src/timezone/zic.c index 4bb14bfca48..8ef425367fc 100644 --- a/src/timezone/zic.c +++ b/src/timezone/zic.c @@ -3,7 +3,7 @@ * 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/zic.c,v 1.15 2005/06/20 08:00:51 neilc Exp $ + * $PostgreSQL: pgsql/src/timezone/zic.c,v 1.16 2005/10/15 02:49:51 momjian Exp $ */ #include "postgres.h" @@ -134,11 +134,11 @@ static char *memcheck(char *tocheck); static int mkdirs(char *filename); static void newabbr(const char *abbr); static long oadd(long t1, long t2); -static void outzone(const struct zone *zp, int ntzones); +static void outzone(const struct zone * zp, int ntzones); static void puttzcode(long code, FILE *fp); static int rcomp(const void *leftp, const void *rightp); -static pg_time_t rpytime(const struct rule *rp, int wantedy); -static void rulesub(struct rule *rp, +static pg_time_t rpytime(const struct rule * rp, int wantedy); +static void rulesub(struct rule * rp, const char *loyearp, const char *hiyearp, const char *typep, const char *monthp, const char *dayp, const char *timep); @@ -408,8 +408,8 @@ static void 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); @@ -450,9 +450,9 @@ static int sflag = FALSE; int main(int argc, char *argv[]) { - int i; - int j; - int c; + int i; + int j; + int c; #ifndef WIN32 (void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH)); @@ -475,7 +475,7 @@ main(int argc, char *argv[]) else { (void) fprintf(stderr, - _("%s: More than one -d option specified\n"), + _("%s: More than one -d option specified\n"), progname); (void) exit(EXIT_FAILURE); } @@ -486,7 +486,7 @@ main(int argc, char *argv[]) else { (void) fprintf(stderr, - _("%s: More than one -l option specified\n"), + _("%s: More than one -l option specified\n"), progname); (void) exit(EXIT_FAILURE); } @@ -497,7 +497,7 @@ main(int argc, char *argv[]) else { (void) fprintf(stderr, - _("%s: More than one -p option specified\n"), + _("%s: More than one -p option specified\n"), progname); (void) exit(EXIT_FAILURE); } @@ -508,7 +508,7 @@ main(int argc, char *argv[]) else { (void) fprintf(stderr, - _("%s: More than one -y option specified\n"), + _("%s: More than one -y option specified\n"), progname); (void) exit(EXIT_FAILURE); } @@ -519,7 +519,7 @@ main(int argc, char *argv[]) else { (void) fprintf(stderr, - _("%s: More than one -L option specified\n"), + _("%s: More than one -L option specified\n"), progname); (void) exit(EXIT_FAILURE); } @@ -585,8 +585,8 @@ main(int argc, char *argv[]) static void dolink(const char *fromfile, const char *tofile) { - char *fromname; - char *toname; + char *fromname; + char *toname; if (fromfile[0] == '/') fromname = ecpyalloc(fromfile); @@ -606,8 +606,8 @@ dolink(const char *fromfile, const char *tofile) } /* - * We get to be careful here since there's a fair chance of root - * running us. + * We get to be careful here since there's a fair chance of root running + * us. */ if (!itsdir(toname)) (void) remove(toname); @@ -625,7 +625,7 @@ dolink(const char *fromfile, const char *tofile) !itsdir(fromname)) { const char *s = tofile; - char *symlinkcontents = NULL; + char *symlinkcontents = NULL; while ((s = strchr(s + 1, '/')) != NULL) symlinkcontents = ecatalloc(symlinkcontents, "../"); @@ -695,8 +695,8 @@ setboundaries(void) static int itsdir(const char *name) { - char *myname; - int accres; + char *myname; + int accres; myname = ecpyalloc(name); myname = ecatalloc(myname, "/."); @@ -725,10 +725,10 @@ associate(void) { struct zone *zp; struct rule *rp; - int base, - out; - int i, - j; + int base, + out; + int i, + j; if (nrules != 0) { @@ -796,8 +796,8 @@ associate(void) TRUE); /* - * Note, though, that if there's no rule, a '%s' in the format - * is a bad thing. + * Note, though, that if there's no rule, a '%s' in the format is + * a bad thing. */ if (strchr(zp->z_format, '%') != 0) error(_("%s in ruleless zone")); @@ -810,13 +810,13 @@ associate(void) static void infile(const char *name) { - FILE *fp; - char **fields; - char *cp; + FILE *fp; + char **fields; + char *cp; const struct lookup *lp; - int nfields; - int wantcont; - int num; + int nfields; + int wantcont; + int num; char buf[BUFSIZ]; if (strcmp(name, "-") == 0) @@ -883,7 +883,7 @@ infile(const char *name) case LC_LEAP: if (name != leapsec) (void) fprintf(stderr, - _("%s: Leap line in non leap seconds file %s\n"), + _("%s: Leap line in non leap seconds file %s\n"), progname, name); else inleap(fields, nfields); @@ -891,7 +891,7 @@ infile(const char *name) break; default: /* "cannot happen" */ (void) fprintf(stderr, - _("%s: panic: Invalid l_value %d\n"), + _("%s: panic: Invalid l_value %d\n"), progname, lp->l_value); (void) exit(EXIT_FAILURE); } @@ -991,14 +991,14 @@ inrule(char **fields, int nfields) r.r_name = ecpyalloc(fields[RF_NAME]); r.r_abbrvar = ecpyalloc(fields[RF_ABBRVAR]); rules = (struct rule *) (void *) erealloc((char *) rules, - (int) ((nrules + 1) * sizeof *rules)); + (int) ((nrules + 1) * sizeof *rules)); rules[nrules++] = r; } static int inzone(char **fields, int nfields) { - int i; + int i; static char *buf; if (nfields < ZONE_MINFIELDS || nfields > ZONE_MAXFIELDS) @@ -1010,7 +1010,7 @@ inzone(char **fields, int nfields) { buf = erealloc(buf, (int) (132 + strlen(TZDEFAULT))); (void) sprintf(buf, - _("\"Zone %s\" line and -l option are mutually exclusive"), + _("\"Zone %s\" line and -l option are mutually exclusive"), TZDEFAULT); error(buf); return FALSE; @@ -1019,7 +1019,7 @@ inzone(char **fields, int nfields) { buf = erealloc(buf, (int) (132 + strlen(TZDEFRULES))); (void) sprintf(buf, - _("\"Zone %s\" line and -p option are mutually exclusive"), + _("\"Zone %s\" line and -p option are mutually exclusive"), TZDEFRULES); error(buf); return FALSE; @@ -1032,7 +1032,7 @@ inzone(char **fields, int nfields) strlen(fields[ZF_NAME]) + strlen(zones[i].z_filename))); (void) sprintf(buf, - _("duplicate zone name %s (file \"%s\", line %d)"), + _("duplicate zone name %s (file \"%s\", line %d)"), fields[ZF_NAME], zones[i].z_filename, zones[i].z_linenum); @@ -1056,16 +1056,16 @@ inzcont(char **fields, int nfields) static int inzsub(char **fields, int nfields, int iscont) { - char *cp; + char *cp; static struct zone z; - int i_gmtoff, - i_rule, - i_format; - int i_untilyear, - i_untilmonth; - int i_untilday, - i_untiltime; - int hasuntil; + int i_gmtoff, + i_rule, + i_format; + int i_untilyear, + i_untilmonth; + int i_untilday, + i_untiltime; + int hasuntil; if (iscont) { @@ -1129,7 +1129,7 @@ inzsub(char **fields, int nfields, int iscont) } } zones = (struct zone *) (void *) erealloc((char *) zones, - (int) ((nzones + 1) * sizeof *zones)); + (int) ((nzones + 1) * sizeof *zones)); zones[nzones++] = z; /* @@ -1281,19 +1281,19 @@ inlink(char **fields, int nfields) l.l_from = ecpyalloc(fields[LF_FROM]); l.l_to = ecpyalloc(fields[LF_TO]); links = (struct link *) (void *) erealloc((char *) links, - (int) ((nlinks + 1) * sizeof *links)); + (int) ((nlinks + 1) * sizeof *links)); links[nlinks++] = l; } static void -rulesub(struct rule *rp, const char *loyearp, const char *hiyearp, +rulesub(struct rule * rp, const char *loyearp, const char *hiyearp, const char *typep, const char *monthp, const char *dayp, const char *timep) { const struct lookup *lp; const char *cp; - char *dp; - char *ep; + char *dp; + char *ep; if ((lp = byword(monthp, mon_names)) == NULL) { @@ -1466,8 +1466,8 @@ rulesub(struct rule *rp, const char *loyearp, const char *hiyearp, static void convert(long val, char *buf) { - int i; - long shift; + int i; + long shift; for (i = 0, shift = 24; i < 4; ++i, shift -= 8) buf[i] = val >> shift; @@ -1496,9 +1496,9 @@ atcomp(const void *avp, const void *bvp) static void writezone(const char *name) { - FILE *fp; - int i, - j; + FILE *fp; + int i, + j; static char *fullname; static struct tzhead tzh; pg_time_t ats[TZ_MAX_TIMES]; @@ -1679,23 +1679,23 @@ doabbr(char *abbr, const char *format, const char *letters, int isdst) } static void -outzone(const struct zone *zpfirst, int zonecount) +outzone(const struct zone * zpfirst, int zonecount) { const struct zone *zp; struct rule *rp; - int i, - j; - int usestart, - useuntil; - pg_time_t starttime = 0; - pg_time_t untiltime = 0; - long gmtoff; - long stdoff; - int year; - long startoff; - int startttisstd; - int startttisgmt; - int type; + int i, + j; + int usestart, + useuntil; + pg_time_t starttime = 0; + pg_time_t untiltime = 0; + long gmtoff; + long stdoff; + int year; + long startoff; + int startttisstd; + int startttisgmt; + int type; char startbuf[BUFSIZ]; /* @@ -1706,8 +1706,8 @@ outzone(const struct zone *zpfirst, int zonecount) charcnt = 0; /* - * Thanks to Earl Chew (earl@dnd.icp.nec.com.au) for noting the need - * to unconditionally initialize startttisstd. + * Thanks to Earl Chew (earl@dnd.icp.nec.com.au) for noting the need to + * unconditionally initialize startttisstd. */ startttisstd = FALSE; startttisgmt = FALSE; @@ -1749,8 +1749,8 @@ outzone(const struct zone *zpfirst, int zonecount) break; /* - * Mark which rules to do in the current year. For those - * to do, calculate rpytime(rp, year); + * 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) { @@ -1765,16 +1765,17 @@ outzone(const struct zone *zpfirst, int zonecount) } for (;;) { - int k; - pg_time_t jtime, ktime = 0; - long offset; + int k; + pg_time_t jtime, + ktime = 0; + long offset; char buf[BUFSIZ]; 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) @@ -1917,8 +1918,8 @@ static int addtype(long gmtoff, const char *abbr, int isdst, int ttisstd, int ttisgmt) { - int i; - int j; + int i; + int j; if (isdst != TRUE && isdst != FALSE) { @@ -1937,8 +1938,8 @@ addtype(long gmtoff, const char *abbr, int isdst, } /* - * See if there's already an entry for this zone type. If so, just - * return its index. + * See if there's already an entry for this zone type. If so, just return + * its index. */ for (i = 0; i < typecnt; ++i) { @@ -1975,8 +1976,8 @@ addtype(long gmtoff, const char *abbr, int isdst, static void leapadd(const pg_time_t t, int positive, int rolling, int count) { - int i; - int j; + int i; + int j; if (leapcnt + (positive ? count : 1) > TZ_MAX_LEAPS) { @@ -2011,8 +2012,8 @@ leapadd(const pg_time_t t, int positive, int rolling, int count) static void adjleap(void) { - int i; - long last = 0; + int i; + long last = 0; /* * propagate leap seconds forward @@ -2082,7 +2083,7 @@ itsabbr(const char *abbr, const char *word) } static const struct lookup * -byword(const char *word, const struct lookup *table) +byword(const char *word, const struct lookup * table) { const struct lookup *foundlp; const struct lookup *lp; @@ -2115,9 +2116,9 @@ byword(const char *word, const struct lookup *table) static char ** getfields(char *cp) { - char *dp; - char **array; - int nsubs; + char *dp; + char **array; + int nsubs; if (cp == NULL) return NULL; @@ -2154,7 +2155,7 @@ getfields(char *cp) static long oadd(long t1, long t2) { - long t; + long t; t = t1 + t2; if ((t2 > 0 && t <= t1) || (t2 < 0 && t >= t1)) @@ -2168,7 +2169,7 @@ oadd(long t1, long t2) static pg_time_t tadd(const pg_time_t t1, long t2) { - pg_time_t t; + pg_time_t t; if (t1 == max_time && t2 > 0) return max_time; @@ -2189,13 +2190,13 @@ tadd(const pg_time_t t1, long t2) */ static pg_time_t -rpytime(const struct rule *rp, int wantedy) +rpytime(const struct rule * rp, int wantedy) { - int y, - m, - i; - long dayoff; /* with a nod to Margaret O. */ - pg_time_t t; + int y, + m, + i; + long dayoff; /* with a nod to Margaret O. */ + pg_time_t t; if (wantedy == INT_MIN) return min_time; @@ -2239,7 +2240,7 @@ rpytime(const struct rule *rp, int wantedy) dayoff = oadd(dayoff, eitol(i)); if (rp->r_dycode == DC_DOWGEQ || rp->r_dycode == DC_DOWLEQ) { - long wday; + long wday; #define LDAYSPERWEEK ((long) DAYSPERWEEK) wday = eitol(EPOCH_WDAY); @@ -2288,7 +2289,7 @@ rpytime(const struct rule *rp, int wantedy) static void newabbr(const char *string) { - int i; + int i; i = strlen(string) + 1; if (charcnt + i > TZ_MAX_CHARS) @@ -2303,8 +2304,8 @@ newabbr(const char *string) static int mkdirs(char *argname) { - char *name; - char *cp; + char *name; + char *cp; if (argname == NULL || *argname == '\0') return 0; @@ -2327,9 +2328,9 @@ mkdirs(char *argname) 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 checking. + * 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) { @@ -2338,7 +2339,7 @@ mkdirs(char *argname) if (errno != EEXIST || !itsdir(name)) { (void) fprintf(stderr, - _("%s: Can't create directory %s: %s\n"), + _("%s: Can't create directory %s: %s\n"), progname, name, e); ifree(name); return -1; |