--- /dev/null
+Return-Path: <Vladimir.Marek@oracle.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id ECBE6429E29\r
+ for <notmuch@notmuchmail.org>; Mon, 6 May 2013 08:16:55 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.299\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.299 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3, UNPARSEABLE_RELAY=0.001]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id ztnn-hQRPrym for <notmuch@notmuchmail.org>;\r
+ Mon, 6 May 2013 08:16:52 -0700 (PDT)\r
+Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 71CA5431E82\r
+ for <notmuch@notmuchmail.org>; Mon, 6 May 2013 08:16:36 -0700 (PDT)\r
+Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237])\r
+ by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with\r
+ ESMTP id r46FGRrf001034\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);\r
+ Mon, 6 May 2013 15:16:28 GMT\r
+Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85])\r
+ by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
+ r46FGRL4027370\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL);\r
+ Mon, 6 May 2013 15:16:28 GMT\r
+Received: from abhmt119.oracle.com (abhmt119.oracle.com [141.146.116.71])\r
+ by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id\r
+ r46FGRxt027181; Mon, 6 May 2013 15:16:27 GMT\r
+Received: from vi64-x3-2e-prg06.cz.oracle.com (/10.163.102.127)\r
+ by default (Oracle Beehive Gateway v4.0)\r
+ with ESMTP ; Mon, 06 May 2013 08:16:26 -0700\r
+From: Vladimir.Marek@oracle.com\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/4] strsep: check for availability (Solaris support)\r
+Date: Mon, 6 May 2013 17:16:01 +0200\r
+Message-Id: <1367853362-11846-4-git-send-email-Vladimir.Marek@oracle.com>\r
+X-Mailer: git-send-email 1.7.9.2\r
+In-Reply-To: <1367853362-11846-1-git-send-email-Vladimir.Marek@oracle.com>\r
+References: <1367853362-11846-1-git-send-email-Vladimir.Marek@oracle.com>\r
+X-Source-IP: acsinet21.oracle.com [141.146.126.237]\r
+Cc: Vladimir Marek <vlmarek@volny.cz>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 06 May 2013 15:16:56 -0000\r
+\r
+From: Blake Jones <blakej@foo.net>\r
+\r
+Solaris does not ship a version of the strsep() function. This change\r
+adds a check to "configure" to see whether notmuch needs to provide its\r
+own implementation, and if so, it uses the new version in\r
+"compat/strsep.c" (which was copied from Mutt, and apparently before\r
+that from glibc).\r
+\r
+Signed-off-by: Vladimir Marek <vlmarek@volny.cz>\r
+---\r
+ compat/Makefile.local | 4 +++\r
+ compat/compat.h | 4 +++\r
+ compat/have_strsep.c | 11 +++++++++\r
+ compat/strsep.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++\r
+ configure | 17 +++++++++++++\r
+ 5 files changed, 101 insertions(+)\r
+ create mode 100644 compat/have_strsep.c\r
+ create mode 100644 compat/strsep.c\r
+\r
+diff --git a/compat/Makefile.local b/compat/Makefile.local\r
+index 13f16cd..2c4f65f 100644\r
+--- a/compat/Makefile.local\r
++++ b/compat/Makefile.local\r
+@@ -13,4 +13,8 @@ ifneq ($(HAVE_STRCASESTR),1)\r
+ notmuch_compat_srcs += $(dir)/strcasestr.c\r
+ endif\r
+ \r
++ifneq ($(HAVE_STRSEP),1)\r
++notmuch_compat_srcs += $(dir)/strsep.c\r
++endif\r
++\r
+ SRCS := $(SRCS) $(notmuch_compat_srcs)\r
+diff --git a/compat/compat.h b/compat/compat.h\r
+index 0c4ac66..ae762c3 100644\r
+--- a/compat/compat.h\r
++++ b/compat/compat.h\r
+@@ -53,6 +53,10 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp);\r
+ char* strcasestr(const char *haystack, const char *needle);\r
+ #endif /* !HAVE_STRCASESTR */\r
+ \r
++#if !HAVE_STRSEP\r
++char *strsep(char **stringp, const char *delim);\r
++#endif /* !HAVE_STRSEP */\r
++\r
+ /* Silence gcc warnings about unused results. These warnings exist\r
+ * for a reason; any use of this needs to be justified. */\r
+ #ifdef __GNUC__\r
+diff --git a/compat/have_strsep.c b/compat/have_strsep.c\r
+new file mode 100644\r
+index 0000000..2abab81\r
+--- /dev/null\r
++++ b/compat/have_strsep.c\r
+@@ -0,0 +1,11 @@\r
++#define _GNU_SOURCE\r
++#include <string.h>\r
++\r
++int main()\r
++{\r
++ char *found;\r
++ char **stringp;\r
++ const char *delim;\r
++\r
++ found = strsep(stringp, delim);\r
++}\r
+diff --git a/compat/strsep.c b/compat/strsep.c\r
+new file mode 100644\r
+index 0000000..78ab9e7\r
+--- /dev/null\r
++++ b/compat/strsep.c\r
+@@ -0,0 +1,65 @@\r
++/* Copyright (C) 1992, 93, 96, 97, 98, 99, 2004 Free Software Foundation, Inc.\r
++ This file is part of the GNU C Library.\r
++\r
++ The GNU C Library is free software; you can redistribute it and/or\r
++ modify it under the terms of the GNU Lesser General Public\r
++ License as published by the Free Software Foundation; either\r
++ version 2.1 of the License, or (at your option) any later version.\r
++\r
++ The GNU C Library is distributed in the hope that it will be useful,\r
++ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
++ Lesser General Public License for more details.\r
++\r
++ You should have received a copy of the GNU Lesser General Public\r
++ License along with the GNU C Library; if not, write to the Free\r
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA\r
++ 02111-1307 USA. */\r
++\r
++#include <string.h>\r
++\r
++/* Taken from glibc 2.6.1 */\r
++\r
++char *strsep (char **stringp, const char *delim)\r
++{\r
++ char *begin, *end;\r
++\r
++ begin = *stringp;\r
++ if (begin == NULL)\r
++ return NULL;\r
++\r
++ /* A frequent case is when the delimiter string contains only one\r
++ character. Here we don't need to call the expensive `strpbrk'\r
++ function and instead work using `strchr'. */\r
++ if (delim[0] == '\0' || delim[1] == '\0')\r
++ {\r
++ char ch = delim[0];\r
++\r
++ if (ch == '\0')\r
++ end = NULL;\r
++ else\r
++ {\r
++ if (*begin == ch)\r
++ end = begin;\r
++ else if (*begin == '\0')\r
++ end = NULL;\r
++ else\r
++ end = strchr (begin + 1, ch);\r
++ }\r
++ }\r
++ else\r
++ /* Find the end of the token. */\r
++ end = strpbrk (begin, delim);\r
++\r
++ if (end)\r
++ {\r
++ /* Terminate the token and set *STRINGP past NUL character. */\r
++ *end++ = '\0';\r
++ *stringp = end;\r
++ }\r
++ else\r
++ /* No more delimiters; this is the last token. */\r
++ *stringp = NULL;\r
++\r
++ return begin;\r
++}\r
+diff --git a/configure b/configure\r
+index 99ec71a..5243cac 100755\r
+--- a/configure\r
++++ b/configure\r
+@@ -517,6 +517,17 @@ else\r
+ fi\r
+ rm -f compat/have_strcasestr\r
+ \r
++printf "Checking for strsep... "\r
++if ${CC} -o compat/have_strsep "$srcdir"/compat/have_strsep.c > /dev/null 2>&1\r
++then\r
++ printf "Yes.\n"\r
++ have_strsep="1"\r
++else\r
++ printf "No (will use our own instead).\n"\r
++ have_strsep="0"\r
++fi\r
++rm -f compat/have_strsep\r
++\r
+ printf "Checking for standard version of getpwuid_r... "\r
+ if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1\r
+ then\r
+@@ -698,6 +709,10 @@ HAVE_GETLINE = ${have_getline}\r
+ # build its own version)\r
+ HAVE_STRCASESTR = ${have_strcasestr}\r
+ \r
++# Whether the strsep function is available (if not, then notmuch will\r
++# build its own version)\r
++HAVE_STRSEP = ${have_strsep}\r
++\r
+ # Whether the getpwuid_r function is standards-compliant\r
+ # (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS\r
+ # to enable the standards-compliant version -- needed for Solaris)\r
+@@ -754,12 +769,14 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\\r
+ \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\\r
+ \$(VALGRIND_CFLAGS) \\\r
+ -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\\r
++ -DHAVE_STRSEP=\$(HAVE_STRSEP) \\\r
+ -DSTD_GETPWUID=\$(STD_GETPWUID) \\\r
+ -DSTD_ASCTIME=\$(STD_ASCTIME)\r
+ CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\\r
+ \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\\r
+ \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\\r
+ -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\\r
++ -DHAVE_STRSEP=\$(HAVE_STRSEP) \\\r
+ -DSTD_GETPWUID=\$(STD_GETPWUID) \\\r
+ -DSTD_ASCTIME=\$(STD_ASCTIME)\r
+ CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)\r
+-- \r
+1.7.9.2\r
+\r