Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Qmail-Scanner-Diagnostics: from rcpt-mqugw.biglobe.ne.jp by f.primenet.com.au (envelope-from <takimoto-j@kba.biglobe.ne.jp>, uid 7791) with qmail-scanner-2.11 
 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1.  
 Clear:RC:0(133.208.100.4):SA:0(-1.3/5.0):. 
 Processed in 0.137385 secs); 16 Jul 2016 05:35:12 -0000
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.3 required=5.0 tests=RP_MATCHES_RCVD,SPF_PASS
	autolearn=unavailable autolearn_force=no version=3.4.1
X-Envelope-From: takimoto-j@kba.biglobe.ne.jp
X-Qmail-Scanner-Mime-Attachments: |
X-Qmail-Scanner-Zip-Files: |
Received-SPF: pass (ns1.primenet.com.au: SPF record at spf01.biglobe.ne.jp designates 133.208.100.4 as permitted sender)
X-Biglobe-Sender: <takimoto-j@kba.biglobe.ne.jp>
From: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Subject: strptime() on Cygwin requires _XOPEN_SOURCE
Message-Id: <AF9EE581-2824-44FB-9D14-90524F6B0FED@kba.biglobe.ne.jp>
Date: Sat, 16 Jul 2016 14:34:30 +0900
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\))
X-Mailer: Apple Mail (2.1510)
X-Biglobe-Spnum: 51880
X-Seq: zsh-workers 38862

When building on the latest Cygwin, I get the following warning:

datetime.c:62:12: warning: implicit declaration of function 'strptime'

and if I use the newly built zsh to run
zsh% zmodload zsh/datetime
zsh% strftime -r '%Y' 2016
then the zsh coredumps.

Cygwin uses not glib but newlib, and feature test macros have been
overhauled in newlib-2.4 (a few months ago I guess).
It now requires _XOPEN_SOURCE to use strptime(3) in time.h.

A possible fix is to define _XOPEN_SOURCE in datetime.c (patch1 below).
Another possibility is to define _GNU_SOURCE in zsh_system.h (patch2).

Both work OK on the latest Cygwin, but I can't test on older Cygwin.
Maybe patch1 is better since it would have minimum side effects?

patch1:
diff --git a/Src/Modules/datetime.c b/Src/Modules/datetime.c
index bb82c54..b924392 100644
--- a/Src/Modules/datetime.c
+++ b/Src/Modules/datetime.c
@@ -27,6 +27,9 @@
  *
  */
=20
+#ifdef __CYGWIN__
+#define _XOPEN_SOURCE
+#endif
 #include "datetime.mdh"
 #include "datetime.pro"
 #include <time.h>


patch2:
diff --git a/Src/zsh_system.h b/Src/zsh_system.h
index 17c4c64..8e48a51 100644
--- a/Src/zsh_system.h
+++ b/Src/zsh_system.h
@@ -37,7 +37,7 @@
 #endif
 #endif
=20
-#if defined(__linux) || defined(__GNU__) || defined(__GLIBC__) || =
defined(LIBC_MUSL)
+#if defined(__linux) || defined(__GNU__) || defined(__GLIBC__) || =
defined(LIBC_MUSL) || defined(__CYGWIN__)
 /*
  * Turn on numerous extensions.
  * This is in order to get the functions for manipulating /dev/ptmx.



