diff options
author | Brett Cannon <bcannon@gmail.com> | 2005-02-10 20:48:03 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2005-02-10 20:48:03 (GMT) |
commit | 438024258078d46e76c55cbf35d387725034be19 (patch) | |
tree | 6bdbf92db766140af306888681351d378a992992 /configure.in | |
parent | 64d904b715b1cf6a29bfa72a72aeb6a3e72eac5a (diff) | |
download | cpython-438024258078d46e76c55cbf35d387725034be19.zip cpython-438024258078d46e76c55cbf35d387725034be19.tar.gz cpython-438024258078d46e76c55cbf35d387725034be19.tar.bz2 |
Modified test for tzset to not rely on tm->tm_zone's existence. Also added
sanity checks on tzname if HAVE_TZNAME defined.
Closes bug #1096244. Thanks Gregory Bond.
Diffstat (limited to 'configure.in')
-rw-r--r-- | configure.in | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/configure.in b/configure.in index 383c40f..58e1e72 100644 --- a/configure.in +++ b/configure.in @@ -2917,45 +2917,74 @@ then [Define if poll() sets errno on invalid file descriptors.]) fi +# Before we can test tzset, we need to check if struct tm has a tm_zone +# (which is not required by ISO C or UNIX spec) and/or if we support +# tzname[] +AC_STRUCT_TIMEZONE -# tzset(3) exists and works like we expect it to +# check tzset(3) exists and works like we expect it to AC_MSG_CHECKING(for working tzset()) AC_CACHE_VAL(ac_cv_working_tzset, [ AC_TRY_RUN([ #include <stdlib.h> #include <time.h> #include <string.h> + +#if HAVE_TZNAME +extern char *tzname[]; +#endif + int main() { /* Note that we need to ensure that not only does tzset(3) do 'something' with localtime, but it works as documented in the library reference and as expected by the test suite. + This includes making sure that tzname is set properly if + tm->tm_zone does not exist since it is the alternative way + of getting timezone info. Red Hat 6.2 doesn't understand the southern hemisphere - after New Year's Day; it thinks swaps on that day. + after New Year's Day. */ - time_t groundhogday = 1044144000; /* GMT-based; well, it's a colony */ + time_t groundhogday = 1044144000; /* GMT-based */ time_t midyear = groundhogday + (365 * 24 * 3600 / 2); putenv("TZ=UTC+0"); tzset(); if (localtime(&groundhogday)->tm_hour != 0) exit(1); +#if HAVE_TZNAME + /* For UTC, tzname[1] is sometimes "", sometimes " " */ + if (strcmp(tzname[0], "UTC") || + (tzname[1][0] != 0 && tzname[1][0] != ' ')) + exit(1); +#endif putenv("TZ=EST+5EDT,M4.1.0,M10.5.0"); tzset(); if (localtime(&groundhogday)->tm_hour != 19) exit(1); +#if HAVE_TZNAME + if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT")) + exit(1); +#endif putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0"); tzset(); if (localtime(&groundhogday)->tm_hour != 11) exit(1); +#if HAVE_TZNAME + if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT")) + exit(1); +#endif + +#if HAVE_STRUCT_TM_TM_ZONE if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT")) exit(1); if (strcmp(localtime(&midyear)->tm_zone, "AEST")) exit(1); +#endif exit(0); } |