ctime_r and asctime_r are not implemented.

prototypes in time.h do not match POSIX.

PR:		6345
Reviewed by:	phk
Submitted by:	Dmitry Khrustalev <dima@xyzzy.machaon.ru>
This commit is contained in:
Poul-Henning Kamp 1998-04-19 06:47:25 +00:00
parent 823833f19d
commit 3f643d87bb
3 changed files with 23 additions and 5 deletions

View File

@ -128,8 +128,8 @@ size_t strftime __P((char *, size_t, const char *, const struct tm *));
time_t time __P((time_t *));
#ifdef _THREAD_SAFE
int asctime_r __P((const struct tm *, char *, int));
int ctime_r __P((const time_t *, char *, int));
char *asctime_r __P((const struct tm *, char *));
char *ctime_r __P((const time_t *, char *));
struct tm *gmtime_r __P((const time_t *, struct tm *));
struct tm *localtime_r __P((const time_t *, struct tm *));
#endif

View File

@ -18,9 +18,20 @@ static char elsieid[] = "@(#)asctime.c 7.7";
** A la X3J11, with core dump avoidance.
*/
char *
asctime(timeptr)
register const struct tm * timeptr;
const struct tm * timeptr;
{
static char result[3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) +
3 + 2 + 1 + 1];
return(asctime_r(timeptr, result));
}
char *
asctime_r(timeptr, result)
const struct tm * timeptr;
char *result;
{
static const char wday_name[][3] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
@ -36,8 +47,6 @@ register const struct tm * timeptr;
** three explicit spaces, two explicit colons, a newline,
** and a trailing ASCII nul).
*/
static char result[3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) +
3 + 2 + 1 + 1];
register const char * wn;
register const char * mn;

View File

@ -1345,6 +1345,15 @@ const time_t * const timep;
return asctime(localtime(timep));
}
char *
ctime_r(timep, buf)
const time_t * const timep;
char *buf;
{
struct tm tm;
return asctime_r(localtime_r(timep, &tm), buf);
}
/*
** Adapted from code provided by Robert Elz, who writes:
** The "best" way to do mktime I think is based on an idea of Bob