Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Jun 2001 12:01:03 +0400 (MSD)
From:      Maxim Konovalov <maxim@macomnet.ru>
To:        Dima Dorfman <dima@unixfreak.org>
Cc:        <freebsd-bugs@FreeBSD.org>, <thz@lennartz-electronic.de>
Subject:   Re: strptime: %s formatting missing (patch) 
Message-ID:  <Pine.BSF.4.33.0106281156340.46848-100000@news1.macomnet.ru>
In-Reply-To: <20010627231627.55D363E2F@bazooka.unixfreak.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 27 Jun 2001, Dima Dorfman wrote:

> Maxim Konovalov <maxim@macomnet.ru> writes:
> >
> > Just another patch:
>
> Perhaps I'm missing something, but what's the [functional] difference
> between this and the patch in PR 27029?  I don't like the "*buf - '0'"

There are no functional differences. I made it before I found PR.

> in this one; it doesn't look like it's locale-safe.  strtol does the
> same thing, but at least it's abstracted out.  The only thing I don't

I used it for consistency with other parts of strptime.c. This trick
is used everywhere in strptime.c.

> like about the latter is its use of memcpy, but that can be easily
> fixed with gmtime_r (note to original submitter: I'll make that change
> myself, don't bother sending another patch :-)).

Thank you.

>
> 					Dima Dorfman
> 					dima@unixfreak.org
>
> > --- strptime.c.orig	Wed Jun 27 16:09:11 2001
> > +++ strptime.c	Wed Jun 27 17:08:12 2001
> > @@ -86,6 +86,7 @@
> >  static char *
> >  _strptime(const char *buf, const char *fmt, struct tm *tm)
> >  {
> > +	long	l;
> >  	char	c;
> >  	const char *ptr;
> >  	int	i,
> > @@ -459,6 +460,16 @@
> >  			if (*buf != 0 && isspace((unsigned char)*buf))
> >  				while (*ptr != 0 && !isspace((unsigned char)*ptr))
> >  					ptr++;
> > +			break;
> > +
> > +		case 's':
> > +			for (l = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) {
> > +				l *= 10;
> > +				l += *buf - '0';
> > +			}
> > +
> > +			(void)localtime_r(&l, tm);
> > +
> >  			break;
> >
> >  		case 'Y':
> >
> > --
> > Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer
> > phone: +7 (095) 796-9079, mailto: maxim@macomnet.ru
> >
>
>

 - -maxim

-- 
Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer
phone: +7 (095) 796-9079, mailto: maxim@macomnet.ru


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?Pine.BSF.4.33.0106281156340.46848-100000>