[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Configure test for whether localtime caches TZ
From: |
Ken Brown |
Subject: |
Configure test for whether localtime caches TZ |
Date: |
Sat, 30 Oct 2010 14:29:00 -0400 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.11) Gecko/20101013 Thunderbird/3.1.5 |
The configure test for whether localtime caches TZ directly modifies the
environment and so (according to POSIX) might produce unreliable
results. Wouldn't it be better to use unsetenv, as in the following
patch (against the emacs-23 branch):
=== modified file 'configure.in'
--- configure.in 2010-05-10 00:37:59 +0000
+++ configure.in 2010-10-30 18:07:03 +0000
@@ -2441,14 +2441,6 @@
AC_CACHE_VAL(emacs_cv_localtime_cache,
[if test x$ac_cv_func_tzset = xyes; then
AC_TRY_RUN([#include <time.h>
-extern char **environ;
-unset_TZ ()
-{
- char **from, **to;
- for (to = from = environ; (*to = *from); from++)
- if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
- to++;
-}
char TZ_GMT0[] = "TZ=GMT0";
char TZ_PST8[] = "TZ=PST8";
main()
@@ -2458,13 +2450,13 @@
if (putenv (TZ_GMT0) != 0)
exit (1);
hour_GMT0 = localtime (&now)->tm_hour;
- unset_TZ ();
+ unsetenv("TZ");
hour_unset = localtime (&now)->tm_hour;
if (putenv (TZ_PST8) != 0)
exit (1);
if (localtime (&now)->tm_hour == hour_GMT0)
exit (1);
- unset_TZ ();
+ unsetenv("TZ");
if (localtime (&now)->tm_hour != hour_unset)
exit (1);
exit (0);
- Configure test for whether localtime caches TZ,
Ken Brown <=