This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin strptime() is missing "%s" which strftime() has


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

Attachment: 0001-add-strptime-%s-%F.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]