Add warning under NOTES that asctime(), ctime(), gmtime(), and

localtime() may each overwrite the static object returned by any
of the other calls.
This commit is contained in:
Michael Kerrisk 2008-09-18 12:26:18 +00:00
parent fdc6b83141
commit 8167059b21
1 changed files with 16 additions and 4 deletions

View File

@ -30,7 +30,7 @@
.\" Modified 2001-12-13, joey, aeb
.\" Modified 2004-11-16, mtk
.\"
.TH CTIME 3 2007-07-26 "" "Linux Programmer's Manual"
.TH CTIME 3 2008-04-06 "" "Linux Programmer's Manual"
.SH NAME
asctime, ctime, gmtime, localtime, mktime, asctime_r, ctime_r, gmtime_r,
localtime_r \- transform date and time to broken-down time or ASCII
@ -266,10 +266,22 @@ Thread-safe versions
and
.BR localtime_r ()
are specified by SUSv2, and available since libc 5.2.5.
POSIX.1-2001 says:
"The
.BR asctime (),
.BR ctime (),
.BR gmtime (),
and
.BR localtime ()
functions shall return values in one of two static objects:
a broken-down time structure and an array of type
.IR char .
Execution of any of the functions may overwrite the information returned
in either of these objects by any of the other functions."
This can occur in the glibc implementation.
.LP
In many implementations, including
.IR glibc ,
a 0 in
In many implementations, including glibc, a 0 in
.I tm_mday
is interpreted as meaning the last day of the preceding month.
.LP