From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6399 invoked by alias); 12 May 2011 11:12:25 -0000 Received: (qmail 6174 invoked by uid 22791); 12 May 2011 11:12:05 -0000 X-Spam-Check-By: sourceware.org Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.83/v0.83-20-g38e4449) with ESMTP; Thu, 12 May 2011 11:11:47 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 857CA2C0577; Thu, 12 May 2011 13:11:44 +0200 (CEST) Date: Thu, 12 May 2011 11:12:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: strptime doesn't fill in tm_wday and tm_yday. Message-ID: <20110512111144.GA10157@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <4DCAA2A0.6040506@lysator.liu.se> <20110511173434.GE11041@calimero.vinschen.de> <4DCBA1E0.7010502@lysator.liu.se> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <4DCBA1E0.7010502@lysator.liu.se> User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2011-05/txt/msg00180.txt.bz2 On May 12 11:01, Peter Rosin wrote: > Den 2011-05-11 19:34 skrev Corinna Vinschen: > > On May 11 16:52, Peter Rosin wrote: > >> Hello! > >> > >> The following STC hints at a problem in strptime: > ... > >> Opengroup has this to say about only filling in some fields: > >> > >> "It is unspecified whether multiple calls to strptime() > >> using the same tm structure will update the current > >> contents of the structure or overwrite all contents of > >> the structure. Conforming applications should make a > >> single call to strptime() with a format and all data > >> needed to completely specify the date and time being > >> converted." > >> > >> but I don't think it applies since indeed I do completely specify > >> the date in my strptime call. > > > > The Cygwin implementation of strptime is taken from NetBSD and enhanced > > only in terms of support for the E and O modifiers. The NetBSD and > > OpenBSD versions also support a non-POSIX format specifier %u (day of > > week, monday = 1). Other than that, the Cygwin strptime behaves exactly > > as the BSD implementation. tm_wday is only set if you specify %a, %A or > > %w. tm_yday is only set if you specify %j. > > > > Despite the example in the strptime man page of POSIX.1-2008, POSIX does > > not specify that strptime has to fill out tm fields which are not also > > specified in the format string. You should better memset the tm > > structure to 0 before calling strptime. > > Since you pulled out your "POSIX does not require it" card, I'm grasping > for my "Cygwin should behave like Linux" card. :-) I'm not so much pulling the POSIX card, but rather the BSD/upstream card. Consider this: The Cygwin version behaves pretty exactly like the BSD version since it *is* the BSD version. Should you ever have to port your application to Open/Free/NetBSD, you will see the exact same problem. Whatever we do with the Cygwin strptime eventually, you still have to consider that your application is *not* portable. > Seriously, of course I need to handle quirks in strptime if I want the > users of my application to be happy, but that does not mean that strptime > can't be a little bit more helpful on Cygwin. Maybe someone with a > copyright assignment can find some inspiration in the patch [1] I sent > for the newlib strptime? I'll take a look. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple