Re: notmuch and "mute" -- useful to anyone?
[notmuch-archives.git] / 24 / 12c55eae6fadba7cb85abff8cd524200cf3848
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 9137741647F\r
6         for <notmuch@notmuchmail.org>; Mon,  9 Apr 2012 03:39:53 -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 6EhFg7132Yzs for <notmuch@notmuchmail.org>;\r
17         Mon,  9 Apr 2012 03:39:52 -0700 (PDT)\r
18 Received: from acsinet14.oracle.com (acsinet14.oracle.com [141.146.126.236])\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 C08E841647C\r
22         for <notmuch@notmuchmail.org>; Mon,  9 Apr 2012 03:39:52 -0700 (PDT)\r
23 Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227])\r
24         by acsinet14.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with\r
25         ESMTP id q39AIinF002233\r
26         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)\r
27         for <notmuch@notmuchmail.org>; Mon, 9 Apr 2012 10:18:44 GMT\r
28 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237])\r
29         by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with\r
30         ESMTP id q39AIh6J031164\r
31         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);\r
32         Mon, 9 Apr 2012 10:18:43 GMT\r
33 Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158])\r
34         by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
35         q39AIgD6012290\r
36         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);\r
37         Mon, 9 Apr 2012 10:18:42 GMT\r
38 Received: from abhmt120.oracle.com (abhmt120.oracle.com [141.146.116.72])\r
39         by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id\r
40         q39AIfMD022174; Mon, 9 Apr 2012 05:18:42 -0500\r
41 Received: from pub.czech.sun.com (/10.163.20.32)\r
42         by default (Oracle Beehive Gateway v4.0)\r
43         with ESMTP ; Mon, 09 Apr 2012 03:18:41 -0700\r
44 From: Vladimir.Marek@oracle.com\r
45 To: notmuch@notmuchmail.org\r
46 Subject: [PATCH 3/4] Private strsep implementation\r
47 Date: Mon,  9 Apr 2012 12:17:44 +0200\r
48 Message-Id: <1333966665-10469-4-git-send-email-Vladimir.Marek@oracle.com>\r
49 X-Mailer: git-send-email 1.7.3.2\r
50 In-Reply-To: <1333966665-10469-1-git-send-email-Vladimir.Marek@oracle.com>\r
51 References: <1333966665-10469-1-git-send-email-Vladimir.Marek@oracle.com>\r
52 X-Source-IP: acsinet21.oracle.com [141.146.126.237]\r
53 X-Auth-Type: Internal IP\r
54 X-CT-RefId: str=0001.0A090202.4F82B783.00A1,ss=1,re=0.000,fgs=0\r
55 Cc: Vladimir Marek <vlmarek@volny.cz>\r
56 X-BeenThere: notmuch@notmuchmail.org\r
57 X-Mailman-Version: 2.1.13\r
58 Precedence: list\r
59 List-Id: "Use and development of the notmuch mail system."\r
60         <notmuch.notmuchmail.org>\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
64 List-Post: <mailto:notmuch@notmuchmail.org>\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
68 X-List-Received-Date: Mon, 09 Apr 2012 10:39:53 -0000\r
69 \r
70 From: Vladimir Marek <vlmarek@volny.cz>\r
71 \r
72 strsep is not available on Solaris 10, so we stole the one used by mutt.\r
73 \r
74 Signed-off-by: Vladimir Marek <vlmarek@volny.cz>\r
75 ---\r
76  compat/Makefile.local |    4 +++\r
77  compat/compat.h       |    4 +++\r
78  compat/have_strsep.c  |   10 +++++++\r
79  compat/strsep.c       |   65 +++++++++++++++++++++++++++++++++++++++++++++++++\r
80  configure             |   21 ++++++++++++++-\r
81  5 files changed, 102 insertions(+), 2 deletions(-)\r
82  create mode 100644 compat/have_strsep.c\r
83  create mode 100644 compat/strsep.c\r
84 \r
85 diff --git a/compat/Makefile.local b/compat/Makefile.local\r
86 index 13f16cd..2c4f65f 100644\r
87 --- a/compat/Makefile.local\r
88 +++ b/compat/Makefile.local\r
89 @@ -13,4 +13,8 @@ ifneq ($(HAVE_STRCASESTR),1)\r
90  notmuch_compat_srcs += $(dir)/strcasestr.c\r
91  endif\r
92  \r
93 +ifneq ($(HAVE_STRSEP),1)\r
94 +notmuch_compat_srcs += $(dir)/strsep.c\r
95 +endif\r
96 +\r
97  SRCS := $(SRCS) $(notmuch_compat_srcs)\r
98 diff --git a/compat/compat.h b/compat/compat.h\r
99 index b2e2736..cf8d56d 100644\r
100 --- a/compat/compat.h\r
101 +++ b/compat/compat.h\r
102 @@ -46,6 +46,10 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp);\r
103  char* strcasestr(const char *haystack, const char *needle);\r
104  #endif /* !HAVE_STRCASESTR */\r
105  \r
106 +#if !HAVE_STRSEP\r
107 +char *strsep(char **stringp, const char *delim);\r
108 +#endif /* !HAVE_STRSEP */\r
109 +\r
110  /* Silence gcc warnings about unused results.  These warnings exist\r
111   * for a reason; any use of this needs to be justified. */\r
112  #ifdef __GNUC__\r
113 diff --git a/compat/have_strsep.c b/compat/have_strsep.c\r
114 new file mode 100644\r
115 index 0000000..5bd396c\r
116 --- /dev/null\r
117 +++ b/compat/have_strsep.c\r
118 @@ -0,0 +1,10 @@\r
119 +#define _GNU_SOURCE\r
120 +#include <string.h>\r
121 +\r
122 +int main()\r
123 +{\r
124 +    char *found;\r
125 +    char **stringp, const char *delim;\r
126 +\r
127 +    found = strsep(stringp, delim);\r
128 +}\r
129 diff --git a/compat/strsep.c b/compat/strsep.c\r
130 new file mode 100644\r
131 index 0000000..78ab9e7\r
132 --- /dev/null\r
133 +++ b/compat/strsep.c\r
134 @@ -0,0 +1,65 @@\r
135 +/* Copyright (C) 1992, 93, 96, 97, 98, 99, 2004 Free Software Foundation, Inc.\r
136 +   This file is part of the GNU C Library.\r
137 +\r
138 +   The GNU C Library is free software; you can redistribute it and/or\r
139 +   modify it under the terms of the GNU Lesser General Public\r
140 +   License as published by the Free Software Foundation; either\r
141 +   version 2.1 of the License, or (at your option) any later version.\r
142 +\r
143 +   The GNU C Library is distributed in the hope that it will be useful,\r
144 +   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
145 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
146 +   Lesser General Public License for more details.\r
147 +\r
148 +   You should have received a copy of the GNU Lesser General Public\r
149 +   License along with the GNU C Library; if not, write to the Free\r
150 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA\r
151 +   02111-1307 USA.  */\r
152 +\r
153 +#include <string.h>\r
154 +\r
155 +/* Taken from glibc 2.6.1 */\r
156 +\r
157 +char *strsep (char **stringp, const char *delim)\r
158 +{\r
159 +  char *begin, *end;\r
160 +\r
161 +  begin = *stringp;\r
162 +  if (begin == NULL)\r
163 +    return NULL;\r
164 +\r
165 +  /* A frequent case is when the delimiter string contains only one\r
166 +     character.  Here we don't need to call the expensive `strpbrk'\r
167 +     function and instead work using `strchr'.  */\r
168 +  if (delim[0] == '\0' || delim[1] == '\0')\r
169 +    {\r
170 +      char ch = delim[0];\r
171 +\r
172 +      if (ch == '\0')\r
173 +       end = NULL;\r
174 +      else\r
175 +       {\r
176 +         if (*begin == ch)\r
177 +           end = begin;\r
178 +         else if (*begin == '\0')\r
179 +           end = NULL;\r
180 +         else\r
181 +           end = strchr (begin + 1, ch);\r
182 +       }\r
183 +    }\r
184 +  else\r
185 +    /* Find the end of the token.  */\r
186 +    end = strpbrk (begin, delim);\r
187 +\r
188 +  if (end)\r
189 +    {\r
190 +      /* Terminate the token and set *STRINGP past NUL character.  */\r
191 +      *end++ = '\0';\r
192 +      *stringp = end;\r
193 +    }\r
194 +  else\r
195 +    /* No more delimiters; this is the last token.  */\r
196 +    *stringp = NULL;\r
197 +\r
198 +  return begin;\r
199 +}\r
200 diff --git a/configure b/configure\r
201 index 6870341..a06df7c 100755\r
202 --- a/configure\r
203 +++ b/configure\r
204 @@ -486,6 +486,17 @@ else\r
205  fi\r
206  rm -f compat/have_strcasestr\r
207  \r
208 +printf "Checking for strsep... "\r
209 +if ${CC} -o compat/have_strsep "$srcdir"/compat/have_strsep > /dev/null 2>&1\r
210 +then\r
211 +    printf "Yes.\n"\r
212 +    have_strsep=1\r
213 +else\r
214 +    printf "No (will use our own instead).\n"\r
215 +    have_strsep=0\r
216 +fi\r
217 +rm -f compat/have_strsep\r
218 +\r
219  printf "int main(void){return 0;}\n" > minimal.c\r
220  \r
221  printf "Checking for rpath support... "\r
222 @@ -645,6 +656,10 @@ HAVE_GETLINE = ${have_getline}\r
223  # build its own version)\r
224  HAVE_STRCASESTR = ${have_strcasestr}\r
225  \r
226 +# Whether the strsep function is available (if not, then notmuch will\r
227 +# build its own version)\r
228 +HAVE_STRSEP = ${have_strsep}\r
229 +\r
230  # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS\r
231  PLATFORM = ${platform}\r
232  \r
233 @@ -689,10 +704,12 @@ WITH_ZSH = ${WITH_ZSH}\r
234  # Combined flags for compiling and linking against all of the above\r
235  CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\\r
236                    \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND)   \\\r
237 -                  \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)\r
238 +                  \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\\r
239 +                  -DHAVE_STRSEP=\$(HAVE_STRSEP)\r
240  CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\\r
241                      \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\\r
242                      \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)             \\\r
243 -                     -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)\r
244 +                    -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\\r
245 +                    -DHAVE_STRSEP=\$(HAVE_STRSEP)\r
246  CONFIGURE_LDFLAGS =  \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)\r
247  EOF\r
248 -- \r
249 1.7.3.2\r
250 \r