aboutsummaryrefslogtreecommitdiff
path: root/src/timezone/strftime.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-10-16 21:40:16 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2020-10-16 21:40:16 -0400
commit38fac9c1f66b05eab01d83a06abbd644355fa56b (patch)
tree19d9146c8581dad493d11c02976a0fda5d6db177 /src/timezone/strftime.c
parent9c3032881e00eb92a6bb4fad966831881e9c3b41 (diff)
downloadpostgresql-38fac9c1f66b05eab01d83a06abbd644355fa56b.tar.gz
postgresql-38fac9c1f66b05eab01d83a06abbd644355fa56b.zip
Sync our copy of the timezone library with IANA release tzcode2020c.
This changes zic's default output format from "-b fat" to "-b slim". We were already using "slim" in v13/HEAD, so those branches drop the explicit -b switch in the Makefiles. Instead, add an explicit "-b fat" in v12 and before, so that we don't change the output file format in those branches. (This is perhaps excessively conservative, but we decided not to do so in a12079109, and I'll stick with that.) Other non-cosmetic changes are to drop support for zic's long-obsolete "-y" switch, and to ensure that strftime() does not change errno unless it fails. As usual with tzcode changes, back-patch to all supported branches.
Diffstat (limited to 'src/timezone/strftime.c')
-rw-r--r--src/timezone/strftime.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/timezone/strftime.c b/src/timezone/strftime.c
index 4b942c393a3..dd6c7db8695 100644
--- a/src/timezone/strftime.c
+++ b/src/timezone/strftime.c
@@ -128,12 +128,22 @@ size_t
pg_strftime(char *s, size_t maxsize, const char *format, const struct pg_tm *t)
{
char *p;
+ int saved_errno = errno;
enum warn warn = IN_NONE;
p = _fmt(format, t, s, s + maxsize, &warn);
+ if (!p)
+ {
+ errno = EOVERFLOW;
+ return 0;
+ }
if (p == s + maxsize)
+ {
+ errno = ERANGE;
return 0;
+ }
*p = '\0';
+ errno = saved_errno;
return p - s;
}