changeset 13131:9bf8948cd6b6

timegm: Fix C++ test error on mingw.
author Bruno Haible <bruno@clisp.org>
date Sat, 03 Apr 2010 19:15:04 +0200
parents 5735734700f2
children eeb9ce788354
files ChangeLog lib/time.in.h m4/time_h.m4 m4/timegm.m4 modules/time
diffstat 5 files changed, 22 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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.
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -187,6 +187,9 @@
 _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);
--- a/m4/time_h.m4
+++ b/m4/time_h.m4
@@ -79,6 +79,7 @@
   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.
--- a/m4/timegm.m4
+++ b/m4/timegm.m4
@@ -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_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
--- a/modules/time
+++ b/modules/time
@@ -33,6 +33,7 @@
 	      -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' \