Discussion:
time: fix trouble with HAVE_TIMEZONE_T
(too old to reply)
Bruno Haible
2017-05-10 23:08:50 UTC
Permalink
Raw Message
On mingw, in a testdir for module 'stat', I see this error:

i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../gllib -I.. -DGNULIB_STRICT_CHECKING=1 -I/usr/local/mingw32/include -Wall -g -O2 -MT stat.o -MD -MP -MF .deps/stat.Tpo -c -o stat.o ../../gllib/stat.c
In file included from ./sys/stat.h:44:0,
from ../../gllib/stat.c:60:
./time.h:741:36: error: operator '!' has no right operand

This occurs because HAVE_TIMEZONE_T is not set by Autoconf, thus it expands
to empty in the Makefile snippet that substitutes it. But a value of 0 or 1
is required.

This bug dates back to 2015, but was hidden until 2017-05-01 through a
dependency chain time -> gettimeofday -> sys_time.

This patch fixes it.


2017-05-10 Bruno Haible <***@clisp.org>

time: Fix missing initialization of HAVE_TIMEZONE_T.
* m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize HAVE_TIMEZONE_T
here...
* m4/sys_time_h.m4 (gl_HEADER_SYS_TIME_H_DEFAULTS): ... not here.
* m4/time_rz.m4 (gl_TIME_RZ): Require gl_HEADER_TIME_H_DEFAULTS, not
gl_HEADER_SYS_TIME_H_DEFAULTS.
* modules/time_rz (Depends-on): Add 'time'. Remove useless quoting.
(configure.ac): Remove useless quoting.

diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4
index e622dbe..1c8c3cf 100644
--- a/m4/sys_time_h.m4
+++ b/m4/sys_time_h.m4
@@ -1,5 +1,5 @@
# Configure a replacement for <sys/time.h>.
-# serial 8
+# serial 9

# Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
@@ -105,7 +105,6 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H_DEFAULTS],
HAVE_GETTIMEOFDAY=1; AC_SUBST([HAVE_GETTIMEOFDAY])
HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL])
HAVE_SYS_TIME_H=1; AC_SUBST([HAVE_SYS_TIME_H])
- HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T])
REPLACE_GETTIMEOFDAY=0; AC_SUBST([REPLACE_GETTIMEOFDAY])
REPLACE_STRUCT_TIMEVAL=0; AC_SUBST([REPLACE_STRUCT_TIMEVAL])
])
diff --git a/m4/time_h.m4 b/m4/time_h.m4
index f52b601..28e2209 100644
--- a/m4/time_h.m4
+++ b/m4/time_h.m4
@@ -2,7 +2,7 @@

# Copyright (C) 2000-2001, 2003-2007, 2009-2017 Free Software Foundation, Inc.

-# serial 10
+# serial 11

# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -120,6 +120,8 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
HAVE_TZSET=1; AC_SUBST([HAVE_TZSET])
+ dnl Even GNU libc does not have timezone_t yet.
+ HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T])
dnl If another module says to replace or to not replace, do that.
dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
dnl this lets maintainers check for portability.
diff --git a/m4/time_rz.m4 b/m4/time_rz.m4
index 079e933..3991118 100644
--- a/m4/time_rz.m4
+++ b/m4/time_rz.m4
@@ -10,7 +10,7 @@ dnl Written by Paul Eggert.
AC_DEFUN([gl_TIME_RZ],
[
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
- AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
+ AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
AC_REQUIRE([AC_STRUCT_TIMEZONE])

AC_CHECK_TYPES([timezone_t], [], [], [[#include <time.h>]])
diff --git a/modules/time_rz b/modules/time_rz
index 1bc29f4..0285add 100644
--- a/modules/time_rz
+++ b/modules/time_rz
@@ -19,17 +19,18 @@ m4/time_rz.m4

Depends-on:
extensions
-flexmember [test "$HAVE_TIMEZONE_T" = 0]
-setenv [test "$HAVE_TIMEZONE_T" = 0]
-stdbool [test "$HAVE_TIMEZONE_T" = 0]
-time_r [test "$HAVE_TIMEZONE_T" = 0]
-timegm [test "$HAVE_TIMEZONE_T" = 0]
-tzset [test "$HAVE_TIMEZONE_T" = 0]
-unsetenv [test "$HAVE_TIMEZONE_T" = 0]
+time
+flexmember [test $HAVE_TIMEZONE_T = 0]
+setenv [test $HAVE_TIMEZONE_T = 0]
+stdbool [test $HAVE_TIMEZONE_T = 0]
+time_r [test $HAVE_TIMEZONE_T = 0]
+timegm [test $HAVE_TIMEZONE_T = 0]
+tzset [test $HAVE_TIMEZONE_T = 0]
+unsetenv [test $HAVE_TIMEZONE_T = 0]

configure.ac:
gl_TIME_RZ
-if test "$HAVE_TIMEZONE_T" = 0; then
+if test $HAVE_TIMEZONE_T = 0; then
AC_LIBOBJ([time_rz])
fi
gl_TIME_MODULE_INDICATOR([time_rz])

Loading...