From nobody@FreeBSD.org  Wed May  2 02:57:00 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 1EA4437B422
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  2 May 2001 02:57:00 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.1/8.11.1) id f429v0e11951;
	Wed, 2 May 2001 02:57:00 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200105020957.f429v0e11951@freefall.freebsd.org>
Date: Wed, 2 May 2001 02:57:00 -0700 (PDT)
From: thz@lennartz-electronic.de
To: freebsd-gnats-submit@FreeBSD.org
Subject: strptime: %s formatting missing (patch)
X-Send-Pr-Version: www-1.0

>Number:         27029
>Category:       bin
>Synopsis:       strptime: %s formatting missing (patch)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    dd
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 02 03:00:02 PDT 2001
>Closed-Date:    Mon Jul 30 17:06:28 PDT 2001
>Last-Modified:  Mon Jul 30 17:06:35 PDT 2001
>Originator:     Thomas Zenker
>Release:        4.3-STABLE
>Organization:
Lennartz electronic
>Environment:
FreeBSD mezcal.tue.le 4.3-STABLE FreeBSD 4.3-STABLE #6: Wed May  2 08:50:01 CEST 2001     root@mezcal.tue.le:/usr/obj/usr/src/sys/MEZCAL  i386
>Description:
for date manipulations in ascii form is documented, that all formattings
of date (resp. strftime) can be read by strptime. However, the "%s" 
format (seconds UTC since epoch) is not recognized. A patch, which
integrates this format is supplied.

>How-To-Repeat:
date -j -f "%s" `date "+%s"`

>Fix:
Index: lib/libc/stdtime/strptime.c
===================================================================
RCS file: /usr/cvs/FreeBSD/src/lib/libc/stdtime/strptime.c,v
retrieving revision 1.17.2.1
diff -u -r1.17.2.1 strptime.c
--- lib/libc/stdtime/strptime.c	2000/10/26 16:07:53	1.17.2.1
+++ lib/libc/stdtime/strptime.c	2001/04/27 19:38:51
@@ -513,6 +513,16 @@
 			}
 			}
 			break;
+		case 's':
+			{
+			time_t t;
+			const char *cp;
+			t = strtol(buf, &cp, 10);
+			buf = cp;
+			memcpy(tm, gmtime(&t), sizeof(struct tm));
+			got_GMT = 1;
+			}
+			break;
 		}
 	}
 	return (char *)buf;

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: dd 
State-Changed-When: Sun Jun 24 19:28:08 PDT 2001 
State-Changed-Why:  
The patch looks pretty good; however, could you please send it to 
audit@freebsd.org for further review? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=27029 
Responsible-Changed-From-To: freebsd-bugs->dd 
Responsible-Changed-By: dd 
Responsible-Changed-When: Mon Jun 25 23:30:16 PDT 2001 
Responsible-Changed-Why:  
I'll do this. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=27029 
State-Changed-From-To: feedback->analyzed 
State-Changed-By: dd 
State-Changed-When: Fri Jul 13 06:59:30 PDT 2001 
State-Changed-Why:  
patch applied, will mfc in a week or two 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=27029 
State-Changed-From-To: analyzed->closed 
State-Changed-By: dd 
State-Changed-When: Mon Jul 30 17:06:28 PDT 2001 
State-Changed-Why:  
MFC'd, thanks! 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=27029 
>Unformatted:
