aboutsummaryrefslogtreecommitdiffstats
path: root/smtpd/to.c
diff options
context:
space:
mode:
authorgilles <gilles@poolp.org>2016-05-22 13:16:26 +0200
committergilles <gilles@poolp.org>2016-05-22 13:16:26 +0200
commit3b954b75a577c14ba6c87b91cf002e5e10c6c7c5 (patch)
tree0d285a36d2e80fc54536b618ab5858c82d4eeaad /smtpd/to.c
parentMerge pull request #692 from obadz/tag-char-fixes (diff)
downloadOpenSMTPD-3b954b75a577c14ba6c87b91cf002e5e10c6c7c5.tar.xz
OpenSMTPD-3b954b75a577c14ba6c87b91cf002e5e10c6c7c5.zip
sync with OpenBSD:opensmtpd-201605221710
- use temporary variables to reduce changeset with portable
Diffstat (limited to 'smtpd/to.c')
-rw-r--r--smtpd/to.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/smtpd/to.c b/smtpd/to.c
index 5cc2da51..f8724203 100644
--- a/smtpd/to.c
+++ b/smtpd/to.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: to.c,v 1.26 2016/02/15 12:53:50 mpi Exp $ */
+/* $OpenBSD: to.c,v 1.27 2016/05/22 11:15:31 gilles Exp $ */
/*
* Copyright (c) 2009 Jacek Masiulaniec <jacekm@dobremiasto.net>
@@ -194,21 +194,26 @@ time_to_text(time_t when)
char *day[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
char *month[] = {"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
+ char *tz;
+ long offset;
lt = localtime(&when);
if (lt == NULL || when == 0)
fatalx("time_to_text: localtime");
+ offset = lt->tm_gmtoff;
+ tz = lt->tm_zone;
+
/* We do not use strftime because it is subject to locale substitution*/
if (!bsnprintf(buf, sizeof(buf),
"%s, %d %s %d %02d:%02d:%02d %c%02d%02d (%s)",
day[lt->tm_wday], lt->tm_mday, month[lt->tm_mon],
lt->tm_year + 1900,
lt->tm_hour, lt->tm_min, lt->tm_sec,
- lt->tm_gmtoff >= 0 ? '+' : '-',
- abs((int)lt->tm_gmtoff / 3600),
- abs((int)lt->tm_gmtoff % 3600) / 60,
- lt->tm_zone))
+ offset >= 0 ? '+' : '-',
+ abs((int)offset / 3600),
+ abs((int)offset % 3600) / 60,
+ tz))
fatalx("time_to_text: bsnprintf");
return buf;