aboutsummaryrefslogtreecommitdiff
path: root/lib/libarchive/archive_read_support_format_iso9660.c
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@FreeBSD.org>2008-02-19 06:02:01 +0000
committerTim Kientzle <kientzle@FreeBSD.org>2008-02-19 06:02:01 +0000
commit54c845efb96e62dde9172c305489d32122698e64 (patch)
treec14ec2fcf3c52567e63390350555da5856fda71a /lib/libarchive/archive_read_support_format_iso9660.c
parent334a6ee707ca05705b78e445cc099da72efb0fc3 (diff)
downloadsrc-54c845efb96e62dde9172c305489d32122698e64.tar.gz
src-54c845efb96e62dde9172c305489d32122698e64.zip
Someday I might forgive the standards bodies for omitting timegm().
Maybe. In the meantime, my workarounds for trying to coax UTC without timegm() are getting uglier and uglier. Apparently, some systems don't support setenv()/unsetenv(), so you can't set the TZ env var and hope thereby to coax mktime() into generating UTC. Without that, I don't see a really good alternative to just giving up and converting to localtime with mktime(). (I suppose I should research the Perl library approach for computing an inverse function to gmtime(); that might actually be simpler than this growing list of hacks.)
Notes
Notes: svn path=/head/; revision=176403
Diffstat (limited to 'lib/libarchive/archive_read_support_format_iso9660.c')
-rw-r--r--lib/libarchive/archive_read_support_format_iso9660.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/libarchive/archive_read_support_format_iso9660.c b/lib/libarchive/archive_read_support_format_iso9660.c
index 83e22875bded..80bac08af5f1 100644
--- a/lib/libarchive/archive_read_support_format_iso9660.c
+++ b/lib/libarchive/archive_read_support_format_iso9660.c
@@ -1064,24 +1064,28 @@ time_from_tm(struct tm *t)
if (t->tm_isdst)
t->tm_hour -= 1;
return (mktime(t)); /* Re-convert. */
-#else
- /*
- * If you don't have tm_gmtoff, let's try resetting the timezone
- * (yecch!).
- */
+#elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV) && defined(HAVE_TZSET)
+ /* No timegm() and no tm_gmtoff, let's try forcing mktime() to UTC. */
time_t ret;
char *tz;
+ /* Reset the timezone, remember the old one. */
tz = getenv("TZ");
setenv("TZ", "UTC 0", 1);
tzset();
+
ret = mktime(t);
+
+ /* Restore the previous timezone. */
if (tz)
setenv("TZ", tz, 1);
else
unsetenv("TZ");
tzset();
return ret;
+#else
+ /* <sigh> We have no choice but to use localtime instead of UTC. */
+ return (mktime(t));
#endif
}