delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/05/12/05:02:07

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Message-ID: <4DCBA1E0.7010502@lysator.liu.se>
Date: Thu, 12 May 2011 11:01:20 +0200
From: Peter Rosin <peda AT lysator DOT liu DOT se>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: strptime doesn't fill in tm_wday and tm_yday.
References: <4DCAA2A0 DOT 6040506 AT lysator DOT liu DOT se> <20110511173434 DOT GE11041 AT calimero DOT vinschen DOT de>
In-Reply-To: <20110511173434.GE11041@calimero.vinschen.de>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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. :-)

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?

Cheers,
Peter

[1] http://sourceware.org/ml/newlib/2011/msg00177.html

--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019