zsh-workers
 help / color / mirror / code / Atom feed
From: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: strptime() on Cygwin requires _XOPEN_SOURCE
Date: Sat, 16 Jul 2016 14:34:30 +0900	[thread overview]
Message-ID: <AF9EE581-2824-44FB-9D14-90524F6B0FED@kba.biglobe.ne.jp> (raw)

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 @@
  *
  */
 
+#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
 
-#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.




             reply	other threads:[~2016-07-16  5:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-16  5:34 Jun T. [this message]
2016-07-18  8:41 ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AF9EE581-2824-44FB-9D14-90524F6B0FED@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).