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:
parent
64d904b715
commit
4380242580
|
@ -66,6 +66,7 @@ Finn Bock
|
||||||
Paul Boddie
|
Paul Boddie
|
||||||
Matthew Boedicker
|
Matthew Boedicker
|
||||||
David Bolen
|
David Bolen
|
||||||
|
Gregory Bond
|
||||||
Jurjen Bos
|
Jurjen Bos
|
||||||
Peter Bosch
|
Peter Bosch
|
||||||
Eric Bouck
|
Eric Bouck
|
||||||
|
|
|
@ -161,6 +161,11 @@ Build
|
||||||
``-L/opt/local/lib`` for DarwinPorts) and CPPFLAGS (``-I/sw/include`` for
|
``-L/opt/local/lib`` for DarwinPorts) and CPPFLAGS (``-I/sw/include`` for
|
||||||
Fink, ``-I/opt/local/include`` for DarwinPorts).
|
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
|
C API
|
||||||
-----
|
-----
|
||||||
|
|
35
configure.in
35
configure.in
|
@ -2917,45 +2917,74 @@ then
|
||||||
[Define if poll() sets errno on invalid file descriptors.])
|
[Define if poll() sets errno on invalid file descriptors.])
|
||||||
fi
|
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_MSG_CHECKING(for working tzset())
|
||||||
AC_CACHE_VAL(ac_cv_working_tzset, [
|
AC_CACHE_VAL(ac_cv_working_tzset, [
|
||||||
AC_TRY_RUN([
|
AC_TRY_RUN([
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if HAVE_TZNAME
|
||||||
|
extern char *tzname[];
|
||||||
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
/* Note that we need to ensure that not only does tzset(3)
|
/* Note that we need to ensure that not only does tzset(3)
|
||||||
do 'something' with localtime, but it works as documented
|
do 'something' with localtime, but it works as documented
|
||||||
in the library reference and as expected by the test suite.
|
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
|
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);
|
time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
|
||||||
|
|
||||||
putenv("TZ=UTC+0");
|
putenv("TZ=UTC+0");
|
||||||
tzset();
|
tzset();
|
||||||
if (localtime(&groundhogday)->tm_hour != 0)
|
if (localtime(&groundhogday)->tm_hour != 0)
|
||||||
exit(1);
|
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");
|
putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
|
||||||
tzset();
|
tzset();
|
||||||
if (localtime(&groundhogday)->tm_hour != 19)
|
if (localtime(&groundhogday)->tm_hour != 19)
|
||||||
exit(1);
|
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");
|
putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
|
||||||
tzset();
|
tzset();
|
||||||
if (localtime(&groundhogday)->tm_hour != 11)
|
if (localtime(&groundhogday)->tm_hour != 11)
|
||||||
exit(1);
|
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"))
|
if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
|
||||||
exit(1);
|
exit(1);
|
||||||
if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
|
if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
|
||||||
exit(1);
|
exit(1);
|
||||||
|
#endif
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue