[newlib-cygwin] winsup/cygwin/libc/strptime.cc(__strptime) add %s support to strptime

Corinna Vinschen corinna@sourceware.org
Fri Aug 25 09:40:00 GMT 2017


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8324ab5e2a08513cef052070f1e7cb228d28b7c8

commit 8324ab5e2a08513cef052070f1e7cb228d28b7c8
Author: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
Date:   Thu Aug 24 13:24:28 2017 -0600

    winsup/cygwin/libc/strptime.cc(__strptime) add %s support to strptime

Diff:
---
 winsup/cygwin/libc/strptime.cc | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/winsup/cygwin/libc/strptime.cc b/winsup/cygwin/libc/strptime.cc
index 62dca6e..7c6cc20 100644
--- a/winsup/cygwin/libc/strptime.cc
+++ b/winsup/cygwin/libc/strptime.cc
@@ -573,6 +573,26 @@ 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;
+			char *end;
+			save_errno save;
+
+			LEGAL_ALT(0);
+			sec = strtoll_l ((char *)bp, &end, 10, locale);
+			t = sec;
+			if (end == (char *)bp
+			    || errno != 0
+			    || t != sec
+			    || localtime_r (&t, tm) != tm)
+			    return NULL;
+			bp = (const unsigned char *)end;
+			ymd |= SET_YDAY | SET_WDAY | SET_YMD;
+			break;
+		    }
+
 		case 'U':	/* The week of year, beginning on sunday. */
 		case 'W':	/* The week of year, beginning on monday. */
 			/*



More information about the Cygwin-cvs mailing list