From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16891 invoked by alias); 24 Jul 2017 21:36:29 -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 16261 invoked by uid 89); 24 Jul 2017 21:36:28 -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=gates, Hx-languages-length:2805, his, Attached 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; Mon, 24 Jul 2017 21:36:25 +0000 Subject: Re: Cygwin strptime() is missing "%s" which strftime() has To: References: <851e9a02-f7c2-25c4-f37d-64d17d5c6d54@SystematicSw.ab.ca> From: Craig Howland Message-ID: <8d88e863-e8c2-bed4-1b73-3f4a977c15d8@LGSInnovations.com> Date: Mon, 24 Jul 2017 21:36: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: <851e9a02-f7c2-25c4-f37d-64d17d5c6d54@SystematicSw.ab.ca> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit 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/msg00631.txt.bz2 On 07/24/2017 04:41 PM, Brian Inglis wrote: > On Mon, 24 Jul 2017 02:32:14 -0700, Corinna Vinschen wrote:> On Jul 23 22:07, > Brian Inglis wrote: >>> On 2017-07-23 20:09, Lavrentiev, Anton (NIH/NLM/NCBI) [C] wrote: >>>>> But that's just scanning a decimal integer to time_t. >>>> It's not a question of whether I can or can't convert a string into an >>>> integer, rather it's a question about portability of code that uses %s for >>>> both functions and expects it to work unchanged in the Cygwin environment. >>>> Also, strptime() was designed to be a reversal to strftime() (from the >>>> man-pages: the strptime() function is the converse function to >>>> strftime(3)) so both are supposed to "understand" the same basic set of >>>> formats. Because of Cygwin's strptime() missing "%s", the following also >>>> does not work even from command line: >>>> >>>> $ date +"%s" | strptime "%s" >>> Attached diff for proposed strptime %s and %F support. >>> Let me know if you would prefer a different approach before I submit a git >>> format-patch. >> Approach looks good, so please send the patch to the newlib mailing list >> with a nice log message. > Thinking just "add strptime %F %s support"; involved because I use date and > dateutils a lot in shell scripts; also hope this will also allow %F %s support > in dateutils strptime, which the OP just added to his cygwin posts. > >> In fact, just send patches like these immediately in the right format to >> the right list. Chances are good that the patch is taken without further >> ado and you skip the part where you have to send the patch twice :) > Darn, originated on cygwin list, forwarded to cygwin-patches, forgot this should > have gone to newlib list. > >> In this case I have a nit, but this should be discussed on the right >> mailing list so all affected parties can chime in. Hint: strtoimax is >> not available on all platforms yet (patches still in limbo)... > Figured there would need to be some tweaks for newlib platforms, compilers, and > style, so made some changes, attached another diff for discussion, before > submitting a patch. > Let me know if you want conditionals or declarations changed, hoisted to > function start, case braces removed, other issues? > 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.) Craig