summaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2005-02-10 20:48:03 +0000
committerBrett Cannon <bcannon@gmail.com>2005-02-10 20:48:03 +0000
commit7d4f98bd773d1c36cb5f32f9c5d802c1c799d09c (patch)
tree6e60fd0fb37d8e8002950a8a3a9ec9c1ed525470 /configure.in
parent0ee927f5ea3b312e12ea03fe2cbe19a11d598955 (diff)
downloadcpython-7d4f98bd773d1c36cb5f32f9c5d802c1c799d09c.tar.gz
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.in35
1 files changed, 32 insertions, 3 deletions
diff --git a/configure.in b/configure.in
index 383c40f4c6..58e1e72a3f 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);
}