summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2005-02-10 22:47:13 (GMT)
committerBrett Cannon <bcannon@gmail.com>2005-02-10 22:47:13 (GMT)
commitd7a6228af3f60bce7dc565bbf175ffe80fdb6506 (patch)
tree078a2bf19938b46de193ea0aabf2cc32a2e9ebd6
parent89dbd9a0555a04623f641c7f3c567770508cf88f (diff)
downloadcpython-d7a6228af3f60bce7dc565bbf175ffe80fdb6506.zip
cpython-d7a6228af3f60bce7dc565bbf175ffe80fdb6506.tar.gz
cpython-d7a6228af3f60bce7dc565bbf175ffe80fdb6506.tar.bz2
Fix tzset() check to not require the existence of tm->tm_zone. Also added more
sanity checks for tzname when HAVE_TZNAME is defined. Closes bug #1096244. Thanks Gregory Bond.
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS6
-rwxr-xr-xconfigure226
-rw-r--r--configure.in35
4 files changed, 261 insertions, 7 deletions
diff --git a/Misc/ACKS b/Misc/ACKS
index 2c8038f..be12115 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -64,6 +64,7 @@ Finn Bock
Paul Boddie
Matthew Boedicker
David Bolen
+Gregory Bond
Jurjen Bos
Peter Bosch
Eric Bouck
diff --git a/Misc/NEWS b/Misc/NEWS
index d62d9d9..a7fd5b4 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -62,6 +62,12 @@ Build
- term.h is now properly detected again.
+- Check for tzset no longer dependent on tm->tm_zone to exist in the struct
+ (not required by either ISO C nor the UNIX 2 spec).
+ Tests for sanity in tzname when HAVE_TZNAME defined were also defined.
+ Closes bug #1096244. Thanks Gregory Bond.
+
+
Windows
-------
diff --git a/configure b/configure
index 6e5677c..0edbb64 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Revision: 1.475.2.4 .
+# From configure.in Revision: 1.475.2.5 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for python 2.4.
#
@@ -19748,8 +19748,201 @@ _ACEOF
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[]
+echo "$as_me:$LINENO: checking for struct tm.tm_zone" >&5
+echo $ECHO_N "checking for struct tm.tm_zone... $ECHO_C" >&6
+if test "${ac_cv_member_struct_tm_tm_zone+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <$ac_cv_struct_tm>
+
+
+int
+main ()
+{
+static struct tm ac_aggr;
+if (ac_aggr.tm_zone)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_member_struct_tm_tm_zone=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
-# tzset(3) exists and works like we expect it to
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <$ac_cv_struct_tm>
+
+
+int
+main ()
+{
+static struct tm ac_aggr;
+if (sizeof ac_aggr.tm_zone)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_member_struct_tm_tm_zone=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_member_struct_tm_tm_zone=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_member_struct_tm_tm_zone" >&5
+echo "${ECHO_T}$ac_cv_member_struct_tm_tm_zone" >&6
+if test $ac_cv_member_struct_tm_tm_zone = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_TM_TM_ZONE 1
+_ACEOF
+
+
+fi
+
+if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TM_ZONE 1
+_ACEOF
+
+else
+ echo "$as_me:$LINENO: checking for tzname" >&5
+echo $ECHO_N "checking for tzname... $ECHO_C" >&6
+if test "${ac_cv_var_tzname+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <time.h>
+#ifndef tzname /* For SGI. */
+extern char *tzname[]; /* RS6000 and others reject char **tzname. */
+#endif
+
+int
+main ()
+{
+atoi(*tzname);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_var_tzname=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_var_tzname=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_var_tzname" >&5
+echo "${ECHO_T}$ac_cv_var_tzname" >&6
+ if test $ac_cv_var_tzname = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TZNAME 1
+_ACEOF
+
+ fi
+fi
+
+
+# check tzset(3) exists and works like we expect it to
echo "$as_me:$LINENO: checking for working tzset()" >&5
echo $ECHO_N "checking for working tzset()... $ECHO_C" >&6
if test "${ac_cv_working_tzset+set}" = set; then
@@ -19769,37 +19962,62 @@ cat >>conftest.$ac_ext <<_ACEOF
#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);
}
diff --git a/configure.in b/configure.in
index d6ae4bf..620b1fe 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);
}