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]

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


On Aug 23 12:51, Brian Inglis wrote:
> 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

> From 11f950597e7f66132a2ce6c8120f7199ba02316f Mon Sep 17 00:00:00 2001
> From: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
> Date: Tue, 22 Aug 2017 15:10:27 -0600
> Subject: [PATCH] winsup/cygwin/libc/strptime.cc(__strptime) add strptime %s
> 
> ---
>  winsup/cygwin/libc/strptime.cc | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/winsup/cygwin/libc/strptime.cc b/winsup/cygwin/libc/strptime.cc
> index 62dca6e5e..a7fef4985 100644
> --- a/winsup/cygwin/libc/strptime.cc
> +++ b/winsup/cygwin/libc/strptime.cc
> @@ -573,6 +573,29 @@ literal:
>  			bp = conv_num(bp, &tm->tm_sec, 0, 61, ALT_DIGITS);
>  			continue;
>  
> +		case 's' :	/* The seconds since Unix epoch - GNU extension */
> +		    {
> +			long long sec;
> +			time_t t;
> +			int errno_save;
> +			char *end;
> +
> +			LEGAL_ALT(0);
> +			errno_save = errno;

Funny enough, in other places in Cygwin we call this temp variable
"save_errno" :)


Alternatively, since you're in C++ code, you can use the save_errno
class, like this:

  {
    save_errno save;

    [do your thing]
  }

The destructor of save_errno will restore errno.

Since the code as such is fine, it's your choice if you want to stick
to it or use one of the above.  Just give the word.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature


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