timegm: Fix C++ test error on mingw.
authorBruno Haible <bruno@clisp.org>
Sat, 3 Apr 2010 17:15:04 +0000 (19:15 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 3 Apr 2010 17:35:06 +0000 (19:35 +0200)
ChangeLog
lib/time.in.h
m4/time_h.m4
m4/timegm.m4
modules/time

index ecea28d..cd8c296 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2010-04-03  Bruno Haible  <bruno@clisp.org>
 
+       timegm: Fix C++ test error on mingw.
+       * lib/time.in.h (timegm): Use modern idiom.
+       * m4/timegm.m4 (gl_FUNC_TIMEGM): When timegm does not exist, set
+       HAVE_TIMEGM to 0, not REPLACE_TIMEGM to 1.
+       * m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize HAVE_TIMEGM.
+       * modules/time (Makefile.am): Substitute HAVE_TIMEGM.
+
+2010-04-03  Bruno Haible  <bruno@clisp.org>
+
        timegm: Assume declaration if function exists.
        * m4/timegm.m4 (gl_FUNC_TIMEGM): Assume timegm is declared if and only
        if it exists. Don't clobber ac_cv_func_timegm.
index 3561016..aeea0b2 100644 (file)
@@ -187,6 +187,9 @@ _GL_CXXALIASWARN (strptime);
 _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
 #  else
+#   if ! @HAVE_TIMEGM@
+_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
+#   endif
 _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
 #  endif
 _GL_CXXALIASWARN (timegm);
index ecab807..f69038a 100644 (file)
@@ -79,6 +79,7 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
   GNULIB_TIME_R=0;                       AC_SUBST([GNULIB_TIME_R])
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_LOCALTIME_R=0;                    AC_SUBST([HAVE_LOCALTIME_R])
+  HAVE_TIMEGM=0;                         AC_SUBST([HAVE_TIMEGM])
   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.
index 010a6f2..bdaafbf 100644 (file)
@@ -1,4 +1,4 @@
-# timegm.m4 serial 7
+# timegm.m4 serial 8
 dnl Copyright (C) 2003, 2007, 2009, 2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,16 +9,16 @@ AC_DEFUN([gl_FUNC_TIMEGM],
   AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_MKTIME])
   REPLACE_TIMEGM=0
-  if test $ac_cv_func_working_mktime = no; then
-    # Assume that timegm is buggy if mktime is.
-    REPLACE_TIMEGM=1
-  else
-    AC_CHECK_FUNCS([timegm])
-    if test $ac_cv_func_timegm != yes; then
+  AC_CHECK_FUNCS_ONCE([timegm])
+  if test $ac_cv_func_timegm = yes; then
+    if test $ac_cv_func_working_mktime = no; then
+      # Assume that timegm is buggy if mktime is.
       REPLACE_TIMEGM=1
     fi
+  else
+    HAVE_TIMEGM=0
   fi
-  if test $REPLACE_TIMEGM = 1; then
+  if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then
     AC_LIBOBJ([timegm])
     gl_PREREQ_TIMEGM
   fi
index bfc208b..287dec1 100644 (file)
@@ -33,6 +33,7 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
              -e 's|@''GNULIB_TIMEGM''@|$(GNULIB_TIMEGM)|g' \
              -e 's|@''GNULIB_TIME_R''@|$(GNULIB_TIME_R)|g' \
              -e 's|@''HAVE_LOCALTIME_R''@|$(HAVE_LOCALTIME_R)|g' \
+             -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
              -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
              -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
              -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \