From b69faecbeedaa31838483cfc102d72d4f319bb95 Mon Sep 17 00:00:00 2001 From: Adam Fedor Date: Thu, 4 Sep 2003 03:28:14 +0000 Subject: [PATCH] Use tzset to find timezone info. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17615 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Headers/Additions/GNUstepBase/config.h.in | 11 +++++++---- Source/NSTimeZone.m | 14 ++++++++++++++ configure | 3 ++- configure.ac | 2 +- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index f27beb097..606e4b83f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-09-02 Adam Fedor + + * configure.ac: Check for tzset + * Source/NSTimeZone.m (+systemTimeZone): Use it to find time zone + (as a last resort). + 2003-09-02 Adam Fedor * Tools/gdnc.m (main): Don't mess with file descriptors on MinGW. diff --git a/Headers/Additions/GNUstepBase/config.h.in b/Headers/Additions/GNUstepBase/config.h.in index e7d1406d1..d011322c1 100644 --- a/Headers/Additions/GNUstepBase/config.h.in +++ b/Headers/Additions/GNUstepBase/config.h.in @@ -6,7 +6,7 @@ /* Define if SO_REUSEADDR is broken on this system */ #undef BROKEN_SO_REUSEADDR -/* Define if your system terminates the final argument in /proc/28891/cmdline */ +/* Define if your system terminates the final argument in /proc/$$/cmdline */ #undef CMDLINE_TERMINATED /* Define if constructors are automatically loaded */ @@ -121,6 +121,9 @@ /* Define to 1 if you have the `mmap' function. */ #undef HAVE_MMAP +/* Define to 1 if you have the `nanosleep' function. */ +#undef HAVE_NANOSLEEP + /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H @@ -282,6 +285,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_TIME_H +/* Define to 1 if you have the `tzset' function. */ +#undef HAVE_TZSET + /* Define to 1 if you have the header file. */ #undef HAVE_UCBINCLUDE_SYS_RESOURCE_H @@ -291,9 +297,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H -/* Define to 1 if you have the `nanosleep' function. */ -#undef HAVE_NANOSLEEP - /* Define to 1 if you have the `usleep' function. */ #undef HAVE_USLEEP diff --git a/Source/NSTimeZone.m b/Source/NSTimeZone.m index dc39fbc4d..93a82dc25 100644 --- a/Source/NSTimeZone.m +++ b/Source/NSTimeZone.m @@ -54,6 +54,7 @@ #include #include #include +#include #include "Foundation/NSArray.h" #include "Foundation/NSCoder.h" #include "Foundation/NSData.h" @@ -1123,6 +1124,18 @@ static NSMapTable *absolutes = 0; localZoneString = [localZoneString stringByTrimmingSpaces]; } } +#if HAVE_TZSET + if (localZoneString == nil) + { + /* + * Try to get timezone from tzset and tzname + */ + extern char *tzname[2]; + tzset(); + if (tzname[0] != NULL && *tzname[0] != '\0') + localZoneString = [NSString stringWithCString: tzname[0]]; + } +#else if (localZoneString == nil) { /* @@ -1131,6 +1144,7 @@ static NSMapTable *absolutes = 0; localZoneString = [[[NSProcessInfo processInfo] environment] objectForKey: @"TZ"]; } +#endif if (localZoneString != nil) { zone = [defaultPlaceholderTimeZone initWithName: localZoneString]; diff --git a/configure b/configure index 4c7dfe67e..57e3321e7 100755 --- a/configure +++ b/configure @@ -8321,7 +8321,8 @@ done -for ac_func in time ctime + +for ac_func in time ctime tzset do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 diff --git a/configure.ac b/configure.ac index 7b8c79116..dc5e9167a 100644 --- a/configure.ac +++ b/configure.ac @@ -529,7 +529,7 @@ LIBS="$saved_LIBS" dnl AC_REPLACE_FUNCS(getrusage gettimeofday) AC_CHECK_HEADERS(time.h sys/time.h sys/rusage.h ucbinclude/sys/resource.h) -AC_CHECK_FUNCS(time ctime) +AC_CHECK_FUNCS(time ctime tzset) #-------------------------------------------------------------------- # These headers/functions needed by GSTcpPort.m