Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jun 2001 16:16:27 -0700
From:      Dima Dorfman <dima@unixfreak.org>
To:        Maxim Konovalov <maxim@macomnet.ru>
Cc:        freebsd-bugs@FreeBSD.org, thz@lennartz-electronic.de
Subject:   Re: strptime: %s formatting missing (patch) 
Message-ID:  <20010627231627.55D363E2F@bazooka.unixfreak.org>
In-Reply-To: <Pine.BSF.4.33.0106271807360.70033-100000@news1.macomnet.ru>; from maxim@macomnet.ru on "Wed, 27 Jun 2001 18:12:45 %2B0400 (MSD)"

next in thread | previous in thread | raw e-mail | index | archive | help
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'"
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
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 :-)).

					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
> 

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?20010627231627.55D363E2F>