Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 0e / 08fdd1b9c5bb1eb64a2ac27bc24ea63957a315
1 Return-Path: <Vladimir.Marek@oracle.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 23A0B431FD4\r
6         for <notmuch@notmuchmail.org>; Wed, 21 Aug 2013 04:10:23 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.299\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.299 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3, UNPARSEABLE_RELAY=0.001]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id 4DcII5jOMO0k for <notmuch@notmuchmail.org>;\r
17         Wed, 21 Aug 2013 04:10:15 -0700 (PDT)\r
18 Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 53F6D431FC2\r
22         for <notmuch@notmuchmail.org>; Wed, 21 Aug 2013 04:10:15 -0700 (PDT)\r
23 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94])\r
24         by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with\r
25         ESMTP id r7LBA74G024490\r
26         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);\r
27         Wed, 21 Aug 2013 11:10:07 GMT\r
28 Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231])\r
29         by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
30         r7LBA4sS001230\r
31         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);\r
32         Wed, 21 Aug 2013 11:10:06 GMT\r
33 Received: from abhmt103.oracle.com (abhmt103.oracle.com [141.146.116.55])\r
34         by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
35         r7LBA4QI000044; Wed, 21 Aug 2013 11:10:04 GMT\r
36 Received: from tbd.cz.oracle.com (/10.163.101.124)\r
37         by default (Oracle Beehive Gateway v4.0)\r
38         with ESMTP ; Wed, 21 Aug 2013 04:10:04 -0700\r
39 From: Vladimir.Marek@oracle.com\r
40 To: notmuch@notmuchmail.org\r
41 Subject: [PATCH 4/4] timegm: add portable implementation (Solaris support)\r
42 Date: Wed, 21 Aug 2013 13:09:54 +0200\r
43 Message-Id: <1377083394-29755-1-git-send-email-Vladimir.Marek@oracle.com>\r
44 X-Mailer: git-send-email 1.7.9.2\r
45 In-Reply-To: <m2eh9sn8cm.fsf@guru.guru-group.fi>\r
46 References: <m2eh9sn8cm.fsf@guru.guru-group.fi>\r
47 X-Source-IP: ucsinet22.oracle.com [156.151.31.94]\r
48 Cc: Vladimir Marek <vlmarek@volny.cz>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Wed, 21 Aug 2013 11:10:23 -0000\r
62 \r
63 From: Blake Jones <blakej@foo.net>\r
64 \r
65 The timegm(3) function is a non-standard extension to libc which is\r
66 available in GNU libc and on some BSDs.  Although SunOS had this\r
67 function in its libc, Solaris (unfortunately) removed it.  This patch\r
68 implements a very simple version of timegm() which is good enough for\r
69 parse-time-string.c.\r
70 \r
71 Signed-off-by: Vladimir Marek <vlmarek@volny.cz>\r
72 ---\r
73  compat/Makefile.local                 |    4 +++\r
74  compat/compat.h                       |    5 +++\r
75  compat/have_timegm.c                  |    7 +++++\r
76  compat/timegm.c                       |   56 +++++++++++++++++++++++++++++++++\r
77  configure                             |   11 +++++++\r
78  parse-time-string/parse-time-string.c |    1 +\r
79  6 files changed, 84 insertions(+)\r
80  create mode 100644 compat/have_timegm.c\r
81  create mode 100644 compat/timegm.c\r
82 \r
83 diff --git a/compat/Makefile.local b/compat/Makefile.local\r
84 index 2c4f65f..b0d5417 100644\r
85 --- a/compat/Makefile.local\r
86 +++ b/compat/Makefile.local\r
87 @@ -17,4 +17,8 @@ ifneq ($(HAVE_STRSEP),1)\r
88  notmuch_compat_srcs += $(dir)/strsep.c\r
89  endif\r
90  \r
91 +ifneq ($(HAVE_TIMEGM),1)\r
92 +notmuch_compat_srcs += $(dir)/timegm.c\r
93 +endif\r
94 +\r
95  SRCS := $(SRCS) $(notmuch_compat_srcs)\r
96 diff --git a/compat/compat.h b/compat/compat.h\r
97 index ae762c3..5a402d5 100644\r
98 --- a/compat/compat.h\r
99 +++ b/compat/compat.h\r
100 @@ -57,6 +57,11 @@ char* strcasestr(const char *haystack, const char *needle);\r
101  char *strsep(char **stringp, const char *delim);\r
102  #endif /* !HAVE_STRSEP */\r
103  \r
104 +#if !HAVE_TIMEGM\r
105 +#include <time.h>\r
106 +time_t timegm (struct tm *tm);\r
107 +#endif /* !HAVE_TIMEGM */\r
108 +\r
109  /* Silence gcc warnings about unused results.  These warnings exist\r
110   * for a reason; any use of this needs to be justified. */\r
111  #ifdef __GNUC__\r
112 diff --git a/compat/have_timegm.c b/compat/have_timegm.c\r
113 new file mode 100644\r
114 index 0000000..b62b793\r
115 --- /dev/null\r
116 +++ b/compat/have_timegm.c\r
117 @@ -0,0 +1,7 @@\r
118 +#include <time.h>\r
119 +#include "compat.h"\r
120 +\r
121 +int main()\r
122 +{\r
123 +    return (int) timegm((struct tm *)0);\r
124 +}\r
125 diff --git a/compat/timegm.c b/compat/timegm.c\r
126 new file mode 100644\r
127 index 0000000..a986887\r
128 --- /dev/null\r
129 +++ b/compat/timegm.c\r
130 @@ -0,0 +1,56 @@\r
131 +/* timegm.c --- Implementation of replacement timegm function.\r
132 +\r
133 +   This program is free software; you can redistribute it and/or\r
134 +   modify it under the terms of the GNU General Public License as\r
135 +   published by the Free Software Foundation; either version 3, or (at\r
136 +   your option) any later version.\r
137 +\r
138 +   This program is distributed in the hope that it will be useful, but\r
139 +   WITHOUT ANY WARRANTY; without even the implied warranty of\r
140 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
141 +   General Public License for more details.\r
142 +\r
143 +   You should have received a copy of the GNU General Public License\r
144 +   along with this program; if not, write to the Free Software\r
145 +   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
146 +   02110-1301, USA.  */\r
147 +\r
148 +/* Written by Blake Jones. */\r
149 +\r
150 +#include <time.h>\r
151 +#include "compat.h"\r
152 +\r
153 +static int\r
154 +leapyear (int year)\r
155 +{\r
156 +    return ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0));\r
157 +}\r
158 +\r
159 +/*\r
160 + * This is a simple implementation of timegm() which does what is needed\r
161 + * by create_output() -- just turns the "struct tm" into a GMT time_t.\r
162 + * It does not normalize any of the fields of the "struct tm", nor does\r
163 + * it set tm_wday or tm_yday.\r
164 + */\r
165 +time_t\r
166 +timegm (struct tm *tm)\r
167 +{\r
168 +    int        monthlen[2][12] = {\r
169 +       { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },\r
170 +       { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },\r
171 +    };\r
172 +    int        year, month, days;\r
173 +\r
174 +    days = 365 * (tm->tm_year - 70);\r
175 +    for (year = 70; year < tm->tm_year; year++) {\r
176 +       if (leapyear(1900 + year)) {\r
177 +           days++;\r
178 +       }\r
179 +    }\r
180 +    for (month = 0; month < tm->tm_mon; month++) {\r
181 +       days += monthlen[leapyear(1900 + year)][month];\r
182 +    }\r
183 +    days += tm->tm_mday - 1;\r
184 +\r
185 +    return ((((days * 24) + tm->tm_hour) * 60 + tm->tm_min) * 60 + tm->tm_sec);\r
186 +}\r
187 diff --git a/configure b/configure\r
188 index ac44857..6166917 100755\r
189 --- a/configure\r
190 +++ b/configure\r
191 @@ -530,6 +530,17 @@ else\r
192  fi\r
193  rm -f compat/have_strsep\r
194  \r
195 +printf "Checking for timegm... "\r
196 +if ${CC} -o compat/have_timegm "$srcdir"/compat/have_timegm.c > /dev/null 2>&1\r
197 +then\r
198 +    printf "Yes.\n"\r
199 +    have_timegm="1"\r
200 +else\r
201 +    printf "No (will use our own instead).\n"\r
202 +    have_timegm="0"\r
203 +fi\r
204 +rm -f compat/have_timegm\r
205 +\r
206  printf "Checking for standard version of getpwuid_r... "\r
207  if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1\r
208  then\r
209 diff --git a/parse-time-string/parse-time-string.c b/parse-time-string/parse-time-string.c\r
210 index 584067d..ccad422 100644\r
211 --- a/parse-time-string/parse-time-string.c\r
212 +++ b/parse-time-string/parse-time-string.c\r
213 @@ -32,6 +32,7 @@\r
214  #include <sys/time.h>\r
215  #include <sys/types.h>\r
216  \r
217 +#include "compat.h"\r
218  #include "parse-time-string.h"\r
219  \r
220  /*\r
221 -- \r
222 1.7.9.2\r
223 \r