From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30128 invoked by alias); 24 Jul 2017 20:42:01 -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 29275 invoked by uid 89); 24 Jul 2017 20:42:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=cygwin-patches, cygwinpatches, Approach X-HELO: smtp-out-no.shaw.ca Received: from smtp-out-no.shaw.ca (HELO smtp-out-no.shaw.ca) (64.59.134.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Jul 2017 20:41:58 +0000 Received: from [192.168.1.100] ([24.64.240.204]) by shaw.ca with SMTP id ZkAudKDBOM9gtZkAvdS11d; Mon, 24 Jul 2017 14:41:57 -0600 X-Authority-Analysis: v=2.2 cv=a+JAzQaF c=1 sm=1 tr=0 a=MVEHjbUiAHxQW0jfcDq5EA==:117 a=MVEHjbUiAHxQW0jfcDq5EA==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=0Nv4YW_xbRoqaKzFsrYA:9 a=QEXdDO2ut3YA:10 a=ct2b9mZHzRgieNl42vkA:9 a=CdiWusdWvyIA:10 Reply-To: Brian.Inglis@SystematicSw.ab.ca Subject: Re: Cygwin strptime() is missing "%s" which strftime() has References: To: newlib@sourceware.org From: Brian Inglis Message-ID: <851e9a02-f7c2-25c4-f37d-64d17d5c6d54@SystematicSw.ab.ca> Date: Mon, 24 Jul 2017 20:42:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------207D557E61FF1E33068A4549" X-CMAE-Envelope: MS4wfHJR3WKOMp8Uhp5RyLq2xtHtBVjSpf5MaiWOBxOwZk9FsI0y2scCqz7Zdf2UAsxRQLt+SPvwBR84VptMyjSdKka4OJnjyMB3iiLcf0DnoVWvh5hW1rZU hb7Znd4O9NogThG8vkrTzpr5CO25EcrIJ5EIgLwORRmefQIIYxLfrxsmyhR22k2kwqywI5c5fjVEsA== X-IsSubscribed: yes X-SW-Source: 2017/txt/msg00630.txt.bz2 This is a multi-part message in MIME format. --------------207D557E61FF1E33068A4549 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 2234 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? -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada --------------207D557E61FF1E33068A4549 Content-Type: text/plain; charset=UTF-8; name="0001-add-strptime-%s-%F.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="0001-add-strptime-%s-%F.patch" Content-length: 2030 ZGlmZiAtLWdpdCBhL25ld2xpYi9saWJjL3RpbWUvc3RycHRpbWUuYyBiL25l d2xpYi9saWJjL3RpbWUvc3RycHRpbWUuYwppbmRleCBjMDg2MWViODcuLjEx MjIyN2U0MCAxMDA2NDQKLS0tIGEvbmV3bGliL2xpYmMvdGltZS9zdHJwdGlt ZS5jCisrKyBiL25ld2xpYi9saWJjL3RpbWUvc3RycHRpbWUuYwpAQCAtMzgs NiArMzgsOCBAQAogI2luY2x1ZGUgPHN0cmluZ3MuaD4KICNpbmNsdWRlIDxj dHlwZS5oPgogI2luY2x1ZGUgPHN0ZGxpYi5oPgorI2luY2x1ZGUgPGludHR5 cGVzLmg+CisjaW5jbHVkZSA8bGltaXRzLmg+CiAjaW5jbHVkZSAiLi4vbG9j YWxlL3NldGxvY2FsZS5oIgogCiAjZGVmaW5lIF9jdGxvYyh4KSAoX0N1cnJl bnRUaW1lTG9jYWxlLT54KQpAQCAtMjMwLDYgKzIzMiwxMyBAQCBzdHJwdGlt ZV9sIChjb25zdCBjaGFyICpidWYsIGNvbnN0IGNoYXIgKmZvcm1hdCwgc3Ry dWN0IHRtICp0aW1lcHRyLAogCQlidWYgPSBzOwogCQl5bWQgfD0gU0VUX01E QVk7CiAJCWJyZWFrOworCSAgICBjYXNlICdGJyA6CQkvKiAlWS0lbS0lZCAq LworCQlzID0gc3RycHRpbWVfbCAoYnVmLCAiJVktJW0tJWQiLCB0aW1lcHRy LCBsb2NhbGUpOworCQlpZiAocyA9PSBOVUxMKQorCQkg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SBzdHJ0b2xfbCAoYnVmLCAmcywgMTAsIGxvY2FsZSk7CiAJCWlm IChzID09IGJ1ZikK --------------207D557E61FF1E33068A4549--