From 9827ca52b9f69d29f3bc3c74a8ca95e14ee226ff Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Mon, 9 Jan 2012 14:43:35 -0500 Subject: [PATCH] Clean up time handling; always assume we have tzset() and that the right prototypes are in time.h (both are valid in POSIX). --- configure.ac | 16 ++-------------- sbr/dtime.c | 33 ++------------------------------- 2 files changed, 4 insertions(+), 45 deletions(-) diff --git a/configure.ac b/configure.ac index 5ff1829..0df49ba 100644 --- a/configure.ac +++ b/configure.ac @@ -462,7 +462,6 @@ esac AC_SUBST(OURDEFS) AC_HEADER_STDC -AC_HEADER_TIME AC_HEADER_TIOCGWINSZ AC_CHECK_HEADERS(errno.h fcntl.h crypt.h termcap.h \ langinfo.h wchar.h wctype.h iconv.h netdb.h \ @@ -487,7 +486,7 @@ AC_CHECK_HEADER([sys/ptem.h], AC_DEFINE(WINSIZE_IN_PTEM,1, dnl --------------- dnl CHECK FUNCTIONS dnl --------------- -AC_CHECK_FUNCS(writev lstat tzset getutent nl_langinfo) +AC_CHECK_FUNCS(writev lstat getutent nl_langinfo) dnl Check for multibyte character set support if test "x$ac_cv_header_wchar_h" = "xyes" -a "x$ac_cv_header_wctype_h" = "xyes" \ @@ -744,18 +743,7 @@ dnl ---------------- dnl CHECK STRUCTURES dnl ---------------- -AC_CHECK_MEMBERS(struct tm.tm_gmtoff,,, - [#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef TM_IN_SYS_TIME -# include -# else -# include -# endif -#endif]) - +AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include ]) AC_CHECK_MEMBERS(struct utmp.ut_type,,,[#include ]) AC_STRUCT_DIRENT_D_TYPE diff --git a/sbr/dtime.c b/sbr/dtime.c index 2e978d7..5d5375d 100644 --- a/sbr/dtime.c +++ b/sbr/dtime.c @@ -10,23 +10,9 @@ #include /* for snprintf() */ #include #include +#include -#if !defined(HAVE_STRUCT_TM_TM_GMTOFF) && !defined(HAVE_TZSET) -# include -#endif - -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#if !defined(HAVE_STRUCT_TM_TM_GMTOFF) && defined(HAVE_TZSET) +#if !defined(HAVE_STRUCT_TM_TM_GMTOFF) extern int daylight; extern long timezone; extern char *tzname[]; @@ -140,10 +126,6 @@ dlocaltime (time_t *clock) static struct tws tw; struct tm *tm; -#if !defined(HAVE_STRUCT_TM_TM_GMTOFF) && !defined(HAVE_TZSET) - struct timeb tb; -#endif - if (!clock) return NULL; @@ -172,13 +154,8 @@ dlocaltime (time_t *clock) if (tm->tm_isdst) /* if DST is in effect */ tw.tw_zone -= 60; /* reset to normal offset */ #else -# ifdef HAVE_TZSET tzset(); tw.tw_zone = -(timezone / 60); -# else - ftime (&tb); - tw.tw_zone = -tb.timezone; -# endif #endif tw.tw_flags &= ~TW_SDAY; @@ -368,14 +345,8 @@ dtimezone (int offset, int flags) } if (!(flags & TW_ZONE) && mins == 0) { -#if defined(HAVE_TZSET) && defined(HAVE_TZNAME) tzset(); return ((flags & TW_DST) ? tzname[1] : tzname[0]); -#else - for (z = zones; z->std; z++) - if (z->shift == hours) - return (z->dst && (flags & TW_DST) ? z->dst : z->std); -#endif } #ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST -- 1.7.10.4