Consistently use named parameters in timezone code.

Make our copy of the IANA timezone library use named parameters in
function declarations.  Also make sure that parameter names from each
function's declaration match corresponding definition parameter names.

This makes the timezone code follow Postgres coding standards.  The
value of having a consistent standard everywhere seems to outweigh the
cost of keeping the function declarations in sync with future IANA
releases.

Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAH2-WznJt9CMM9KJTMjJh_zbL5hD9oX44qdJ4aqZtjFi-zA3Tg@mail.gmail.com
This commit is contained in:
Peter Geoghegan 2022-09-19 15:13:42 -07:00
parent bc2187ed63
commit c4f8e89fef
4 changed files with 36 additions and 32 deletions

View File

@ -82,13 +82,15 @@ struct rule
* Prototypes for static functions.
*/
static struct pg_tm *gmtsub(pg_time_t const *, int32, struct pg_tm *);
static bool increment_overflow(int *, int);
static bool increment_overflow_time(pg_time_t *, int32);
static int64 leapcorr(struct state const *, pg_time_t);
static struct pg_tm *timesub(pg_time_t const *, int32, struct state const *,
struct pg_tm *);
static bool typesequiv(struct state const *, int, int);
static struct pg_tm *gmtsub(pg_time_t const *timep, int32 offset,
struct pg_tm *tmp);
static bool increment_overflow(int *ip, int j);
static bool increment_overflow_time(pg_time_t *tp, int32 j);
static int64 leapcorr(struct state const *sp, pg_time_t t);
static struct pg_tm *timesub(pg_time_t const *timep,
int32 offset, struct state const *sp,
struct pg_tm *tmp);
static bool typesequiv(struct state const *sp, int a, int b);
/*

View File

@ -232,7 +232,7 @@ init_timezone_hashtable(void)
* default timezone setting is later overridden from postgresql.conf.
*/
pg_tz *
pg_tzset(const char *name)
pg_tzset(const char *tzname)
{
pg_tz_cache *tzp;
struct state tzstate;
@ -240,7 +240,7 @@ pg_tzset(const char *name)
char canonname[TZ_STRLEN_MAX + 1];
char *p;
if (strlen(name) > TZ_STRLEN_MAX)
if (strlen(tzname) > TZ_STRLEN_MAX)
return NULL; /* not going to fit */
if (!timezone_cache)
@ -254,8 +254,8 @@ pg_tzset(const char *name)
* a POSIX-style timezone spec.)
*/
p = uppername;
while (*name)
*p++ = pg_toupper((unsigned char) *name++);
while (*tzname)
*p++ = pg_toupper((unsigned char) *tzname++);
*p = '\0';
tzp = (pg_tz_cache *) hash_search(timezone_cache,

View File

@ -111,11 +111,11 @@ enum warn
IN_NONE, IN_SOME, IN_THIS, IN_ALL
};
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 *,
enum warn *);
static char *_yconv(int, int, bool, bool, char *, char const *);
static char *_add(const char *str, char *pt, const char *ptlim);
static char *_conv(int n, const char *format, char *pt, const char *ptlim);
static char *_fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim,
enum warn *warnp);
static char *_yconv(int a, int b, bool convert_top, bool convert_yy, char *pt, char const *ptlim);
/*

View File

@ -123,30 +123,32 @@ static void error(const char *string,...) pg_attribute_printf(1, 2);
static void warning(const char *string,...) pg_attribute_printf(1, 2);
static void usage(FILE *stream, int status) pg_attribute_noreturn();
static void addtt(zic_t starttime, int type);
static int addtype(zic_t, char const *, bool, bool, bool);
static void leapadd(zic_t, int, int);
static int addtype(zic_t utoff, char const *abbr,
bool isdst, bool ttisstd, bool ttisut);
static void leapadd(zic_t t, int correction, int rolling);
static void adjleap(void);
static void associate(void);
static void dolink(const char *, const char *, bool);
static char **getfields(char *buf);
static void dolink(char const *target, char const *linkname,
bool staysymlink);
static char **getfields(char *cp);
static zic_t gethms(const char *string, const char *errstring);
static zic_t getsave(char *, bool *);
static void inexpires(char **, int);
static void infile(const char *filename);
static zic_t getsave(char *field, bool *isdst);
static void inexpires(char **fields, int nfields);
static void infile(const char *name);
static void inleap(char **fields, int nfields);
static void inlink(char **fields, int nfields);
static void inrule(char **fields, int nfields);
static bool inzcont(char **fields, int nfields);
static bool inzone(char **fields, int nfields);
static bool inzsub(char **, int, bool);
static bool itsdir(char const *);
static bool itssymlink(char const *);
static bool inzsub(char **fields, int nfields, bool iscont);
static bool itsdir(char const *name);
static bool itssymlink(char const *name);
static bool is_alpha(char a);
static char lowerit(char);
static void mkdirs(char const *, bool);
static void newabbr(const char *abbr);
static char lowerit(char a);
static void mkdirs(char const *argname, bool ancestors);
static void newabbr(const char *string);
static zic_t oadd(zic_t t1, zic_t t2);
static void outzone(const struct zone *zp, ptrdiff_t ntzones);
static void outzone(const struct zone *zpfirst, ptrdiff_t zonecount);
static zic_t rpytime(const struct rule *rp, zic_t wantedy);
static void rulesub(struct rule *rp,
const char *loyearp, const char *hiyearp,
@ -304,8 +306,8 @@ struct lookup
const int l_value;
};
static struct lookup const *byword(const char *string,
const struct lookup *lp);
static struct lookup const *byword(const char *word,
const struct lookup *table);
static struct lookup const zi_line_codes[] = {
{"Rule", LC_RULE},