From owner-freebsd-bugs Wed Jun 27 16:16:32 2001 Delivered-To: freebsd-bugs@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 24EC837B405 for ; Wed, 27 Jun 2001 16:16:28 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from hornet.unixfreak.org (hornet [63.198.170.140]) by bazooka.unixfreak.org (Postfix) with ESMTP id 55D363E2F; Wed, 27 Jun 2001 16:16:27 -0700 (PDT) To: Maxim Konovalov Cc: freebsd-bugs@FreeBSD.org, thz@lennartz-electronic.de Subject: Re: strptime: %s formatting missing (patch) In-Reply-To: ; from maxim@macomnet.ru on "Wed, 27 Jun 2001 18:12:45 +0400 (MSD)" Date: Wed, 27 Jun 2001 16:16:27 -0700 From: Dima Dorfman Message-Id: <20010627231627.55D363E2F@bazooka.unixfreak.org> Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Maxim Konovalov 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