Re: Missing headers when forwarding html message as RFC822
[notmuch-archives.git] / d4 / acc59fead2a26911907727a14b95f8a5c6b3f8
1 Return-Path: <blakej@foo.net>\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 4B9C1431FBC\r
6         for <notmuch@notmuchmail.org>; Tue, 13 Nov 2012 18:10:17 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id j4Dq2EBz21i6 for <notmuch@notmuchmail.org>;\r
16         Tue, 13 Nov 2012 18:10:15 -0800 (PST)\r
17 Received: from foo.net (70-36-235-136.dsl.static.sonic.net [70.36.235.136])\r
18         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 11ECA431FC7\r
21         for <notmuch@notmuchmail.org>; Tue, 13 Nov 2012 18:10:11 -0800 (PST)\r
22 Received: from foo.net (localhost [127.0.0.1])\r
23         by foo.net (8.14.5+Sun/8.14.5) with ESMTP id qAE2A9pZ018919;\r
24         Tue, 13 Nov 2012 18:10:09 -0800 (PST)\r
25 Received: (from blakej@localhost)\r
26         by foo.net (8.14.5+Sun/8.14.5/Submit) id qAE2A99a018915;\r
27         Tue, 13 Nov 2012 18:10:09 -0800 (PST)\r
28 From: Blake Jones <blakej@foo.net>\r
29 To: notmuch@notmuchmail.org\r
30 Subject: [PATCH v3 06/10] strsep: check for availability (Solaris support)\r
31 Date: Tue, 13 Nov 2012 18:10:01 -0800\r
32 Message-Id: <1352859005-18631-7-git-send-email-blakej@foo.net>\r
33 X-Mailer: git-send-email 1.7.3.2\r
34 In-Reply-To: <1352859005-18631-1-git-send-email-blakej@foo.net>\r
35 References: <1352859005-18631-1-git-send-email-blakej@foo.net>\r
36 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2\r
37         (foo.net [127.0.0.1]); Tue, 13 Nov 2012 18:10:09 -0800 (PST)\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Wed, 14 Nov 2012 02:10:17 -0000\r
51 \r
52 Solaris does not ship a version of the strsep() function.  This change\r
53 adds a check to "configure" to see whether notmuch needs to provide its\r
54 own implementation, and if so, it uses the new version in\r
55 "compat/strsep.c" (which was copied from Mutt, and apparently before\r
56 that from glibc).\r
57 ---\r
58  compat/Makefile.local |    4 +++\r
59  compat/compat.h       |    4 +++\r
60  compat/have_strsep.c  |   10 +++++++\r
61  compat/strsep.c       |   65 +++++++++++++++++++++++++++++++++++++++++++++++++\r
62  configure             |   17 +++++++++++++\r
63  5 files changed, 100 insertions(+), 0 deletions(-)\r
64  create mode 100644 compat/have_strsep.c\r
65  create mode 100644 compat/strsep.c\r
66 \r
67 diff --git a/compat/Makefile.local b/compat/Makefile.local\r
68 index 13f16cd..2c4f65f 100644\r
69 --- a/compat/Makefile.local\r
70 +++ b/compat/Makefile.local\r
71 @@ -13,4 +13,8 @@ ifneq ($(HAVE_STRCASESTR),1)\r
72  notmuch_compat_srcs += $(dir)/strcasestr.c\r
73  endif\r
74  \r
75 +ifneq ($(HAVE_STRSEP),1)\r
76 +notmuch_compat_srcs += $(dir)/strsep.c\r
77 +endif\r
78 +\r
79  SRCS := $(SRCS) $(notmuch_compat_srcs)\r
80 diff --git a/compat/compat.h b/compat/compat.h\r
81 index e5f833e..0b5e465 100644\r
82 --- a/compat/compat.h\r
83 +++ b/compat/compat.h\r
84 @@ -46,6 +46,10 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp);\r
85  char* strcasestr(const char *haystack, const char *needle);\r
86  #endif /* !HAVE_STRCASESTR */\r
87  \r
88 +#if !HAVE_STRSEP\r
89 +char *strsep(char **stringp, const char *delim);\r
90 +#endif /* !HAVE_STRSEP */\r
91 +\r
92  /* Silence gcc warnings about unused results.  These warnings exist\r
93   * for a reason; any use of this needs to be justified. */\r
94  #ifdef __GNUC__\r
95 diff --git a/compat/have_strsep.c b/compat/have_strsep.c\r
96 new file mode 100644\r
97 index 0000000..5bd396c\r
98 --- /dev/null\r
99 +++ b/compat/have_strsep.c\r
100 @@ -0,0 +1,10 @@\r
101 +#define _GNU_SOURCE\r
102 +#include <string.h>\r
103 +\r
104 +int main()\r
105 +{\r
106 +    char *found;\r
107 +    char **stringp, const char *delim;\r
108 +\r
109 +    found = strsep(stringp, delim);\r
110 +}\r
111 diff --git a/compat/strsep.c b/compat/strsep.c\r
112 new file mode 100644\r
113 index 0000000..78ab9e7\r
114 --- /dev/null\r
115 +++ b/compat/strsep.c\r
116 @@ -0,0 +1,65 @@\r
117 +/* Copyright (C) 1992, 93, 96, 97, 98, 99, 2004 Free Software Foundation, Inc.\r
118 +   This file is part of the GNU C Library.\r
119 +\r
120 +   The GNU C Library is free software; you can redistribute it and/or\r
121 +   modify it under the terms of the GNU Lesser General Public\r
122 +   License as published by the Free Software Foundation; either\r
123 +   version 2.1 of the License, or (at your option) any later version.\r
124 +\r
125 +   The GNU C Library is distributed in the hope that it will be useful,\r
126 +   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
127 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
128 +   Lesser General Public License for more details.\r
129 +\r
130 +   You should have received a copy of the GNU Lesser General Public\r
131 +   License along with the GNU C Library; if not, write to the Free\r
132 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA\r
133 +   02111-1307 USA.  */\r
134 +\r
135 +#include <string.h>\r
136 +\r
137 +/* Taken from glibc 2.6.1 */\r
138 +\r
139 +char *strsep (char **stringp, const char *delim)\r
140 +{\r
141 +  char *begin, *end;\r
142 +\r
143 +  begin = *stringp;\r
144 +  if (begin == NULL)\r
145 +    return NULL;\r
146 +\r
147 +  /* A frequent case is when the delimiter string contains only one\r
148 +     character.  Here we don't need to call the expensive `strpbrk'\r
149 +     function and instead work using `strchr'.  */\r
150 +  if (delim[0] == '\0' || delim[1] == '\0')\r
151 +    {\r
152 +      char ch = delim[0];\r
153 +\r
154 +      if (ch == '\0')\r
155 +       end = NULL;\r
156 +      else\r
157 +       {\r
158 +         if (*begin == ch)\r
159 +           end = begin;\r
160 +         else if (*begin == '\0')\r
161 +           end = NULL;\r
162 +         else\r
163 +           end = strchr (begin + 1, ch);\r
164 +       }\r
165 +    }\r
166 +  else\r
167 +    /* Find the end of the token.  */\r
168 +    end = strpbrk (begin, delim);\r
169 +\r
170 +  if (end)\r
171 +    {\r
172 +      /* Terminate the token and set *STRINGP past NUL character.  */\r
173 +      *end++ = '\0';\r
174 +      *stringp = end;\r
175 +    }\r
176 +  else\r
177 +    /* No more delimiters; this is the last token.  */\r
178 +    *stringp = NULL;\r
179 +\r
180 +  return begin;\r
181 +}\r
182 diff --git a/configure b/configure\r
183 index d9a101f..ab8357f 100755\r
184 --- a/configure\r
185 +++ b/configure\r
186 @@ -512,6 +512,17 @@ else\r
187  fi\r
188  rm -f compat/have_strcasestr\r
189  \r
190 +printf "Checking for strsep... "\r
191 +if ${CC} -o compat/have_strsep "$srcdir"/compat/have_strsep.c > /dev/null 2>&1\r
192 +then\r
193 +    printf "Yes.\n"\r
194 +    have_strsep="1"\r
195 +else\r
196 +    printf "No (will use our own instead).\n"\r
197 +    have_strsep="0"\r
198 +fi\r
199 +rm -f compat/have_strsep\r
200 +\r
201  printf "Checking for standard version of getpwuid_r... "\r
202  if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1\r
203  then\r
204 @@ -723,6 +734,10 @@ HAVE_GETLINE = ${have_getline}\r
205  # build its own version)\r
206  HAVE_STRCASESTR = ${have_strcasestr}\r
207  \r
208 +# Whether the strsep function is available (if not, then notmuch will\r
209 +# build its own version)\r
210 +HAVE_STRSEP = ${have_strsep}\r
211 +\r
212  # Whether the getpwuid_r function is standards-compliant\r
213  # (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS\r
214  # to enable the standards-compliant version -- needed for Solaris)\r
215 @@ -782,12 +797,14 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\\r
216                    \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND)   \\\r
217                    \$(VALGRIND_CFLAGS)                                   \\\r
218                    -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)                 \\\r
219 +                  -DHAVE_STRSEP=\$(HAVE_STRSEP)                         \\\r
220                    -DSTD_GETPWUID=\$(STD_GETPWUID)                       \\\r
221                    -DSTD_ASCTIME=\$(STD_ASCTIME)\r
222  CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\\r
223                      \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\\r
224                      \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)             \\\r
225                      -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)               \\\r
226 +                    -DHAVE_STRSEP=\$(HAVE_STRSEP)                       \\\r
227                      -DSTD_GETPWUID=\$(STD_GETPWUID)                     \\\r
228                      -DSTD_ASCTIME=\$(STD_ASCTIME)\r
229  CONFIGURE_LDFLAGS =  \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS) \\\r
230 -- \r
231 1.7.3.2\r
232 \r