comparison doc/ctime.texi @ 6253:f194efd935e3

Note about ctime.
author Bruno Haible <bruno@clisp.org>
date Mon, 19 Sep 2005 15:46:53 +0000
parents
children adb21c293305
comparison
equal deleted inserted replaced
6252:038c6bc7d60a 6253:f194efd935e3
1 @node ctime
2 @section ctime
3 @findex ctime
4
5 The @code{ctime} function need not be reentrant, and consequently is
6 not required to be thread safe. Implementations of @code{ctime}
7 typically write the time stamp into static buffer. If two threads
8 call @code{ctime} at roughly the same time, you might end up with the
9 wrong date in one of the threads, or some undefined string. There is
10 a re-entrant interface @code{ctime_r}, that take a pre-allocated
11 buffer and length of the buffer, and return @code{NULL} on errors.
12 The input buffer should be at least 26 bytes in size. The output
13 string is locale-independent. However, years can have more than 4
14 digits if @code{time_t} is sufficiently wide, so the length of the
15 required output buffer is not easy to determine. Increasing the
16 buffer size when @code{ctime_r} return @code{NULL} is not necessarily
17 sufficient. The @code{NULL} return value could mean some other error
18 condition, which will not go away by increasing the buffer size.
19
20 A more flexible function is @code{strftime}. However, note that it is
21 locale dependent.