From 6195a89359453dc49064c8f7a28c02165d2cb972 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Tue, 27 Mar 2012 11:03:04 +0200 Subject: [PATCH] FreeBSD needs the HAVE_STRUCT_TM_TM_GMTOFF test. FreeBSD has a timezone() function, not a timezone global variable (that's visible with our default configuration). Undid most of 0e4bc6fa7fa8ad74a1c3e855411bdc0e63bc6a2e. Pulled in from nmh. Thanks to David Levine. --- configure.ac | 5 +++++ sbr/dtime.c | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/configure.ac b/configure.ac index f55a982..2595cff 100644 --- a/configure.ac +++ b/configure.ac @@ -533,6 +533,11 @@ dnl ---------------- dnl CHECK STRUCTURES dnl ---------------- +dnl For platforms such as FreeBSD that have tm_gmtoff in struct tm. +dnl (FreeBSD has a timezone() function but not a timezone global +dnl variable that is visible). +AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include ]) + AC_STRUCT_DIRENT_D_TYPE dnl Where is located? Needed as input for signames.awk diff --git a/sbr/dtime.c b/sbr/dtime.c index 5a73934..48e13db 100644 --- a/sbr/dtime.c +++ b/sbr/dtime.c @@ -11,6 +11,10 @@ #include #include +#if !defined(HAVE_STRUCT_TM_TM_GMTOFF) +extern long timezone; +#endif + #ifndef abs # define abs(a) (a >= 0 ? a : -a) #endif @@ -102,8 +106,14 @@ dlocaltime(time_t *clock) if (tm->tm_isdst) tw.tw_flags |= TW_DST; +#ifdef HAVE_STRUCT_TM_TM_GMTOFF + tw.tw_zone = tm->tm_gmtoff / 60; + if (tm->tm_isdst) /* if DST is in effect */ + tw.tw_zone -= 60; /* reset to normal offset */ +#else tzset(); tw.tw_zone = -(timezone / 60); +#endif tw.tw_flags &= ~TW_SDAY; tw.tw_flags |= TW_SEXP; -- 1.7.10.4