summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-12-21 13:25:39 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2022-12-21 13:26:13 -0800
commitee37744d13296e139b99720c1cf3ea5eed25bfbf (patch)
tree306a6360a60ea385af428e56ffd787027ba181de
parentf162824875e04079dc1fecd6517f9cfe6887069d (diff)
downloadgnulib-ee37744d13296e139b99720c1cf3ea5eed25bfbf.tar.gz
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.
-rw-r--r--ChangeLog9
-rw-r--r--NEWS3
-rw-r--r--doc/posix-functions/asctime.texi3
-rw-r--r--doc/posix-functions/ctime.texi4
-rw-r--r--lib/time.in.h1
-rw-r--r--modules/ctime6
6 files changed, 26 insertions, 0 deletions
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