--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 928C2429E3A\r
+ for <notmuch@notmuchmail.org>; Fri, 16 Aug 2013 23:24:14 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id ob8erNaTd8QR for <notmuch@notmuchmail.org>;\r
+ Fri, 16 Aug 2013 23:24:04 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 8ACEE431E82\r
+ for <notmuch@notmuchmail.org>; Fri, 16 Aug 2013 23:24:03 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id F2BFA100051;\r
+ Sat, 17 Aug 2013 09:23:53 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Vladimir.Marek@oracle.com, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 4/4] timegm: add portable implementation (Solaris support)\r
+In-Reply-To: <1376663897-24385-5-git-send-email-Vladimir.Marek@oracle.com>\r
+References: <1376663897-24385-1-git-send-email-Vladimir.Marek@oracle.com>\r
+ <1376663897-24385-5-git-send-email-Vladimir.Marek@oracle.com>\r
+User-Agent: Notmuch/0.16+3~g340c058 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Sat, 17 Aug 2013 09:23:53 +0300\r
+Message-ID: <m2eh9sn8cm.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+Cc: Vladimir Marek <vlmarek@volny.cz>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 17 Aug 2013 06:24:15 -0000\r
+\r
+Hi Vladimir, Blake and everyone else.\r
+\r
+This patch set looks good to me and tests (in Linux) pass. \r
+\r
+>From code point of view these patches are IMO pushable.\r
+\r
+There is just a small (but not so minor) thing missing;\r
+\r
+The timegm(.c) implementation lacks copyright & licensing\r
+information -- all the other compat files that are compiled\r
+into executable does have this information so it is best\r
+to keep this component also in line with those.\r
+\r
+If you (either of you) can send new patch 4/4 as a reply to\r
+this message it can be tracked along the first 3 in nmbug (*)\r
+\r
+http://nmbug.tethera.net/status/\r
+\r
+Tomi\r
+\r
+On Fri, Aug 16 2013, Vladimir.Marek@oracle.com wrote:\r
+\r
+> From: Blake Jones <blakej@foo.net>\r
+>\r
+> The timegm(3) function is a non-standard extension to libc which is\r
+> available in GNU libc and on some BSDs. Although SunOS had this\r
+> function in its libc, Solaris (unfortunately) removed it. This patch\r
+> implements a very simple version of timegm() which is good enough for\r
+> parse-time-string.c.\r
+>\r
+> Signed-off-by: Vladimir Marek <vlmarek@volny.cz>\r
+> ---\r
+> compat/Makefile.local | 4 ++++\r
+> compat/compat.h | 5 +++++\r
+> compat/have_timegm.c | 7 +++++++\r
+> compat/timegm.c | 37 +++++++++++++++++++++++++++++++++\r
+> configure | 11 ++++++++++\r
+> parse-time-string/parse-time-string.c | 1 +\r
+> 6 files changed, 65 insertions(+)\r
+> create mode 100644 compat/have_timegm.c\r
+> create mode 100644 compat/timegm.c\r
+>\r
+> diff --git a/compat/Makefile.local b/compat/Makefile.local\r
+> index 2c4f65f..b0d5417 100644\r
+> --- a/compat/Makefile.local\r
+> +++ b/compat/Makefile.local\r
+> @@ -17,4 +17,8 @@ ifneq ($(HAVE_STRSEP),1)\r
+> notmuch_compat_srcs += $(dir)/strsep.c\r
+> endif\r
+> \r
+> +ifneq ($(HAVE_TIMEGM),1)\r
+> +notmuch_compat_srcs += $(dir)/timegm.c\r
+> +endif\r
+> +\r
+> SRCS := $(SRCS) $(notmuch_compat_srcs)\r
+> diff --git a/compat/compat.h b/compat/compat.h\r
+> index ae762c3..5a402d5 100644\r
+> --- a/compat/compat.h\r
+> +++ b/compat/compat.h\r
+> @@ -57,6 +57,11 @@ char* strcasestr(const char *haystack, const char *needle);\r
+> char *strsep(char **stringp, const char *delim);\r
+> #endif /* !HAVE_STRSEP */\r
+> \r
+> +#if !HAVE_TIMEGM\r
+> +#include <time.h>\r
+> +time_t timegm (struct tm *tm);\r
+> +#endif /* !HAVE_TIMEGM */\r
+> +\r
+> /* Silence gcc warnings about unused results. These warnings exist\r
+> * for a reason; any use of this needs to be justified. */\r
+> #ifdef __GNUC__\r
+> diff --git a/compat/have_timegm.c b/compat/have_timegm.c\r
+> new file mode 100644\r
+> index 0000000..b62b793\r
+> --- /dev/null\r
+> +++ b/compat/have_timegm.c\r
+> @@ -0,0 +1,7 @@\r
+> +#include <time.h>\r
+> +#include "compat.h"\r
+> +\r
+> +int main()\r
+> +{\r
+> + return (int) timegm((struct tm *)0);\r
+> +}\r
+> diff --git a/compat/timegm.c b/compat/timegm.c\r
+> new file mode 100644\r
+> index 0000000..6d76164\r
+> --- /dev/null\r
+> +++ b/compat/timegm.c\r
+> @@ -0,0 +1,37 @@\r
+> +#include <time.h>\r
+> +#include "compat.h"\r
+> +\r
+> +static int\r
+> +leapyear (int year)\r
+> +{\r
+> + return ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0));\r
+> +}\r
+> +\r
+> +/*\r
+> + * This is a simple implementation of timegm() which does what is needed\r
+> + * by create_output() -- just turns the "struct tm" into a GMT time_t.\r
+> + * It does not normalize any of the fields of the "struct tm", nor does\r
+> + * it set tm_wday or tm_yday.\r
+> + */\r
+> +time_t\r
+> +timegm (struct tm *tm)\r
+> +{\r
+> + int monthlen[2][12] = {\r
+> + { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },\r
+> + { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },\r
+> + };\r
+> + int year, month, days;\r
+> +\r
+> + days = 365 * (tm->tm_year - 70);\r
+> + for (year = 70; year < tm->tm_year; year++) {\r
+> + if (leapyear(1900 + year)) {\r
+> + days++;\r
+> + }\r
+> + }\r
+> + for (month = 0; month < tm->tm_mon; month++) {\r
+> + days += monthlen[leapyear(1900 + year)][month];\r
+> + }\r
+> + days += tm->tm_mday - 1;\r
+> +\r
+> + return ((((days * 24) + tm->tm_hour) * 60 + tm->tm_min) * 60 + tm->tm_sec);\r
+> +}\r
+> diff --git a/configure b/configure\r
+> index ac44857..6166917 100755\r
+> --- a/configure\r
+> +++ b/configure\r
+> @@ -530,6 +530,17 @@ else\r
+> fi\r
+> rm -f compat/have_strsep\r
+> \r
+> +printf "Checking for timegm... "\r
+> +if ${CC} -o compat/have_timegm "$srcdir"/compat/have_timegm.c > /dev/null 2>&1\r
+> +then\r
+> + printf "Yes.\n"\r
+> + have_timegm="1"\r
+> +else\r
+> + printf "No (will use our own instead).\n"\r
+> + have_timegm="0"\r
+> +fi\r
+> +rm -f compat/have_timegm\r
+> +\r
+> printf "Checking for standard version of getpwuid_r... "\r
+> if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1\r
+> then\r
+> diff --git a/parse-time-string/parse-time-string.c b/parse-time-string/parse-time-string.c\r
+> index 584067d..ccad422 100644\r
+> --- a/parse-time-string/parse-time-string.c\r
+> +++ b/parse-time-string/parse-time-string.c\r
+> @@ -32,6 +32,7 @@\r
+> #include <sys/time.h>\r
+> #include <sys/types.h>\r
+> \r
+> +#include "compat.h"\r
+> #include "parse-time-string.h"\r
+> \r
+> /*\r
+> -- \r
+> 1.7.9.2\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r