Re: [PATCH 10/10] timegm: add portable implementation (Solaris support)
authorBlake Jones <blakej@foo.net>
Mon, 5 Nov 2012 18:33:12 +0000 (10:33 +1600)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:20 +0000 (09:50 -0800)
73/ee181548f61afc29f56c9dd7e79af9b36f31e5 [new file with mode: 0644]

diff --git a/73/ee181548f61afc29f56c9dd7e79af9b36f31e5 b/73/ee181548f61afc29f56c9dd7e79af9b36f31e5
new file mode 100644 (file)
index 0000000..21b8014
--- /dev/null
@@ -0,0 +1,107 @@
+Return-Path: <blakej@foo.net>\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 372A3431FB6\r
+       for <notmuch@notmuchmail.org>; Mon,  5 Nov 2012 10:33:21 -0800 (PST)\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 NI2KjQv8GENl for <notmuch@notmuchmail.org>;\r
+       Mon,  5 Nov 2012 10:33:20 -0800 (PST)\r
+Received: from foo.net (70-36-235-136.dsl.static.sonic.net [70.36.235.136])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 6B538431FAE\r
+       for <notmuch@notmuchmail.org>; Mon,  5 Nov 2012 10:33:20 -0800 (PST)\r
+Received: from foo.net (localhost [127.0.0.1])\r
+       by foo.net (8.14.5+Sun/8.14.5) with ESMTP id qA5IXCca010300;\r
+       Mon, 5 Nov 2012 10:33:12 -0800 (PST)\r
+To: Tomi Ollila <tomi.ollila@iki.fi>\r
+Subject: Re: [PATCH 10/10] timegm: add portable implementation (Solaris\r
+       support) \r
+In-Reply-To: Your message of "Mon, 05 Nov 2012 19:36:47 +0200."\r
+       <m2a9uwyms0.fsf@guru.guru-group.fi> \r
+Date: Mon, 05 Nov 2012 10:33:12 -0800\r
+Message-ID: <10299.1352140392@foo.net>\r
+From: Blake Jones <blakej@foo.net>\r
+X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2\r
+       (foo.net [127.0.0.1]); Mon, 05 Nov 2012 10:33:13 -0800 (PST)\r
+Cc: notmuch@notmuchmail.org\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: Mon, 05 Nov 2012 18:33:21 -0000\r
+\r
+>> The other approaches rely on letting libc do all the hard work of\r
+>> time zone manipulation, and then reading the tea leaves to find a way\r
+>> to undo it.\r
+> \r
+> Did you look at the gnu libc version -- I bet it is pretty hairy...\r
+\r
+I didn't look at either the GNU or the Solaris libc version.  But the\r
+file that implements the timezone handling (and localtime(), mktime(),\r
+etc.) in Solaris' libc is nearly 3000 lines of code, so I suspect\r
+there's an awful lot of stuff going on.\r
+\r
+>> For what it's worth, I used the attached program to test my\r
+>> implementation, and it passed.\r
+> \r
+> Thanks, It's nice to see your simple implementation passes these\r
+> tests...\r
+> \r
+> Just for curiosity: What do you think lacks in your timegm() that it\r
+> could not be promoted as 'complete timegm() solution'.\r
+\r
+Well, since there isn't a standard for timegm(), I'm comparing it to\r
+what glibc and BSD do.  The glibc mktime() man page, for example,\r
+mentions that mktime() modifies the fields of the tm structure as\r
+follows:\r
+\r
+    - tm_wday and tm_yday are set to values determined from the contents\r
+      of the other fields\r
+\r
+    - if structure members are outside their valid interval, they will\r
+      be normalized (so that, for example, 40 October is changed into 9\r
+      November)\r
+\r
+    - tm_isdst is set (regardless of its initial value) to a positive\r
+      value or to 0, respectively, to indicate whether DST is or is not\r
+      in effect at the specified time.\r
+\r
+    - Calling mktime() also sets the external variable tzname with\r
+      information about the current timezone. \r
+\r
+The corresponding timegm() man page for glibc doesn't say whether\r
+timegm() does the same thing, but I would assume it does.  The FreeBSD\r
+timegm() man page says that its version does update the fields of the\r
+"tm" structure, like its mktime() implementation.\r
+\r
+My implementation of timegm() does none of these things.  It treats the\r
+passed-in "struct tm" as constant, and just returns a valid time_t.  If\r
+you really wanted to make this mktime() be as capable as the ones in the\r
+GNU and BSD libc's, you could have it turn around and call gmtime_r() on\r
+the generated time_t, and pass the original "struct tm" to gmtime_r().\r
+Personally, I think this is unnecessary overloading of a function that\r
+does this one thing just fine, and in practice Jani's code doesn't seem\r
+to need it, so I didn't bother.\r
+\r
+> In any way, including this timegm() function in compat suits me fine.\r
+\r
+Great.\r
+\r
+Blake\r