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
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\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
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
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
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
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
75 +ifneq ($(HAVE_STRSEP),1)
\r
76 +notmuch_compat_srcs += $(dir)/strsep.c
\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
89 +char *strsep(char **stringp, const char *delim);
\r
90 +#endif /* !HAVE_STRSEP */
\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
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
99 +++ b/compat/have_strsep.c
\r
101 +#define _GNU_SOURCE
\r
102 +#include <string.h>
\r
107 + char **stringp, const char *delim;
\r
109 + found = strsep(stringp, delim);
\r
111 diff --git a/compat/strsep.c b/compat/strsep.c
\r
112 new file mode 100644
\r
113 index 0000000..78ab9e7
\r
115 +++ b/compat/strsep.c
\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
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
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
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
135 +#include <string.h>
\r
137 +/* Taken from glibc 2.6.1 */
\r
139 +char *strsep (char **stringp, const char *delim)
\r
141 + char *begin, *end;
\r
143 + begin = *stringp;
\r
144 + if (begin == NULL)
\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
152 + char ch = delim[0];
\r
158 + if (*begin == ch)
\r
160 + else if (*begin == '\0')
\r
163 + end = strchr (begin + 1, ch);
\r
167 + /* Find the end of the token. */
\r
168 + end = strpbrk (begin, delim);
\r
172 + /* Terminate the token and set *STRINGP past NUL character. */
\r
177 + /* No more delimiters; this is the last token. */
\r
182 diff --git a/configure b/configure
\r
183 index d9a101f..ab8357f 100755
\r
186 @@ -512,6 +512,17 @@ else
\r
188 rm -f compat/have_strcasestr
\r
190 +printf "Checking for strsep... "
\r
191 +if ${CC} -o compat/have_strsep "$srcdir"/compat/have_strsep.c > /dev/null 2>&1
\r
196 + printf "No (will use our own instead).\n"
\r
199 +rm -f compat/have_strsep
\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
204 @@ -723,6 +734,10 @@ HAVE_GETLINE = ${have_getline}
\r
205 # build its own version)
\r
206 HAVE_STRCASESTR = ${have_strcasestr}
\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
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