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 017534196F2
\r
6 for <notmuch@notmuchmail.org>; Tue, 13 Apr 2010 09:50:19 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.401 tagged_above=-999 required=5
\r
12 tests=[BAYES_05=-0.5, 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 FDltHHGo+idq for <notmuch@notmuchmail.org>;
\r
17 Tue, 13 Apr 2010 09:50:18 -0700 (PDT)
\r
18 Received: from mail.hohndel.org (mail.hohndel.org [65.23.157.147])
\r
19 by olra.theworths.org (Postfix) with ESMTP id 5EBD9431FC1
\r
20 for <notmuch@notmuchmail.org>; Tue, 13 Apr 2010 09:50:18 -0700 (PDT)
\r
21 Received: by mail.hohndel.org (Postfix, from userid 112)
\r
22 id 9E326340FC; Tue, 13 Apr 2010 12:17:40 -0400 (EDT)
\r
23 Received: from x200.gr8dns.org (unknown [65.23.157.147])
\r
24 by mail.hohndel.org (Postfix) with ESMTP id 84243340F8
\r
25 for <notmuch@notmuchmail.org>; Tue, 13 Apr 2010 12:17:38 -0400 (EDT)
\r
26 Received: by x200.gr8dns.org (Postfix, from userid 500)
\r
27 id 58358C00E5; Tue, 13 Apr 2010 09:17:37 -0700 (PDT)
\r
28 From: Dirk Hohndel <hohndel@x200.gr8dns.org>
\r
29 To: <notmuch@notmuchmail.org>
\r
30 Subject: [PATCH] Add simplistic compat implementation for strcasestr
\r
31 Date: Tue, 13 Apr 2010 09:17:37 -0700
\r
32 Message-ID: <m339yzcony.fsf@x200.gr8dns.org>
\r
34 Content-Type: text/plain; charset=us-ascii
\r
35 X-Mailman-Approved-At: Tue, 13 Apr 2010 11:39:58 -0700
\r
36 X-BeenThere: notmuch@notmuchmail.org
\r
37 X-Mailman-Version: 2.1.13
\r
39 List-Id: "Use and development of the notmuch mail system."
\r
40 <notmuch.notmuchmail.org>
\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
44 List-Post: <mailto:notmuch@notmuchmail.org>
\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
48 X-List-Received-Date: Tue, 13 Apr 2010 16:50:19 -0000
\r
51 v.2 of the patch, this time including the Makefile logic.
\r
52 All platforms I have access to support strcasestr - so please test
\r
53 that the implementation / integration works correctly on those
\r
56 Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
\r
58 compat/have_strcasestr.c | 10 ++++++++++
\r
59 compat/strcasestr.c | 41 +++++++++++++++++++++++++++++++++++++++++
\r
60 2 files changed, 51 insertions(+), 0 deletions(-)
\r
61 create mode 100644 compat/have_strcasestr.c
\r
62 create mode 100644 compat/strcasestr.c
\r
64 diff --git a/compat/have_strcasestr.c b/compat/have_strcasestr.c
\r
65 new file mode 100644
\r
66 index 0000000..c0fb762
\r
68 +++ b/compat/have_strcasestr.c
\r
70 +#define _GNU_SOURCE
\r
71 +#include <strings.h>
\r
76 + const char *haystack, *needle;
\r
78 + found = strcasestr(haystack, needle);
\r
80 diff --git a/compat/strcasestr.c b/compat/strcasestr.c
\r
81 new file mode 100644
\r
82 index 0000000..50bc89d
\r
84 +++ b/compat/strcasestr.c
\r
87 + * slow simplistic reimplementation of strcasestr for systems that
\r
88 + * don't include it in their library
\r
90 + * based on a GPL implementation in OpenTTD found under GPL v2
\r
92 + This program is free software; you can redistribute it and/or
\r
93 + modify it under the terms of the GNU General Public License as
\r
94 + published by the Free Software Foundation, version 2.
\r
96 + This program is distributed in the hope that it will be useful, but
\r
97 + WITHOUT ANY WARRANTY; without even the implied warranty of
\r
98 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
99 + General Public License for more details.
\r
101 + You should have received a copy of the GNU General Public License
\r
102 + along with this program; if not, write to the Free Software
\r
103 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
\r
104 + 02110-1301, USA. */
\r
106 +/* Imported into notmuch by Dirk Hohndel - original author unknown. */
\r
107 +/* the semantic here actually puzzles me:
\r
108 + how can haystack be const char * - yet the return value is char *
\r
109 + after all, it points to a sub-string of haystack... */
\r
111 +#include <string.h>
\r
113 +char *strcasestr(const char *haystack, const char *needle)
\r
115 + size_t hay_len = strlen(haystack);
\r
116 + size_t needle_len = strlen(needle);
\r
117 + while (hay_len >= needle_len) {
\r
118 + if (strncasecmp(haystack, needle, needle_len) == 0)
\r
119 + return (char *) haystack;
\r
133 Intel Open Source Technology Center
\r