summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2016-05-22 11:15:32 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2016-05-22 11:15:32 +0000
commit5f06ae6d434ca90bb47b67c178b5aec671e06a38 (patch)
tree574ca3f0827f0bf40ff56bec73b53cef49e8e569
parent6b057da7d4b6e7f5c05d7a43783451e64da24bec (diff)
use temporary variables to store some struct tm values, no functional
change but reduces the changeset with portable version
-rw-r--r--usr.sbin/smtpd/to.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.sbin/smtpd/to.c b/usr.sbin/smtpd/to.c
index 5cc2da51bb2..f8724203c55 100644
--- a/usr.sbin/smtpd/to.c
+++ b/usr.sbin/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;