Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c4f8e89

Browse files
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
1 parent bc2187e commit c4f8e89

File tree

4 files changed

+36
-32
lines changed

4 files changed

+36
-32
lines changed

src/timezone/localtime.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,15 @@ struct rule
8282
* Prototypes for static functions.
8383
*/
8484

85-
static struct pg_tm *gmtsub(pg_time_t const *, int32, struct pg_tm *);
86-
static bool increment_overflow(int *, int);
87-
static bool increment_overflow_time(pg_time_t *, int32);
88-
static int64 leapcorr(struct state const *, pg_time_t);
89-
static struct pg_tm *timesub(pg_time_t const *, int32, struct state const *,
90-
struct pg_tm *);
91-
static bool typesequiv(struct state const *, int, int);
85+
static struct pg_tm *gmtsub(pg_time_t const *timep, int32 offset,
86+
struct pg_tm *tmp);
87+
static bool increment_overflow(int *ip, int j);
88+
static bool increment_overflow_time(pg_time_t *tp, int32 j);
89+
static int64 leapcorr(struct state const *sp, pg_time_t t);
90+
static struct pg_tm *timesub(pg_time_t const *timep,
91+
int32 offset, struct state const *sp,
92+
struct pg_tm *tmp);
93+
static bool typesequiv(struct state const *sp, int a, int b);
9294

9395

9496
/*

src/timezone/pgtz.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,15 @@ init_timezone_hashtable(void)
232232
* default timezone setting is later overridden from postgresql.conf.
233233
*/
234234
pg_tz *
235-
pg_tzset(const char *name)
235+
pg_tzset(const char *tzname)
236236
{
237237
pg_tz_cache *tzp;
238238
struct state tzstate;
239239
char uppername[TZ_STRLEN_MAX + 1];
240240
char canonname[TZ_STRLEN_MAX + 1];
241241
char *p;
242242

243-
if (strlen(name) > TZ_STRLEN_MAX)
243+
if (strlen(tzname) > TZ_STRLEN_MAX)
244244
return NULL; /* not going to fit */
245245

246246
if (!timezone_cache)
@@ -254,8 +254,8 @@ pg_tzset(const char *name)
254254
* a POSIX-style timezone spec.)
255255
*/
256256
p = uppername;
257-
while (*name)
258-
*p++ = pg_toupper((unsigned char) *name++);
257+
while (*tzname)
258+
*p++ = pg_toupper((unsigned char) *tzname++);
259259
*p = '\0';
260260

261261
tzp = (pg_tz_cache *) hash_search(timezone_cache,

src/timezone/strftime.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ enum warn
111111
IN_NONE, IN_SOME, IN_THIS, IN_ALL
112112
};
113113

114-
static char *_add(const char *, char *, const char *);
115-
static char *_conv(int, const char *, char *, const char *);
116-
static char *_fmt(const char *, const struct pg_tm *, char *, const char *,
117-
enum warn *);
118-
static char *_yconv(int, int, bool, bool, char *, char const *);
114+
static char *_add(const char *str, char *pt, const char *ptlim);
115+
static char *_conv(int n, const char *format, char *pt, const char *ptlim);
116+
static char *_fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim,
117+
enum warn *warnp);
118+
static char *_yconv(int a, int b, bool convert_top, bool convert_yy, char *pt, char const *ptlim);
119119

120120

121121
/*

src/timezone/zic.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,30 +123,32 @@ static void error(const char *string,...) pg_attribute_printf(1, 2);
123123
static void warning(const char *string,...) pg_attribute_printf(1, 2);
124124
static void usage(FILE *stream, int status) pg_attribute_noreturn();
125125
static void addtt(zic_t starttime, int type);
126-
static int addtype(zic_t, char const *, bool, bool, bool);
127-
static void leapadd(zic_t, int, int);
126+
static int addtype(zic_t utoff, char const *abbr,
127+
bool isdst, bool ttisstd, bool ttisut);
128+
static void leapadd(zic_t t, int correction, int rolling);
128129
static void adjleap(void);
129130
static void associate(void);
130-
static void dolink(const char *, const char *, bool);
131-
static char **getfields(char *buf);
131+
static void dolink(char const *target, char const *linkname,
132+
bool staysymlink);
133+
static char **getfields(char *cp);
132134
static zic_t gethms(const char *string, const char *errstring);
133-
static zic_t getsave(char *, bool *);
134-
static void inexpires(char **, int);
135-
static void infile(const char *filename);
135+
static zic_t getsave(char *field, bool *isdst);
136+
static void inexpires(char **fields, int nfields);
137+
static void infile(const char *name);
136138
static void inleap(char **fields, int nfields);
137139
static void inlink(char **fields, int nfields);
138140
static void inrule(char **fields, int nfields);
139141
static bool inzcont(char **fields, int nfields);
140142
static bool inzone(char **fields, int nfields);
141-
static bool inzsub(char **, int, bool);
142-
static bool itsdir(char const *);
143-
static bool itssymlink(char const *);
143+
static bool inzsub(char **fields, int nfields, bool iscont);
144+
static bool itsdir(char const *name);
145+
static bool itssymlink(char const *name);
144146
static bool is_alpha(char a);
145-
static char lowerit(char);
146-
static void mkdirs(char const *, bool);
147-
static void newabbr(const char *abbr);
147+
static char lowerit(char a);
148+
static void mkdirs(char const *argname, bool ancestors);
149+
static void newabbr(const char *string);
148150
static zic_t oadd(zic_t t1, zic_t t2);
149-
static void outzone(const struct zone *zp, ptrdiff_t ntzones);
151+
static void outzone(const struct zone *zpfirst, ptrdiff_t zonecount);
150152
static zic_t rpytime(const struct rule *rp, zic_t wantedy);
151153
static void rulesub(struct rule *rp,
152154
const char *loyearp, const char *hiyearp,
@@ -304,8 +306,8 @@ struct lookup
304306
const int l_value;
305307
};
306308

307-
static struct lookup const *byword(const char *string,
308-
const struct lookup *lp);
309+
static struct lookup const *byword(const char *word,
310+
const struct lookup *table);
309311

310312
static struct lookup const zi_line_codes[] = {
311313
{"Rule", LC_RULE},

0 commit comments

Comments
 (0)