]> Savannah Git Hosting - gnulib.git/commitdiff
time-h: Obey GNULIB_POSIXCHECK, not GNULIB_PORTCHECK.
authorBruno Haible <bruno@clisp.org>
Sat, 29 Jul 2023 16:07:45 +0000 (18:07 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 16 Aug 2023 17:28:52 +0000 (19:28 +0200)
* lib/time.in.h (timespec_get, timespec_getres, time, nanosleep, tzset,
mktime, localtime_r, gmtime_r, localtime, strptime, ctime, strftime,
timegm): Add _GL_WARN_ON_USE invocation.
(asctime, ctime): Don't assume that these functions are declared, since
POSIX obsoletes them.
* m4/time_h.m4 (gl_TIME_H): Test for the declarations of asctime, ctime,
gmtime_r, localtime, localtime_r, mktime, nanosleep, strftime, strptime,
time, timegm, timespec_get, timespec_getres, tzset.
(gl_TIME_H_DEFAULTS): Initialize REPLACE_CTIME, REPLACE_LOCALTIME_R,
REPLACE_MKTIME, REPLACE_NANOSLEEP, REPLACE_STRFTIME, REPLACE_TIMEGM,
REPLACE_TZSET with 0 instead of GNULIB_PORTCHECK.
* m4/ctime.m4 (gl_FUNC_CTIME): Don't re-initialize REPLACE_CTIME.
* m4/time_r.m4 (gl_TIME_R): Don't re-initialize REPLACE_LOCALTIME_R.
* m4/mktime.m4 (gl_FUNC_MKTIME): Don't re-initialize REPLACE_MKTIME.
* m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Don't re-initialize
REPLACE_NANOSLEEP.
* m4/strftime-fixes.m4 (gl_FUNC_STRFTIME): Don't re-initialize
REPLACE_STRFTIME.
* m4/timegm.m4 (gl_FUNC_TIMEGM): Don't re-initialize REPLACE_TIMEGM.
* m4/tzset.m4 (gl_FUNC_TZSET: Don't re-initialize REPLACE_TZSET.

ChangeLog
lib/time.in.h
m4/ctime.m4
m4/mktime.m4
m4/nanosleep.m4
m4/strftime-fixes.m4
m4/time_h.m4
m4/time_r.m4
m4/timegm.m4
m4/tzset.m4

index ed6300d7ecd46efe10f250fecf271682ebd9b9e9..4d5dfe1e597cfec857d66ba9dbf5ce8290cb87bc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2023-07-29  Bruno Haible  <bruno@clisp.org>
+
+       time-h: Obey GNULIB_POSIXCHECK, not GNULIB_PORTCHECK.
+       * lib/time.in.h (timespec_get, timespec_getres, nanosleep, tzset,
+       mktime, localtime_r, gmtime_r, localtime, strptime, ctime, strftime,
+       timegm): Add _GL_WARN_ON_USE invocation.
+       (asctime, ctime): Don't assume that these functions are declared, since
+       POSIX obsoletes them.
+       * m4/time_h.m4 (gl_TIME_H): Test for the declarations of asctime, ctime,
+       gmtime_r, localtime, localtime_r, mktime, nanosleep, strftime, strptime,
+       time, timegm, timespec_get, timespec_getres, tzset.
+       (gl_TIME_H_DEFAULTS): Initialize REPLACE_CTIME, REPLACE_LOCALTIME_R,
+       REPLACE_MKTIME, REPLACE_NANOSLEEP, REPLACE_STRFTIME, REPLACE_TIMEGM,
+       REPLACE_TZSET with 0 instead of GNULIB_PORTCHECK.
+       * m4/ctime.m4 (gl_FUNC_CTIME): Don't re-initialize REPLACE_CTIME.
+       * m4/time_r.m4 (gl_TIME_R): Don't re-initialize REPLACE_LOCALTIME_R.
+       * m4/mktime.m4 (gl_FUNC_MKTIME): Don't re-initialize REPLACE_MKTIME.
+       * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Don't re-initialize
+       REPLACE_NANOSLEEP.
+       * m4/strftime-fixes.m4 (gl_FUNC_STRFTIME): Don't re-initialize
+       REPLACE_STRFTIME.
+       * m4/timegm.m4 (gl_FUNC_TIMEGM): Don't re-initialize REPLACE_TIMEGM.
+       * m4/tzset.m4 (gl_FUNC_TZSET: Don't re-initialize REPLACE_TZSET.
+
 2023-07-28  Bruno Haible  <bruno@clisp.org>
 
        posixcheck: Fix dependencies.
index 8207cdf64cc794cf26eac56d14892da3f9081fea..f181954e3932a5b873af82b726bb87e156e4ba49 100644 (file)
@@ -118,6 +118,12 @@ _GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base)
 #  endif
 _GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
 _GL_CXXALIASWARN (timespec_get);
+# elif defined GNULIB_POSIXCHECK
+#  undef timespec_get
+#  if HAVE_RAW_DECL_TIMESPEC_GET
+_GL_WARN_ON_USE (timespec_get, "timespec_get is unportable - "
+                 "use gnulib module timespec_get for portability");
+#  endif
 # endif
 
 /* Set *TS to the current time resolution, and return BASE.
@@ -129,6 +135,12 @@ _GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base)
 #  endif
 _GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base));
 _GL_CXXALIASWARN (timespec_getres);
+# elif defined GNULIB_POSIXCHECK
+#  undef timespec_getres
+#  if HAVE_RAW_DECL_TIMESPEC_GETRES
+_GL_WARN_ON_USE (timespec_getres, "timespec_getres is unportable - "
+                 "use gnulib module timespec_getres for portability");
+#  endif
 # endif
 
 /* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
@@ -154,6 +166,12 @@ _GL_CXXALIAS_SYS (nanosleep, int,
                   (struct timespec const *__rqtp, struct timespec *__rmtp));
 #  endif
 _GL_CXXALIASWARN (nanosleep);
+# elif defined GNULIB_POSIXCHECK
+#  undef nanosleep
+#  if HAVE_RAW_DECL_NANOSLEEP
+_GL_WARN_ON_USE (nanosleep, "nanosleep is unportable - "
+                 "use gnulib module nanosleep for portability");
+#  endif
 # endif
 
 /* Initialize time conversion information.  */
@@ -189,6 +207,12 @@ _GL_CXXALIAS_MDA (tzset, void, (void));
 _GL_CXXALIAS_SYS (tzset, void, (void));
 #  endif
 _GL_CXXALIASWARN (tzset);
+# elif defined GNULIB_POSIXCHECK
+#  undef tzset
+#  if HAVE_RAW_DECL_TZSET
+_GL_WARN_ON_USE (tzset, "tzset has portability problems - "
+                 "use gnulib module tzset for portability");
+#  endif
 # endif
 
 /* Return the 'time_t' representation of TP and normalize TP.  */
@@ -205,6 +229,12 @@ _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
 #  if __GLIBC__ >= 2
 _GL_CXXALIASWARN (mktime);
 #  endif
+# elif defined GNULIB_POSIXCHECK
+#  undef mktime
+#  if HAVE_RAW_DECL_MKTIME
+_GL_WARN_ON_USE (mktime, "mktime has portability problems - "
+                 "use gnulib module mktime for portability");
+#  endif
 # endif
 
 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
@@ -255,6 +285,17 @@ _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
 #  if @HAVE_DECL_LOCALTIME_R@
 _GL_CXXALIASWARN (gmtime_r);
 #  endif
+# elif defined GNULIB_POSIXCHECK
+#  undef localtime_r
+#  if HAVE_RAW_DECL_LOCALTIME_R
+_GL_WARN_ON_USE (localtime_r, "localtime_r is unportable - "
+                 "use gnulib module time_r for portability");
+#  endif
+#  undef gmtime_r
+#  if HAVE_RAW_DECL_GMTIME_R
+_GL_WARN_ON_USE (gmtime_r, "gmtime_r is unportable - "
+                 "use gnulib module time_r for portability");
+#  endif
 # endif
 
 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
@@ -275,6 +316,12 @@ _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
 #  if __GLIBC__ >= 2
 _GL_CXXALIASWARN (localtime);
 #  endif
+# elif defined GNULIB_POSIXCHECK
+#  undef localtime
+#  if HAVE_RAW_DECL_LOCALTIME
+_GL_WARN_ON_USE (localtime, "localtime has portability problems - "
+                 "use gnulib module localtime for portability");
+#  endif
 # endif
 
 # if 0 || @REPLACE_GMTIME@
@@ -306,6 +353,12 @@ _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
                                      char const *restrict __format,
                                      struct tm *restrict __tm));
 _GL_CXXALIASWARN (strptime);
+# elif defined GNULIB_POSIXCHECK
+#  undef strptime
+#  if HAVE_RAW_DECL_STRPTIME
+_GL_WARN_ON_USE (strptime, "strptime is unportable - "
+                 "use gnulib module strptime for portability");
+#  endif
 # endif
 
 /* Convert *TP to a date and time string.  See
@@ -327,6 +380,12 @@ _GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
 #  if __GLIBC__ >= 2
 _GL_CXXALIASWARN (ctime);
 #  endif
+# elif defined GNULIB_POSIXCHECK
+#  undef ctime
+#  if HAVE_RAW_DECL_CTIME
+_GL_WARN_ON_USE (ctime, "ctime has portability problems - "
+                 "use gnulib module ctime for portability");
+#  endif
 # endif
 
 /* Convert *TP to a date and time string.  See
@@ -351,6 +410,12 @@ _GL_CXXALIAS_SYS (strftime, size_t,
 #  if __GLIBC__ >= 2
 _GL_CXXALIASWARN (strftime);
 #  endif
+# elif defined GNULIB_POSIXCHECK
+#  undef strftime
+#  if HAVE_RAW_DECL_STRFTIME
+_GL_WARN_ON_USE (strftime, "strftime has portability problems - "
+                 "use gnulib module strftime-fixes for portability");
+#  endif
 # endif
 
 # if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
@@ -426,6 +491,12 @@ _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
 #  endif
 _GL_CXXALIASWARN (timegm);
+# elif defined GNULIB_POSIXCHECK
+#  undef timegm
+#  if HAVE_RAW_DECL_TIMEGM
+_GL_WARN_ON_USE (timegm, "timegm is unportable - "
+                 "use gnulib module timegm for portability");
+#  endif
 # endif
 
 /* Encourage applications to avoid unsafe functions that can overrun
@@ -433,8 +504,10 @@ _GL_CXXALIASWARN (timegm);
    applications should use strftime (or even sprintf) instead.  */
 # if defined GNULIB_POSIXCHECK
 #  undef asctime
+#  if HAVE_RAW_DECL_ASCTIME
 _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
                  "better use strftime (or even sprintf) instead");
+#  endif
 # endif
 # if defined GNULIB_POSIXCHECK
 #  undef asctime_r
@@ -445,8 +518,10 @@ _GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - "
 # endif
 # if defined GNULIB_POSIXCHECK
 #  undef ctime
+#  if HAVE_RAW_DECL_CTIME
 _GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - "
                  "better use strftime (or even sprintf) instead");
+#  endif
 # endif
 # if defined GNULIB_POSIXCHECK
 #  undef ctime_r
index 08aeb6745438a8b41b09a7fad8c1fccab0ee60fc..4fe21b0c95df1bb8f72e6bead6ca9d367c86d158 100644 (file)
@@ -1,4 +1,4 @@
-# ctime.m4 serial 2
+# ctime.m4 serial 3
 dnl Copyright (C) 2017-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,6 +10,5 @@ AC_DEFUN([gl_FUNC_CTIME],
   AC_REQUIRE([AC_CANONICAL_HOST])
   case "$host_os" in
     mingw*) REPLACE_CTIME=1 ;;
-    *)      REPLACE_CTIME=0 ;;
   esac
 ])
index e9d31f35a46b08bdcde1aa502d08ad849f05cce9..69cce86da5a9fc0964c1065b5ea83bdd0c759c92 100644 (file)
@@ -1,4 +1,4 @@
-# serial 37
+# serial 38
 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -280,7 +280,6 @@ AC_DEFUN([gl_FUNC_MKTIME],
   AC_REQUIRE([AC_CANONICAL_HOST])
   AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
 
-  REPLACE_MKTIME=0
   if test "$gl_cv_func_working_mktime" != yes; then
     REPLACE_MKTIME=1
     AC_DEFINE([NEED_MKTIME_WORKING], [1],
index 21ee5a21daff75e66764b963922dc9dc6515832c..83007708c514f0191c276e79d4a85a23194127c1 100644 (file)
@@ -1,4 +1,4 @@
-# serial 42
+# serial 42.1
 
 dnl From Jim Meyering.
 dnl Check for the nanosleep function.
@@ -126,9 +126,7 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
        ])
     ])
    case "$gl_cv_func_nanosleep" in
-     *yes)
-       REPLACE_NANOSLEEP=0
-       ;;
+     *yes) ;;
      *)
        REPLACE_NANOSLEEP=1
        case "$gl_cv_func_nanosleep" in
index ee587aa223d26205337ffcd5dadee3d85d9e783c..19136d03b95b878387fd5f889dd4ab7c6d931a31 100644 (file)
@@ -1,4 +1,4 @@
-# strftime-fixes.m4 serial 2
+# strftime-fixes.m4 serial 3
 dnl Copyright (C) 2017-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,6 +10,5 @@ AC_DEFUN([gl_FUNC_STRFTIME],
   AC_REQUIRE([AC_CANONICAL_HOST])
   case "$host_os" in
     mingw*) REPLACE_STRFTIME=1 ;;
-    *)      REPLACE_STRFTIME=0 ;;
   esac
 ])
index f6bf3a4f30e980f2fa328af392cb07a0a7bdf686..b0a61b2817e8b6b3c3fc4815157731a5317cd8fc 100644 (file)
@@ -2,7 +2,7 @@
 
 # Copyright (C) 2000-2001, 2003-2007, 2009-2023 Free Software Foundation, Inc.
 
-# serial 20
+# serial 20.1
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -23,7 +23,10 @@ AC_DEFUN_ONCE([gl_TIME_H],
   dnl corresponding gnulib module is not in use.
   gl_WARN_ON_USE_PREPARE([[
 #include <time.h>
-    ]], [asctime_r ctime_r])
+    ]], [
+      asctime asctime_r ctime ctime_r gmtime_r localtime localtime_r mktime
+      nanosleep strftime strptime time timegm timespec_get timespec_getres tzset
+    ])
 
   AC_REQUIRE([AC_C_RESTRICT])
 
@@ -161,23 +164,17 @@ AC_DEFUN([gl_TIME_H_DEFAULTS],
   HAVE_TIMESPEC_GETRES=1;                AC_SUBST([HAVE_TIMESPEC_GETRES])
   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.
-  REPLACE_CTIME=GNULIB_PORTCHECK;        AC_SUBST([REPLACE_CTIME])
-  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_STRFTIME=GNULIB_PORTCHECK;     AC_SUBST([REPLACE_STRFTIME])
-  REPLACE_TIMEGM=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_TIMEGM])
-  REPLACE_TZSET=GNULIB_PORTCHECK;        AC_SUBST([REPLACE_TZSET])
+  REPLACE_CTIME=0;                       AC_SUBST([REPLACE_CTIME])
+  REPLACE_GMTIME=0;                      AC_SUBST([REPLACE_GMTIME])
+  REPLACE_LOCALTIME=0;                   AC_SUBST([REPLACE_LOCALTIME])
+  REPLACE_LOCALTIME_R=0;                 AC_SUBST([REPLACE_LOCALTIME_R])
+  REPLACE_MKTIME=0;                      AC_SUBST([REPLACE_MKTIME])
+  REPLACE_NANOSLEEP=0;                   AC_SUBST([REPLACE_NANOSLEEP])
+  REPLACE_STRFTIME=0;                    AC_SUBST([REPLACE_STRFTIME])
+  REPLACE_TIMEGM=0;                      AC_SUBST([REPLACE_TIMEGM])
+  REPLACE_TZSET=0;                       AC_SUBST([REPLACE_TZSET])
 
   dnl Hack so that the time module doesn't depend on the sys_time module.
-  dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent.
+  dnl Default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent.
   : ${GNULIB_GETTIMEOFDAY=0};            AC_SUBST([GNULIB_GETTIMEOFDAY])
-  dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME
-  dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier
-  dnl is no longer a big deal.
-  REPLACE_GMTIME=0;                      AC_SUBST([REPLACE_GMTIME])
-  REPLACE_LOCALTIME=0;                   AC_SUBST([REPLACE_LOCALTIME])
 ])
index adce438abf1d0caef2c53f5f49cb27b392d1994b..4831eb26f90147c703bfea6b193dc7fd4f218462 100644 (file)
@@ -57,9 +57,7 @@ AC_DEFUN([gl_TIME_R],
          [gl_cv_time_r_posix=yes],
          [gl_cv_time_r_posix=no])
       ])
-    if test $gl_cv_time_r_posix = yes; then
-      REPLACE_LOCALTIME_R=0
-    else
+    if test $gl_cv_time_r_posix != yes; then
       REPLACE_LOCALTIME_R=1
     fi
   else
index 6079f1a39c8db6fb03c132919fc772fdc1badc98..946363cc0136bf10f0d7a54709ce9bf2b7587568 100644 (file)
@@ -1,4 +1,4 @@
-# timegm.m4 serial 13
+# timegm.m4 serial 13.1
 dnl Copyright (C) 2003, 2007, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,7 +8,6 @@ AC_DEFUN([gl_FUNC_TIMEGM],
 [
   AC_REQUIRE([gl_TIME_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
-  REPLACE_TIMEGM=0
   AC_CHECK_FUNCS_ONCE([timegm])
   if test $ac_cv_func_timegm = yes; then
     if test "$gl_cv_func_working_mktime" != yes; then
index 72e935fe18395586e6cb2ccd5f3c85173dc540d6..45e92339713c3d356ce43aa8ab5c53b979b7dba6 100644 (file)
@@ -1,4 +1,4 @@
-# serial 16
+# serial 17
 
 # Copyright (C) 2003, 2007, 2009-2023 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -11,7 +11,6 @@ AC_DEFUN([gl_FUNC_TZSET],
 [
   AC_REQUIRE([gl_TIME_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST])
-  REPLACE_TZSET=0
   case "$host_os" in
     mingw*) REPLACE_TZSET=1 ;;
   esac