diff options
author | Poul-Henning Kamp <phk@FreeBSD.org> | 1998-04-19 06:47:25 +0000 |
---|---|---|
committer | Poul-Henning Kamp <phk@FreeBSD.org> | 1998-04-19 06:47:25 +0000 |
commit | 3f643d87bbce2c3c5ebe21d3ab44bd93792b31b9 (patch) | |
tree | 1cabb9fb6008ff25bd6ccdff5a6430c982161c86 | |
parent | 823833f19df1eed41eff6f44c072a704ff55b1c6 (diff) | |
download | src-3f643d87bbce2c3c5ebe21d3ab44bd93792b31b9.tar.gz src-3f643d87bbce2c3c5ebe21d3ab44bd93792b31b9.zip |
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>
Notes
Notes:
svn path=/head/; revision=35285
-rw-r--r-- | include/time.h | 4 | ||||
-rw-r--r-- | lib/libc/stdtime/asctime.c | 15 | ||||
-rw-r--r-- | lib/libc/stdtime/localtime.c | 9 |
3 files changed, 23 insertions, 5 deletions
diff --git a/include/time.h b/include/time.h index 3ef83609f672..a2a89c7932ed 100644 --- a/include/time.h +++ b/include/time.h @@ -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 diff --git a/lib/libc/stdtime/asctime.c b/lib/libc/stdtime/asctime.c index a1834b65a273..832f18592ff3 100644 --- a/lib/libc/stdtime/asctime.c +++ b/lib/libc/stdtime/asctime.c @@ -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; diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c index 5de39d66fa6e..61614c75e796 100644 --- a/lib/libc/stdtime/localtime.c +++ b/lib/libc/stdtime/localtime.c @@ -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 |