[Python-checkins] python/dist/src configure.in, 1.475.2.5, 1.475.2.6 configure, 1.462.2.5, 1.462.2.6

bcannon at users.sourceforge.net bcannon at users.sourceforge.net
Thu Feb 10 23:47:48 CET 2005


Update of /cvsroot/python/python/dist/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24745

Modified Files:
      Tag: release24-maint
	configure.in configure 
Log Message:
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.


Index: configure.in
===================================================================
RCS file: /cvsroot/python/python/dist/src/configure.in,v
retrieving revision 1.475.2.5
retrieving revision 1.475.2.6
diff -u -d -r1.475.2.5 -r1.475.2.6
--- configure.in	7 Jan 2005 13:17:33 -0000	1.475.2.5
+++ configure.in	10 Feb 2005 22:46:33 -0000	1.475.2.6
@@ -2917,45 +2917,74 @@
       [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);
 }

Index: configure
===================================================================
RCS file: /cvsroot/python/python/dist/src/configure,v
retrieving revision 1.462.2.5
retrieving revision 1.462.2.6
diff -u -d -r1.462.2.5 -r1.462.2.6
--- configure	7 Jan 2005 13:17:33 -0000	1.462.2.5
+++ configure	10 Feb 2005 22:46:35 -0000	1.462.2.6
@@ -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 @@
 
 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>
 
-# tzset(3) exists and works like we expect it to
+
+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
+
+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 @@
 #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);
 }



More information about the Python-checkins mailing list