1 Return-Path: <BATV+47682ed40cd14f842012+2424+infradead.org+hohndel@bombadil.srs.infradead.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 B2A974196F2
\r
6 for <notmuch@notmuchmail.org>; Mon, 12 Apr 2010 21:13:14 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-4.199 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, WEIRD_QUOTING=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 yD7rDZnKm+mP for <notmuch@notmuchmail.org>;
\r
17 Mon, 12 Apr 2010 21:13:13 -0700 (PDT)
\r
18 Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34])
\r
19 by olra.theworths.org (Postfix) with ESMTP id C1442431FC1
\r
20 for <notmuch@notmuchmail.org>; Mon, 12 Apr 2010 21:13:13 -0700 (PDT)
\r
21 Received: from localhost ([::1] helo=x200.gr8dns.org)
\r
22 by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux))
\r
23 id 1O1XUv-0006ST-1X; Tue, 13 Apr 2010 04:13:13 +0000
\r
24 Received: by x200.gr8dns.org (Postfix, from userid 500)
\r
25 id 86CF9C00E1; Mon, 12 Apr 2010 21:13:12 -0700 (PDT)
\r
26 From: Dirk Hohndel <hohndel@infradead.org>
\r
27 To: Tomas Carnecky <tom@dbservice.com>, notmuch@notmuchmail.org
\r
28 Subject: Re: [PATCH] Add compat version of strcasestr
\r
29 In-Reply-To: <1271130351-21207-1-git-send-email-tom@dbservice.com>
\r
30 References: <1271130351-21207-1-git-send-email-tom@dbservice.com>
\r
31 Date: Mon, 12 Apr 2010 21:13:12 -0700
\r
32 Message-ID: <m3d3y4c7mv.fsf@x200.gr8dns.org>
\r
34 Content-Type: text/plain; charset=us-ascii
\r
35 X-SRS-Rewrite: SMTP reverse-path rewritten from <hohndel@infradead.org> by
\r
36 bombadil.infradead.org See http://www.infradead.org/rpr.html
\r
37 X-BeenThere: notmuch@notmuchmail.org
\r
38 X-Mailman-Version: 2.1.13
\r
40 List-Id: "Use and development of the notmuch mail system."
\r
41 <notmuch.notmuchmail.org>
\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
43 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
45 List-Post: <mailto:notmuch@notmuchmail.org>
\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
49 X-List-Received-Date: Tue, 13 Apr 2010 04:13:15 -0000
\r
52 Funny that we both submitted patches...
\r
54 cworth can decide which one he likes better :-)
\r
58 On Tue, 13 Apr 2010 05:45:51 +0200, Tomas Carnecky <tom@dbservice.com> wrote:
\r
59 > strcasestr is not part of any standard (unlike for example strcasecmp) and thus
\r
60 > not available on all platforms (in my case Solaris).
\r
63 > compat/Makefile.local | 4 ++++
\r
64 > compat/compat.h | 4 ++++
\r
65 > compat/have_strcasestr.c | 8 ++++++++
\r
66 > compat/strcasestr.c | 15 +++++++++++++++
\r
67 > configure | 19 +++++++++++++++++--
\r
68 > 5 files changed, 48 insertions(+), 2 deletions(-)
\r
69 > create mode 100644 compat/have_strcasestr.c
\r
70 > create mode 100644 compat/strcasestr.c
\r
72 > diff --git a/compat/Makefile.local b/compat/Makefile.local
\r
73 > index 81e6c70..328eca2 100644
\r
74 > --- a/compat/Makefile.local
\r
75 > +++ b/compat/Makefile.local
\r
76 > @@ -8,3 +8,7 @@ notmuch_compat_srcs =
\r
77 > ifneq ($(HAVE_GETLINE),1)
\r
78 > notmuch_compat_srcs += $(dir)/getline.c $(dir)/getdelim.c
\r
81 > +ifneq ($(HAVE_STRCASESTR),1)
\r
82 > +notmuch_compat_srcs += $(dir)/strcasestr.c
\r
84 > diff --git a/compat/compat.h b/compat/compat.h
\r
85 > index d639e0f..be70bd8 100644
\r
86 > --- a/compat/compat.h
\r
87 > +++ b/compat/compat.h
\r
88 > @@ -38,4 +38,8 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp);
\r
90 > #endif /* !HAVE_GETLINE */
\r
92 > +#if !HAVE_STRCASESTR
\r
93 > +char *strcasestr(char *a, char *b);
\r
94 > +#endif /* !HAVE_STRCASESTR */
\r
96 > #endif /* NOTMUCH_COMPAT_H */
\r
97 > diff --git a/compat/have_strcasestr.c b/compat/have_strcasestr.c
\r
98 > new file mode 100644
\r
99 > index 0000000..36e760d
\r
101 > +++ b/compat/have_strcasestr.c
\r
104 > +#include <string.h>
\r
105 > +#include <strings.h>
\r
109 > + return strcasestr("","");
\r
111 > diff --git a/compat/strcasestr.c b/compat/strcasestr.c
\r
112 > new file mode 100644
\r
113 > index 0000000..a4188b9
\r
115 > +++ b/compat/strcasestr.c
\r
118 > +#include <string.h>
\r
119 > +#include <strings.h>
\r
121 > +char *strcasestr(char *a, char *b)
\r
126 > + snprintf(f, sizeof(f), "%c%c", tolower(*b), toupper(*b));
\r
127 > + for (l = strcspn(a, f); l != strlen(a); l += strcspn(a + l + 1, f) + 1)
\r
128 > + if (strncasecmp(a + l, b, strlen(b)) == 0)
\r
132 > diff --git a/configure b/configure
\r
133 > index 5af7852..add2da6 100755
\r
136 > @@ -310,6 +310,17 @@ else
\r
138 > rm -f compat/have_getline
\r
140 > +printf "Checking for strcasestr... "
\r
141 > +if ${CC} -o compat/have_strcasestr compat/have_strcasestr.c > /dev/null 2>&1
\r
143 > + printf "Yes.\n"
\r
144 > + have_strcasestr=1
\r
146 > + printf "No (will use our own instead).\n"
\r
147 > + have_strcasestr=0
\r
149 > +rm -f compat/have_strcasestr
\r
153 > All required packages were found. You may now run the following
\r
154 > @@ -384,6 +395,10 @@ zsh_completion_dir = \$(prefix)/share/zsh/functions/Completion/Unix
\r
155 > # build its own version)
\r
156 > HAVE_GETLINE = ${have_getline}
\r
158 > +# Whether the strcasestr function is available (if not, then notmuch will
\r
159 > +# build its own version)
\r
160 > +HAVE_STRCASESTR = ${have_strcasestr}
\r
162 > # Flags needed to compile and link against Xapian
\r
163 > XAPIAN_CXXFLAGS = ${xapian_cxxflags}
\r
164 > XAPIAN_LDFLAGS = ${xapian_ldflags}
\r
165 > @@ -405,9 +420,9 @@ VALGRIND_CFLAGS = ${valgrind_cflags}
\r
166 > # Combined flags for compiling and linking against all of the above
\r
167 > CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
\r
168 > \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
\r
169 > - \$(VALGRIND_CFLAGS)
\r
170 > + \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
\r
171 > CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
\r
172 > \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
\r
173 > - \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)
\r
174 > + \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
\r
175 > CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
\r
180 > _______________________________________________
\r
181 > notmuch mailing list
\r
182 > notmuch@notmuchmail.org
\r
183 > http://notmuchmail.org/mailman/listinfo/notmuch
\r
187 Intel Open Source Technology Center
\r