Fix compilation error when <ctime> is used and mktime is replaced.
authorBruno Haible <bruno@clisp.org>
Tue, 28 Jul 2009 19:01:16 +0000 (21:01 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 28 Jul 2009 19:01:52 +0000 (21:01 +0200)
* lib/time.in.h (mktime): New declaration.
* m4/mktime.m4 (gl_FUNC_MKTIME): Require gl_HEADER_TIME_H_DEFAULTS. Set
REPLACE_MKTIME instead of defining mktime in config.h.
* m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize REPLACE_MKTIME.
* modules/time (Makefile.am): Substitute REPLACE_MKTIME.
Reported by Ross McFarland <rwmcfa1@neces.com>.

ChangeLog
lib/time.in.h
m4/mktime.m4
m4/time_h.m4
modules/time

index 07539f8..fa9a76b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2009-07-27  Bruno Haible  <bruno@clisp.org>
 
+       Fix compilation error when <ctime> is used and mktime is replaced.
+       * lib/time.in.h (mktime): New declaration.
+       * m4/mktime.m4 (gl_FUNC_MKTIME): Require gl_HEADER_TIME_H_DEFAULTS. Set
+       REPLACE_MKTIME instead of defining mktime in config.h.
+       * m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize REPLACE_MKTIME.
+       * modules/time (Makefile.am): Substitute REPLACE_MKTIME.
+       Reported by Ross McFarland <rwmcfa1@neces.com>.
+
+2009-07-27  Bruno Haible  <bruno@clisp.org>
+
        * lib/math.in.h (cosl, logl, sinl): Undefine before declaring it.
        Reported by Matt Kraai <mkraai@beckman.com>.
 
index fba8fce..b9c2230 100644 (file)
@@ -1,6 +1,6 @@
 /* A more-standard <time.h>.
 
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -66,6 +66,12 @@ struct timespec
 int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp);
 # endif
 
+/* Return the 'time_t' representation of TP and normalize TP.  */
+# if @REPLACE_MKTIME@
+#  define mktime rpl_mktime
+extern time_t mktime (struct tm *__tp);
+# endif
+
 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
    <http://www.opengroup.org/susv3xsh/localtime_r.html> and
    <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
index 1e926e8..3eeace5 100644 (file)
@@ -215,11 +215,11 @@ fi
 
 AC_DEFUN([gl_FUNC_MKTIME],
 [
+  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
   AC_FUNC_MKTIME
   dnl Note: AC_FUNC_MKTIME does AC_LIBOBJ([mktime]).
   if test $ac_cv_func_working_mktime = no; then
-    AC_DEFINE([mktime], [rpl_mktime],
-      [Define to rpl_mktime if the replacement function should be used.])
+    REPLACE_MKTIME=1
     gl_PREREQ_MKTIME
   fi
 ])
index d42a635..16fefa1 100644 (file)
@@ -1,7 +1,6 @@
 # Configure a more-standard replacement for <time.h>.
 
-# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007 Free Software
-# Foundation, Inc.
+# Copyright (C) 2000-2001, 2003-2007, 2009 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -30,6 +29,7 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
   dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
   dnl this lets maintainers check for portability.
   REPLACE_LOCALTIME_R=GNULIB_PORTCHECK;  AC_SUBST([REPLACE_LOCALTIME_R])
+  REPLACE_MKTIME=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_MKTIME])
   REPLACE_NANOSLEEP=GNULIB_PORTCHECK;    AC_SUBST([REPLACE_NANOSLEEP])
   REPLACE_STRPTIME=GNULIB_PORTCHECK;     AC_SUBST([REPLACE_STRPTIME])
   REPLACE_TIMEGM=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_TIMEGM])
index 50b07af..a6c9fa7 100644 (file)
@@ -24,6 +24,7 @@ time.h: time.in.h
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
              -e 's|@NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
              -e 's|@REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
+             -e 's|@REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
              -e 's|@REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
              -e 's|@REPLACE_STRPTIME''@|$(REPLACE_STRPTIME)|g' \
              -e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \