From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129910 invoked by alias); 25 Jul 2017 17:38:11 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 129802 invoked by uid 89); 25 Jul 2017 17:38:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=game, HContent-Transfer-Encoding:8bit X-HELO: mail02.lgsinnovations.com Received: from mail02.lgsinnovations.com (HELO mail02.lgsinnovations.com) (63.149.110.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 25 Jul 2017 17:38:03 +0000 Subject: Re: Cygwin strptime() is missing "%s" which strftime() has To: References: <851e9a02-f7c2-25c4-f37d-64d17d5c6d54@SystematicSw.ab.ca> <20170725091613.GB14419@calimero.vinschen.de> From: Craig Howland Message-ID: <37908e9e-d806-af06-4d24-9b00d3878080@LGSInnovations.com> Date: Tue, 25 Jul 2017 17:38:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LGS-EX05.lgsdirect.com (135.22.48.227) To LGS-EX01.lgsdirect.com (135.22.77.164) X-IsSubscribed: yes X-SW-Source: 2017/txt/msg00642.txt.bz2 On 07/25/2017 12:47 PM, Brian Inglis wrote: > Don't we need to save and zero errno to distinguish a new error, and restore if > it stays zero, rather than just pick up the current value, and assume if it > is/was ERANGE it's bad? Yes, it needs to be set to 0 before calling strtol_l. POSIX does not define any errors for strptime(). Therefore by general rule it is permitted for it to set errno to be non-0. However, it is just as easy to always restore it instead of checking for non-0 (why add the check?). Always restoring also indirectly conveys the intent that strptime() is not required to set errno, that no errors are defined for it. On 07/25/2017 05:19 AM, Corinna Vinschen wrote: >> Neither %F nor %s are defined for strptime() in POSIX, so they should not be >> expected to be portable. (See >> http://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html) For >> that matter, %s is not defined for strftime(), either in POSIX or C99, even >> though it is in Newlib. If either of these are added, they should have >> gates (or at the very least, comments) to show they are extensions. (They >> appear to be GLIBC extensions, based on comments in the man page from a >> GLIBC-based system.) > Right, in theory. Just a bit late in the game I guess. We already > support %u, %V, %Z unconditionally. I checked the FreeBSD code and > they don't even bother to add comments ¯\_(ツ)_/¯ Not having done it right earlier is not a good reason to not do it better going forward. That said, OK, no compile-time gate since the other things are hard-coded, but let's at least have comments that they are extensions: + case 'F' : /* %Y-%m-%d (GNU extension) */ + case 's' : { /* (GNU extension) */ Craig