diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-09-22 00:04:21 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-09-22 00:04:21 -0400 |
commit | 3876b16ce3f30fcd8e10738d4449f8c51a695b17 (patch) | |
tree | 14f9d9304da277ce1eeefa111a3ec55a1df76631 /src/timezone/strftime.c | |
parent | a2b1eb23496e9abd695036e3cbb1d39c05618692 (diff) | |
download | postgresql-3876b16ce3f30fcd8e10738d4449f8c51a695b17.tar.gz postgresql-3876b16ce3f30fcd8e10738d4449f8c51a695b17.zip |
Sync our copy of the timezone library with IANA tzcode master.
This patch absorbs a few unreleased fixes in the IANA code.
It corresponds to commit 2d8b944c1cec0808ac4f7a9ee1a463c28f9cd00a
in https://github.com/eggert/tz. Non-cosmetic changes include:
TZDEFRULESTRING is updated to match current US DST practice,
rather than what it was over ten years ago. This only matters
for interpretation of POSIX-style zone names (e.g., "EST5EDT"),
and only if the timezone database doesn't include either an exact
match for the zone name or a "posixrules" entry. The latter
should not be true in any current Postgres installation, but
this could possibly matter when using --with-system-tzdata.
Get rid of a nonportable use of "++var" on a bool var.
This is part of a larger fix that eliminates some vestigial
support for consecutive leap seconds, and adds checks to
the "zic" compiler that the data files do not specify that.
Remove a couple of ancient compatibility hacks. The IANA
crew think these are obsolete, and I tend to agree. But
perhaps our buildfarm will think different.
Back-patch to all supported branches, in line with our policy
that all branches should be using current IANA code. Before v10,
this includes application of current pgindent rules, to avoid
whitespace problems in future back-patches.
Discussion: https://postgr.es/m/E1dsWhf-0000pT-F9@gemulon.postgresql.org
Diffstat (limited to 'src/timezone/strftime.c')
-rw-r--r-- | src/timezone/strftime.c | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/src/timezone/strftime.c b/src/timezone/strftime.c index 7cbafc9d834..e1c64834430 100644 --- a/src/timezone/strftime.c +++ b/src/timezone/strftime.c @@ -82,17 +82,17 @@ static const struct lc_time_T C_time_locale = { /* * x_fmt * - * C99 requires this format. Using just numbers (as here) makes Quakers - * happier; it's also compatible with SVR4. + * C99 and later require 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. + * C99 and later require 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", @@ -106,26 +106,25 @@ static const struct lc_time_T C_time_locale = { "%a %b %e %H:%M:%S %Z %Y" }; +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 *, int *); +static char *_fmt(const char *, const struct pg_tm *, char *, const char *, + enum warn *); static char *_yconv(int, int, bool, bool, char *, const char *); -#define IN_NONE 0 -#define IN_SOME 1 -#define IN_THIS 2 -#define IN_ALL 3 - size_t pg_strftime(char *s, size_t maxsize, const char *format, const struct pg_tm *t) { char *p; - int warn; + enum warn warn = IN_NONE; - warn = IN_NONE; p = _fmt(format, t, s, s + maxsize, &warn); if (p == s + maxsize) return 0; @@ -134,8 +133,8 @@ 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, - int *warnp) +_fmt(const char *format, const struct pg_tm *t, char *pt, + const char *ptlim, enum warn *warnp) { for (; *format; ++format) { @@ -184,7 +183,7 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, continue; case 'c': { - int warn2 = IN_SOME; + enum warn warn2 = IN_SOME; pt = _fmt(Locale->c_fmt, t, pt, ptlim, &warn2); if (warn2 == IN_ALL) @@ -203,9 +202,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 + * Locale modifiers of C99 and later. 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; @@ -417,7 +416,7 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, continue; case 'x': { - int warn2 = IN_SOME; + enum warn warn2 = IN_SOME; pt = _fmt(Locale->x_fmt, t, pt, ptlim, &warn2); if (warn2 == IN_ALL) @@ -442,8 +441,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 and later say that %Z must be replaced by the empty + * string if the time zone is not determinable. */ continue; case 'z': |