From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5094 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: strptime problems Date: Thu, 8 May 2014 18:42:36 +0200 Message-ID: <20140508164236.GS12324@port70.net> References: <20140508043214.GA6149@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1399567376 31738 80.91.229.3 (8 May 2014 16:42:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 May 2014 16:42:56 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-5100-gllmg-musl=m.gmane.org@lists.openwall.com Thu May 08 18:42:50 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WiRPF-0006UQ-7Z for gllmg-musl@plane.gmane.org; Thu, 08 May 2014 18:42:49 +0200 Original-Received: (qmail 5209 invoked by uid 550); 8 May 2014 16:42:48 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 5201 invoked from network); 8 May 2014 16:42:48 -0000 Content-Disposition: inline In-Reply-To: <20140508043214.GA6149@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:5094 Archived-At: * Rich Felker [2014-05-08 00:32:14 -0400]: > to get it done now. However I'm not clear on what the behavior of > strptime should be when reading "derived" fields that don't actually > correspond to anything in the "struct tm". Should it just parse and > ignore them, or should it somehow convert back? The week-based-year > stuff is probably the biggest question but there are others too. strptime seems to be underspecified, it's not clear what happens in case of inconsistent input, what tm_* fields should be filled out, etc glibc sets tm.tm_wday when it can be calculated, musl doesn't glibc sets __tm_gmtoff so strptime depends on the current tz setting glibc supports %s in strptime (non-posix), musl doesn't in musl invalid format strings don't fail now in the numeric_range logic i think a <= can be changed into < --- a/src/time/strptime.c +++ b/src/time/strptime.c @@ -138,10 +138,12 @@ char *strptime(const char *restrict s, const char *restrict f, struct tm *restri case '%': if (*s++ != '%') return 0; break; + default: + return 0; numeric_range: if (!isdigit(*s)) return 0; *dest = 0; - for (i=1; i<=min+range && isdigit(*s); i*=10) + for (i=1; i= (unsigned)range) return 0; *dest -= adj;