* [PATCH] asctime, ctime: deprecate
@ 2022-12-21 21:26 Paul Eggert
2022-12-26 17:26 ` Bruno Haible
0 siblings, 1 reply; 2+ messages in thread
From: Paul Eggert @ 2022-12-21 21:26 UTC (permalink / raw)
To: bug-gnulib; +Cc: Paul Eggert
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] asctime, ctime: deprecate
2022-12-21 21:26 [PATCH] asctime, ctime: deprecate Paul Eggert
@ 2022-12-26 17:26 ` Bruno Haible
0 siblings, 0 replies; 2+ messages in thread
From: Bruno Haible @ 2022-12-26 17:26 UTC (permalink / raw)
To: bug-gnulib, Paul Eggert
Paul Eggert wrote:
> * modules/ctime: Now obsolete.
This part is not right. The notion of an "obsolete" Gnulib module means [1]
that it is omitted when used as a dependency. But since we document that this
module really fixes a portability issue
Portability problems fixed by Gnulib:
@itemize
@item
On native Windows platforms (mingw, MSVC), this function works incorrectly
when the environment variable @code{TZ} has been set by Cygwin.
@end itemize
it shouldn't be marked 'obsolete'. If a customer package has defined a module
that depends on 'ctime', suddenly this dependency is now silently dropped;
this is not good.
[1] https://www.gnu.org/software/gnulib/manual/html_node/Module-description.html
This patch fixes it.
2022-12-26 Bruno Haible <bruno@clisp.org>
ctime: Mark as deprecated, not obsolete. (Regression 2022-12-21.)
* modules/ctime (Status): Remove.
(Notice): Say that it is deprecated, not obsolete.
diff --git a/modules/ctime b/modules/ctime
index 2a602dc2c3..08cc532986 100644
--- a/modules/ctime
+++ b/modules/ctime
@@ -1,11 +1,9 @@
Description:
ctime() function: convert time to string.
-Status:
-obsolete
-
Notice:
-This module is obsolete.
+The function 'ctime' is deprecated.
+New code should use 'localtime_r' and 'strftime' (or even 'sprintf') instead.
Files:
lib/ctime.c
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-26 17:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21 21:26 [PATCH] asctime, ctime: deprecate Paul Eggert
2022-12-26 17:26 ` Bruno Haible
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).