1 Return-Path: <bremner@tethera.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 E9425431FBD
\r
6 for <notmuch@notmuchmail.org>; Fri, 21 Dec 2012 05:08:42 -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 jPWNMr0KASsL for <notmuch@notmuchmail.org>;
\r
16 Fri, 21 Dec 2012 05:08:41 -0800 (PST)
\r
17 Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])
\r
18 (using TLSv1 with cipher AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 34C52431FC0
\r
21 for <notmuch@notmuchmail.org>; Fri, 21 Dec 2012 05:08:39 -0800 (PST)
\r
22 Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net
\r
23 ([156.34.82.78] helo=zancas.localnet)
\r
24 by tesseract.cs.unb.ca with esmtpsa
\r
25 (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72)
\r
26 (envelope-from <bremner@tethera.net>)
\r
27 id 1Tm2L6-0005db-Ew; Fri, 21 Dec 2012 09:08:36 -0400
\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)
\r
29 (envelope-from <bremner@tethera.net>)
\r
30 id 1Tm2L1-0005yX-0L; Fri, 21 Dec 2012 09:08:31 -0400
\r
31 From: david@tethera.net
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [Patch v8 05/18] util/string-util: add strnspn
\r
34 Date: Fri, 21 Dec 2012 09:08:14 -0400
\r
35 Message-Id: <1356095307-22895-5-git-send-email-david@tethera.net>
\r
36 X-Mailer: git-send-email 1.7.10.4
\r
37 In-Reply-To: <1356095307-22895-1-git-send-email-david@tethera.net>
\r
38 References: <1356095307-22895-1-git-send-email-david@tethera.net>
\r
40 Cc: David Bremner <bremner@debian.org>
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.13
\r
44 List-Id: "Use and development of the notmuch mail system."
\r
45 <notmuch.notmuchmail.org>
\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
49 List-Post: <mailto:notmuch@notmuchmail.org>
\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
53 X-List-Received-Date: Fri, 21 Dec 2012 13:08:43 -0000
\r
55 From: David Bremner <bremner@debian.org>
\r
57 this is like the standard strspn, but with a limit on how much of a
\r
60 util/string-util.c | 12 ++++++++++++
\r
61 util/string-util.h | 5 +++++
\r
62 2 files changed, 17 insertions(+)
\r
64 diff --git a/util/string-util.c b/util/string-util.c
\r
65 index b9039f4..7d5deaf 100644
\r
66 --- a/util/string-util.c
\r
67 +++ b/util/string-util.c
\r
68 @@ -35,6 +35,18 @@ strtok_len (char *s, const char *delim, size_t *len)
\r
73 +strnspn (const char *str, size_t len, const char *accept)
\r
77 + for (count = 0; count < len && str[count] != '\0'; count++) {
\r
78 + if (strchr (accept, str[count]) == NULL)
\r
85 double_quote_str (void *ctx, const char *str,
\r
86 char **buf, size_t *len)
\r
87 diff --git a/util/string-util.h b/util/string-util.h
\r
88 index 4fc7942..b46f981 100644
\r
89 --- a/util/string-util.h
\r
90 +++ b/util/string-util.h
\r
93 char *strtok_len (char *s, const char *delim, size_t *len);
\r
95 +/* like strspn, but consider at most `n' characters of 's'. `accept'
\r
96 + * must be null terminated; `s' may be null terminated.
\r
98 +size_t strnspn (const char *s, size_t n, const char *accept);
\r
100 /* Copy str to dest, surrounding with double quotes.
\r
101 * Any internal double-quotes are doubled, i.e. a"b -> "a""b"
\r