bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] asctime, ctime: deprecate


From: Paul Eggert
Subject: [PATCH] asctime, ctime: deprecate
Date: Wed, 21 Dec 2022 13:26:45 -0800

C23 deprecates asctime and ctime, so deprecate them in Gnulib too.
* NEWS, doc/posix-functions/asctime.texi:
* doc/posix-functions/ctime.texi: Mention this.
* lib/time.in.h (ctime): Deprecate any ctime replacement.
* modules/ctime: Now obsolete.
---
 ChangeLog                        | 9 +++++++++
 NEWS                             | 3 +++
 doc/posix-functions/asctime.texi | 3 +++
 doc/posix-functions/ctime.texi   | 4 ++++
 lib/time.in.h                    | 1 +
 modules/ctime                    | 6 ++++++
 6 files changed, 26 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index d7f0a62ed9..66518b7a28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-12-21  Paul Eggert  <eggert@cs.ucla.edu>
+
+       asctime, ctime: deprecate
+       C23 deprecates asctime and ctime, so deprecate them in Gnulib too.
+       * NEWS, doc/posix-functions/asctime.texi:
+       * doc/posix-functions/ctime.texi: Mention this.
+       * lib/time.in.h (ctime): Deprecate any ctime replacement.
+       * modules/ctime: Now obsolete.
+
 2022-12-17  Paul Eggert  <eggert@cs.ucla.edu>
 
        memset_explicit: port to older MS-Windows
diff --git a/NEWS b/NEWS
index 3b83e2978d..bc620ce86a 100644
--- a/NEWS
+++ b/NEWS
@@ -74,6 +74,9 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2022-12-21  ctime           This module is deprecated.  Use localtime_r
+                            and strftime (or even sprintf) instead.
+
 2022-11-03  dynarray        These modules are renamed to 
glibc-internal/dynarray
             scratch_buffer  and glibc-internal/scratch_buffer, respectively.
                             They are not meant for general use.
diff --git a/doc/posix-functions/asctime.texi b/doc/posix-functions/asctime.texi
index c7dce36f6d..5c4654a866 100644
--- a/doc/posix-functions/asctime.texi
+++ b/doc/posix-functions/asctime.texi
@@ -13,5 +13,8 @@ Portability problems fixed by Gnulib:
 Portability problems not fixed by Gnulib:
 @itemize
 @item
+This function is deprecated in C23.
+Portable applications can use @code{strftime} (or even @code{sprintf}) instead.
+@item
 This function may overflow its internal buffer if an invalid year is passed.
 @end itemize
diff --git a/doc/posix-functions/ctime.texi b/doc/posix-functions/ctime.texi
index d9e194c2b3..bb6abb23a8 100644
--- a/doc/posix-functions/ctime.texi
+++ b/doc/posix-functions/ctime.texi
@@ -16,6 +16,10 @@ when the environment variable @code{TZ} has been set by 
Cygwin.
 Portability problems not fixed by Gnulib:
 @itemize
 @item
+This function is deprecated in C23.
+Portable applications can use @code{localtime_r} and @code{strftime}
+(or even @code{sprintf}) instead.
+@item
 This function may overflow its internal buffer if an invalid year is passed.
 @item
 The @code{ctime} function need not be reentrant, and consequently is
diff --git a/lib/time.in.h b/lib/time.in.h
index 6aa67498f5..aba2eda875 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -315,6 +315,7 @@ _GL_CXXALIASWARN (strptime);
 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #    define ctime rpl_ctime
 #   endif
+_GL_ATTRIBUTE_DEPRECATED
 _GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
                                  _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
diff --git a/modules/ctime b/modules/ctime
index 949f849b91..2a602dc2c3 100644
--- a/modules/ctime
+++ b/modules/ctime
@@ -1,6 +1,12 @@
 Description:
 ctime() function: convert time to string.
 
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
 Files:
 lib/ctime.c
 m4/ctime.m4
-- 
2.37.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]