bin/63064: strptime fails on %z

Stefan `Sec` Zehl sec at 42.org
Thu Feb 19 15:30:25 PST 2004


The following reply was made to PR bin/63064; it has been noted by GNATS.

From: Stefan `Sec` Zehl <sec at 42.org>
To: Makoto Matsushita <matusita at jp.FreeBSD.org>
Cc: bug-followup at FreeBSD.org
Subject: Re: bin/63064: strptime fails on %z
Date: Fri, 20 Feb 2004 00:21:50 +0100

 On Fri, Feb 20, 2004 at 03:21 +0900, Makoto Matsushita wrote:
 > Since '%z' format is not defined in th standard, it would be ok that
 > strptime(3) doesn't support '%z'.  Of course, it would be even better
 > that strptime(3) supports all format characters in strftime(3).
 
 I see. What about this patch?
 
 --- /usr/src/lib/libc/stdtime/strptime.c.org	Tue Mar 12 18:24:54 2002
 +++ /usr/src/lib/libc/stdtime/strptime.c	Thu Feb 19 23:54:43 2004
 @@ -492,6 +492,29 @@
  					ptr++;
  			break;
  
 +		case 'z':
 +			if(*buf==0 || (buf[0]!='+' && buf[0] != '-'))
 +				break;
 +
 +			{
 +			signed char sign;
 +
 +			sign = (buf++[0] == '-') ? -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);
 +			got_GMT=1;
 +
 +			}
 +			break;
 +
  		case 'Z':
  			{
  			const char *cp;
 
 
 CU,
     Sec
 -- 
 Cultures consist of people, and the traditional way to learn Unix culture is
 from other people and through the folklore, by osmosis.


More information about the freebsd-bugs mailing list