Consistently use named parameters in timezone code.
authorPeter Geoghegan
Mon, 19 Sep 2022 22:13:42 +0000 (15:13 -0700)
committerPeter Geoghegan
Mon, 19 Sep 2022 22:13:42 +0000 (15:13 -0700)
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 
Reviewed-By: David Rowley
Discussion: https://postgr.es/m/CAH2-WznJt9CMM9KJTMjJh_zbL5hD9oX44qdJ4aqZtjFi-zA3Tg@mail.gmail.com

src/timezone/localtime.c
src/timezone/pgtz.c
src/timezone/strftime.c
src/timezone/zic.c

index fa3c059038c40778627ac018f738f52ee020b6af..ad83c7ee5e09e23e0eeacc325b72dc4f6a76ef5b 100644 (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);
 
 
 /*
index 72f9e3d5e6cc832243a062668a156b3c861b15e1..40096ed792e8470ee7020b69e9ffdff802f3125b 100644 (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,
index dd6c7db869580f0257b1875313318db497c10726..9247a34157f78eae7332ec45ab004237b91aff2a 100644 (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);
 
 
 /*
index 0ea6ead2db3ae2c9f4a99d60191af201266ec027..d6c51419232b0f9187971419852135b969c57830 100644 (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},