1 Return-Path: <hohndel@x200.gr8dns.org>
\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 0AE874196F2
\r
6 for <notmuch@notmuchmail.org>; Tue, 13 Apr 2010 09:47:54 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.999 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9, DKIM_ADSP_NXDOMAIN=0.9, NO_DNS_FOR_FROM=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 7SXldbhBi012 for <notmuch@notmuchmail.org>;
\r
17 Tue, 13 Apr 2010 09:47:53 -0700 (PDT)
\r
18 X-Greylist: delayed 1811 seconds by postgrey-1.32 at olra;
\r
19 Tue, 13 Apr 2010 09:47:52 PDT
\r
20 Received: from mail.hohndel.org (mail.hohndel.org [65.23.157.147])
\r
21 by olra.theworths.org (Postfix) with ESMTP id DF86E431FC1
\r
22 for <notmuch@notmuchmail.org>; Tue, 13 Apr 2010 09:47:52 -0700 (PDT)
\r
23 Received: by mail.hohndel.org (Postfix, from userid 112)
\r
24 id 2D6F3340FE; Tue, 13 Apr 2010 12:47:52 -0400 (EDT)
\r
25 Received: from x200.gr8dns.org (unknown [65.23.157.147])
\r
26 by mail.hohndel.org (Postfix) with ESMTP id 85CE2340FA
\r
27 for <notmuch@notmuchmail.org>; Tue, 13 Apr 2010 12:47:49 -0400 (EDT)
\r
28 Received: by x200.gr8dns.org (Postfix, from userid 500)
\r
29 id 6FD14C00E5; Tue, 13 Apr 2010 09:47:48 -0700 (PDT)
\r
30 From: Dirk Hohndel <hohndel@x200.gr8dns.org>
\r
31 To: <notmuch@notmuchmail.org>
\r
32 Subject: [PATCH] Add strcasestr v.3 - add compat implementation of strcasestr
\r
33 Date: Tue, 13 Apr 2010 09:47:48 -0700
\r
34 Message-ID: <m3vdbvb8p7.fsf@x200.gr8dns.org>
\r
36 Content-Type: text/plain; charset=us-ascii
\r
37 X-Mailman-Approved-At: Tue, 13 Apr 2010 11:39:58 -0700
\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: Tue, 13 Apr 2010 16:47:54 -0000
\r
53 v.3 of this patch, now with the changes to makefiles, configure script
\r
54 compat.h and all new files that I need
\r
55 Please test on platforms lacking strcasestr
\r
57 Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
\r
59 compat/Makefile.local | 4 ++++
\r
60 compat/compat.h | 4 ++++
\r
61 compat/have_strcasestr.c | 10 ++++++++++
\r
62 compat/strcasestr.c | 41 +++++++++++++++++++++++++++++++++++++++++
\r
63 configure | 20 ++++++++++++++++++--
\r
64 5 files changed, 77 insertions(+), 2 deletions(-)
\r
65 create mode 100644 compat/have_strcasestr.c
\r
66 create mode 100644 compat/strcasestr.c
\r
68 diff --git a/compat/Makefile.local b/compat/Makefile.local
\r
69 index 81e6c70..2a17309 100644
\r
70 --- a/compat/Makefile.local
\r
71 +++ b/compat/Makefile.local
\r
72 @@ -8,3 +8,7 @@ notmuch_compat_srcs =
\r
73 ifneq ($(HAVE_GETLINE),1)
\r
74 notmuch_compat_srcs += $(dir)/getline.c $(dir)/getdelim.c
\r
77 +ifneq ($(HAVE_STRCASESTR),1)
\r
78 +notmuch_compat_srcs += $(dir)/strcasestr.c
\r
80 diff --git a/compat/compat.h b/compat/compat.h
\r
81 index d639e0f..173ef68 100644
\r
82 --- a/compat/compat.h
\r
83 +++ b/compat/compat.h
\r
84 @@ -38,4 +38,8 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp);
\r
86 #endif /* !HAVE_GETLINE */
\r
88 +#if !HAVE_STRCASESTR
\r
89 +char* strcasestr(const char *haystack, const char *needle);
\r
90 +#endif /* !HAVE_STRCASESTR */
\r
92 #endif /* NOTMUCH_COMPAT_H */
\r
93 diff --git a/compat/have_strcasestr.c b/compat/have_strcasestr.c
\r
94 new file mode 100644
\r
95 index 0000000..c0fb762
\r
97 +++ b/compat/have_strcasestr.c
\r
99 +#define _GNU_SOURCE
\r
100 +#include <strings.h>
\r
105 + const char *haystack, *needle;
\r
107 + found = strcasestr(haystack, needle);
\r
109 diff --git a/compat/strcasestr.c b/compat/strcasestr.c
\r
110 new file mode 100644
\r
111 index 0000000..50bc89d
\r
113 +++ b/compat/strcasestr.c
\r
116 + * slow simplistic reimplementation of strcasestr for systems that
\r
117 + * don't include it in their library
\r
119 + * based on a GPL implementation in OpenTTD found under GPL v2
\r
121 + This program is free software; you can redistribute it and/or
\r
122 + modify it under the terms of the GNU General Public License as
\r
123 + published by the Free Software Foundation, version 2.
\r
125 + This program is distributed in the hope that it will be useful, but
\r
126 + WITHOUT ANY WARRANTY; without even the implied warranty of
\r
127 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
128 + General Public License for more details.
\r
130 + You should have received a copy of the GNU General Public License
\r
131 + along with this program; if not, write to the Free Software
\r
132 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
\r
133 + 02110-1301, USA. */
\r
135 +/* Imported into notmuch by Dirk Hohndel - original author unknown. */
\r
136 +/* the semantic here actually puzzles me:
\r
137 + how can haystack be const char * - yet the return value is char *
\r
138 + after all, it points to a sub-string of haystack... */
\r
140 +#include <string.h>
\r
142 +char *strcasestr(const char *haystack, const char *needle)
\r
144 + size_t hay_len = strlen(haystack);
\r
145 + size_t needle_len = strlen(needle);
\r
146 + while (hay_len >= needle_len) {
\r
147 + if (strncasecmp(haystack, needle, needle_len) == 0)
\r
148 + return (char *) haystack;
\r
156 diff --git a/configure b/configure
\r
157 index 5af7852..90a399c 100755
\r
160 @@ -310,6 +310,17 @@ else
\r
162 rm -f compat/have_getline
\r
164 +printf "Checking for strcasestr... "
\r
165 +if ${CC} -o compat/have_strcasestr compat/have_strcasestr.c > /dev/null 2>&1
\r
168 + have_strcasestr=1
\r
170 + printf "No (will use our own instead).\n"
\r
171 + have_strcasestr=0
\r
173 +rm -f compat/have_strcasestr
\r
177 All required packages were found. You may now run the following
\r
178 @@ -384,6 +395,10 @@ zsh_completion_dir = \$(prefix)/share/zsh/functions/Completion/Unix
\r
179 # build its own version)
\r
180 HAVE_GETLINE = ${have_getline}
\r
182 +# Whether the strcasestr function is available (if not, then notmuch will
\r
183 +# build its own version)
\r
184 +HAVE_STRCASESTR = ${have_strcasestr}
\r
186 # Flags needed to compile and link against Xapian
\r
187 XAPIAN_CXXFLAGS = ${xapian_cxxflags}
\r
188 XAPIAN_LDFLAGS = ${xapian_ldflags}
\r
189 @@ -405,9 +420,10 @@ VALGRIND_CFLAGS = ${valgrind_cflags}
\r
190 # Combined flags for compiling and linking against all of the above
\r
191 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
\r
192 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
\r
193 - \$(VALGRIND_CFLAGS)
\r
194 + \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
\r
195 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
\r
196 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
\r
197 - \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)
\r
198 + \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\
\r
199 + -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
\r
200 CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
\r
208 Intel Open Source Technology Center
\r