From dima@xyzzy.machaon.ru  Sat Apr 18 23:38:54 1998
Received: from xyzzy.machaon.ru (dial57037.mtu-net.ru [195.34.57.37])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA27967
          for <FreeBSD-gnats-submit@freebsd.org>; Sat, 18 Apr 1998 23:38:49 GMT
          (envelope-from dima@xyzzy.machaon.ru)
Received: (from dima@localhost)
	by xyzzy.machaon.ru (8.8.8/8.8.5) id DAA07927;
	Sun, 19 Apr 1998 03:38:28 +0400 (MSD)
Message-Id: <199804182338.DAA07927@xyzzy.machaon.ru>
Date: Sun, 19 Apr 1998 03:38:28 +0400 (MSD)
From: Dmitry Khrustalev <dima@xyzzy.machaon.ru>
Reply-To: dima@xyzzy.machaon.ru
To: FreeBSD-gnats-submit@freebsd.org
Subject: ctime_r is not implemented
X-Send-Pr-Version: 3.2

>Number:         6345
>Category:       bin
>Synopsis:       ctime_r is not implemented
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Apr 18 16:40:01 PDT 1998
>Closed-Date:    Sat Apr 18 23:47:35 PDT 1998
>Last-Modified:  Sat Apr 18 23:47:48 PDT 1998
>Originator:     Dmitry Khrustalev
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
>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
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Sat Apr 18 23:47:35 PDT 1998 
State-Changed-Why:  
committed, thanks! 
>Unformatted:
