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.
This commit is contained in:
Brett Cannon 2005-02-10 20:48:03 +00:00
parent 64d904b715
commit 4380242580
4 changed files with 677 additions and 220 deletions

View File

@ -66,6 +66,7 @@ Finn Bock
Paul Boddie
Matthew Boedicker
David Bolen
Gregory Bond
Jurjen Bos
Peter Bosch
Eric Bouck

View File

@ -161,6 +161,11 @@ Build
``-L/opt/local/lib`` for DarwinPorts) and CPPFLAGS (``-I/sw/include`` for
Fink, ``-I/opt/local/include`` for DarwinPorts).
- Test in configure.in that checks 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.
C API
-----

856
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -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);
}