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 ECBE6429E29
\r
6 for <notmuch@notmuchmail.org>; Mon, 6 May 2013 08:16:55 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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
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 ztnn-hQRPrym for <notmuch@notmuchmail.org>;
\r
17 Mon, 6 May 2013 08:16:52 -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 71CA5431E82
\r
22 for <notmuch@notmuchmail.org>; Mon, 6 May 2013 08:16:36 -0700 (PDT)
\r
23 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237])
\r
24 by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with
\r
25 ESMTP id r46FGRrf001034
\r
26 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
\r
27 Mon, 6 May 2013 15:16:28 GMT
\r
28 Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85])
\r
29 by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id
\r
31 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL);
\r
32 Mon, 6 May 2013 15:16:28 GMT
\r
33 Received: from abhmt119.oracle.com (abhmt119.oracle.com [141.146.116.71])
\r
34 by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id
\r
35 r46FGRxt027181; Mon, 6 May 2013 15:16:27 GMT
\r
36 Received: from vi64-x3-2e-prg06.cz.oracle.com (/10.163.102.127)
\r
37 by default (Oracle Beehive Gateway v4.0)
\r
38 with ESMTP ; Mon, 06 May 2013 08:16:26 -0700
\r
39 From: Vladimir.Marek@oracle.com
\r
40 To: notmuch@notmuchmail.org
\r
41 Subject: [PATCH 3/4] strsep: check for availability (Solaris support)
\r
42 Date: Mon, 6 May 2013 17:16:01 +0200
\r
43 Message-Id: <1367853362-11846-4-git-send-email-Vladimir.Marek@oracle.com>
\r
44 X-Mailer: git-send-email 1.7.9.2
\r
45 In-Reply-To: <1367853362-11846-1-git-send-email-Vladimir.Marek@oracle.com>
\r
46 References: <1367853362-11846-1-git-send-email-Vladimir.Marek@oracle.com>
\r
47 X-Source-IP: acsinet21.oracle.com [141.146.126.237]
\r
48 Cc: Vladimir Marek <vlmarek@volny.cz>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\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: Mon, 06 May 2013 15:16:56 -0000
\r
63 From: Blake Jones <blakej@foo.net>
\r
65 Solaris does not ship a version of the strsep() function. This change
\r
66 adds a check to "configure" to see whether notmuch needs to provide its
\r
67 own implementation, and if so, it uses the new version in
\r
68 "compat/strsep.c" (which was copied from Mutt, and apparently before
\r
71 Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
\r
73 compat/Makefile.local | 4 +++
\r
74 compat/compat.h | 4 +++
\r
75 compat/have_strsep.c | 11 +++++++++
\r
76 compat/strsep.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
\r
77 configure | 17 +++++++++++++
\r
78 5 files changed, 101 insertions(+)
\r
79 create mode 100644 compat/have_strsep.c
\r
80 create mode 100644 compat/strsep.c
\r
82 diff --git a/compat/Makefile.local b/compat/Makefile.local
\r
83 index 13f16cd..2c4f65f 100644
\r
84 --- a/compat/Makefile.local
\r
85 +++ b/compat/Makefile.local
\r
86 @@ -13,4 +13,8 @@ ifneq ($(HAVE_STRCASESTR),1)
\r
87 notmuch_compat_srcs += $(dir)/strcasestr.c
\r
90 +ifneq ($(HAVE_STRSEP),1)
\r
91 +notmuch_compat_srcs += $(dir)/strsep.c
\r
94 SRCS := $(SRCS) $(notmuch_compat_srcs)
\r
95 diff --git a/compat/compat.h b/compat/compat.h
\r
96 index 0c4ac66..ae762c3 100644
\r
97 --- a/compat/compat.h
\r
98 +++ b/compat/compat.h
\r
99 @@ -53,6 +53,10 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp);
\r
100 char* strcasestr(const char *haystack, const char *needle);
\r
101 #endif /* !HAVE_STRCASESTR */
\r
104 +char *strsep(char **stringp, const char *delim);
\r
105 +#endif /* !HAVE_STRSEP */
\r
107 /* Silence gcc warnings about unused results. These warnings exist
\r
108 * for a reason; any use of this needs to be justified. */
\r
110 diff --git a/compat/have_strsep.c b/compat/have_strsep.c
\r
111 new file mode 100644
\r
112 index 0000000..2abab81
\r
114 +++ b/compat/have_strsep.c
\r
116 +#define _GNU_SOURCE
\r
117 +#include <string.h>
\r
123 + const char *delim;
\r
125 + found = strsep(stringp, delim);
\r
127 diff --git a/compat/strsep.c b/compat/strsep.c
\r
128 new file mode 100644
\r
129 index 0000000..78ab9e7
\r
131 +++ b/compat/strsep.c
\r
133 +/* Copyright (C) 1992, 93, 96, 97, 98, 99, 2004 Free Software Foundation, Inc.
\r
134 + This file is part of the GNU C Library.
\r
136 + The GNU C Library is free software; you can redistribute it and/or
\r
137 + modify it under the terms of the GNU Lesser General Public
\r
138 + License as published by the Free Software Foundation; either
\r
139 + version 2.1 of the License, or (at your option) any later version.
\r
141 + The GNU C Library is distributed in the hope that it will be useful,
\r
142 + but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
143 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
144 + Lesser General Public License for more details.
\r
146 + You should have received a copy of the GNU Lesser General Public
\r
147 + License along with the GNU C Library; if not, write to the Free
\r
148 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
\r
149 + 02111-1307 USA. */
\r
151 +#include <string.h>
\r
153 +/* Taken from glibc 2.6.1 */
\r
155 +char *strsep (char **stringp, const char *delim)
\r
157 + char *begin, *end;
\r
159 + begin = *stringp;
\r
160 + if (begin == NULL)
\r
163 + /* A frequent case is when the delimiter string contains only one
\r
164 + character. Here we don't need to call the expensive `strpbrk'
\r
165 + function and instead work using `strchr'. */
\r
166 + if (delim[0] == '\0' || delim[1] == '\0')
\r
168 + char ch = delim[0];
\r
174 + if (*begin == ch)
\r
176 + else if (*begin == '\0')
\r
179 + end = strchr (begin + 1, ch);
\r
183 + /* Find the end of the token. */
\r
184 + end = strpbrk (begin, delim);
\r
188 + /* Terminate the token and set *STRINGP past NUL character. */
\r
193 + /* No more delimiters; this is the last token. */
\r
198 diff --git a/configure b/configure
\r
199 index 99ec71a..5243cac 100755
\r
202 @@ -517,6 +517,17 @@ else
\r
204 rm -f compat/have_strcasestr
\r
206 +printf "Checking for strsep... "
\r
207 +if ${CC} -o compat/have_strsep "$srcdir"/compat/have_strsep.c > /dev/null 2>&1
\r
212 + printf "No (will use our own instead).\n"
\r
215 +rm -f compat/have_strsep
\r
217 printf "Checking for standard version of getpwuid_r... "
\r
218 if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1
\r
220 @@ -698,6 +709,10 @@ HAVE_GETLINE = ${have_getline}
\r
221 # build its own version)
\r
222 HAVE_STRCASESTR = ${have_strcasestr}
\r
224 +# Whether the strsep function is available (if not, then notmuch will
\r
225 +# build its own version)
\r
226 +HAVE_STRSEP = ${have_strsep}
\r
228 # Whether the getpwuid_r function is standards-compliant
\r
229 # (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS
\r
230 # to enable the standards-compliant version -- needed for Solaris)
\r
231 @@ -754,12 +769,14 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
\r
232 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
\r
233 \$(VALGRIND_CFLAGS) \\
\r
234 -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\
\r
235 + -DHAVE_STRSEP=\$(HAVE_STRSEP) \\
\r
236 -DSTD_GETPWUID=\$(STD_GETPWUID) \\
\r
237 -DSTD_ASCTIME=\$(STD_ASCTIME)
\r
238 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
\r
239 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
\r
240 \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\
\r
241 -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\
\r
242 + -DHAVE_STRSEP=\$(HAVE_STRSEP) \\
\r
243 -DSTD_GETPWUID=\$(STD_GETPWUID) \\
\r
244 -DSTD_ASCTIME=\$(STD_ASCTIME)
\r
245 CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
\r