Date: Sun, 19 Apr 1998 03:38:28 +0400 (MSD) From: Dmitry Khrustalev <dima@xyzzy.machaon.ru> To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/6345: ctime_r is not implemented Message-ID: <199804182338.DAA07927@xyzzy.machaon.ru>
next in thread | raw e-mail | index | archive | help
>Number: 6345
>Category: bin
>Synopsis: ctime_r is not implemented
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sat Apr 18 16:40:01 PDT 1998
>Last-Modified:
>Originator: Dmitry Khrustalev
>Organization:
>Release: FreeBSD 3.0-CURRENT i386
>Environment:
FreeBSD 3.0-CURRENT i386
>Description:
ctime_r and asctime_r are not implemented.
prototypes in time.h do not match POSIX.
>How-To-Repeat:
>Fix:
Apply the following patch:
diff -r -u lib/libc/stdtime.ORIG/asctime.c lib/libc/stdtime/asctime.c
--- lib/libc/stdtime.ORIG/asctime.c Sun Apr 19 02:22:15 1998
+++ lib/libc/stdtime/asctime.c Sun Apr 19 03:04:11 1998
@@ -18,9 +18,20 @@
** 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 @@
** 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;
Only in lib/libc/stdtime: asctime.c.orig
diff -r -u lib/libc/stdtime.ORIG/localtime.c lib/libc/stdtime/localtime.c
--- lib/libc/stdtime.ORIG/localtime.c Sun Apr 19 02:22:14 1998
+++ lib/libc/stdtime/localtime.c Sun Apr 19 03:28:56 1998
@@ -1345,6 +1345,15 @@
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
Only in lib/libc/stdtime: localtime.c.orig
--- include/time.h.ORIG Sat Apr 4 20:16:36 1998
+++ include/time.h Sun Apr 19 03:04:11 1998
@@ -128,8 +128,8 @@
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
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199804182338.DAA07927>
