This is the mail archive of the cygwin-patches mailing list for the Cygwin 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]

[PATCH] winsup/cygwin/libc/strptime.cc(__strptime) add strptime %s


On 2017-07-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.

Attached patch to support %s in Cygwin winsup libc strptime.cc __strptime().

This also enables support for %s in dateutils package strptime(1).

In case the issue comes up, if the user wants to support %s as in date(1) with a
preceding @ flag, they just have to include that verbatim before the format as
in "@%s".

Testing revealed a separate issue with %F format which I will follow up on in a
different thread.

Similar patch coming for newlib.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

Attachment: 0001-winsup-cygwin-libc-strptime.cc-__strptime-add-strpti.patch
Description: Text document


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