Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Sep 2008 16:50:03 GMT
From:      "N.J. Mann" <njm@njm.me.uk>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/63064: strptime(3) fails %z
Message-ID:  <200809231650.m8NGo3rH078321@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/63064; it has been noted by GNATS.

From: "N.J. Mann" <njm@njm.me.uk>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/63064: strptime(3) fails %z
Date: Tue, 23 Sep 2008 17:16:47 +0100

 --UlVJffcvxoiEqYs2
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 I have been using an updated version of this patch (see below for my own
 version) for over a year (6-STABLE and recently 7-STABLE) as part of my
 anti-spam measures (date(1) called from procmail(1)) - if the date of a
 message is more than one hour in the future or two days in the past it
 is suspicious - with great affect.  I would really like to see this, or
 something very similar, incorporated into the official version of
 strptime(3).
 
 
 --UlVJffcvxoiEqYs2
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="strptime.%z.patch.txt"
 
 --- lib/libc/stdtime/strptime.c~	2003-11-17 04:19:15.000000000 +0000
 +++ lib/libc/stdtime/strptime.c	2007-08-27 18:40:00.000000000 +0100
 @@ -490,6 +490,28 @@
  					ptr++;
  			break;
  
 +		case 'z':
 +			{
 +			int sign;
 +
 +			if (*buf != '+' && *buf != '-')
 +				break;
 +
 +			sign = (*buf++ == '-') ? -1 : +1;
 +
 +			len = 4;
 +			for (i = 0; len && *buf != 0 && isdigit((unsigned char)*buf); buf++) {
 +				i *= 10;
 +				i += *buf - '0';
 +				len--;
 +			}
 +
 +			tm->tm_hour -= sign * (i / 100);
 +			tm->tm_min -= sign * (i % 100);
 +			*GMTp = 1;
 +			}
 +			break;
 +
  		case 'Z':
  			{
  			const char *cp;
 
 --UlVJffcvxoiEqYs2--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809231650.m8NGo3rH078321>