Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / 59 / 8fd94f69377c1efa9d547fe0d0bc1b9edaa065
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 39B3E431FBD\r
6         for <notmuch@notmuchmail.org>; Fri, 21 Dec 2012 05:08:45 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\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 O6E5Wu-Re3ij for <notmuch@notmuchmail.org>;\r
16         Fri, 21 Dec 2012 05:08:44 -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 36FF9431FC3\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-0005dc-JS; Fri, 21 Dec 2012 09:08:37 -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-0005yc-4j; 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 06/18] util/hex-escape: add a function to check strings\r
34         unchanged by hex encoding.\r
35 Date: Fri, 21 Dec 2012 09:08:15 -0400\r
36 Message-Id: <1356095307-22895-6-git-send-email-david@tethera.net>\r
37 X-Mailer: git-send-email 1.7.10.4\r
38 In-Reply-To: <1356095307-22895-1-git-send-email-david@tethera.net>\r
39 References: <1356095307-22895-1-git-send-email-david@tethera.net>\r
40 X-Spam_bar: -\r
41 Cc: David Bremner <bremner@debian.org>\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Fri, 21 Dec 2012 13:08:45 -0000\r
55 \r
56 From: David Bremner <bremner@debian.org>\r
57 \r
58 Initial use case is to recognize input tokens for batch tagging that\r
59 need quoting.\r
60 ---\r
61  util/hex-escape.c |    7 +++++++\r
62  util/hex-escape.h |    8 ++++++++\r
63  2 files changed, 15 insertions(+)\r
64 \r
65 diff --git a/util/hex-escape.c b/util/hex-escape.c\r
66 index b7e2e07..b601a33 100644\r
67 --- a/util/hex-escape.c\r
68 +++ b/util/hex-escape.c\r
69 @@ -24,6 +24,7 @@\r
70  #include <ctype.h>\r
71  #include "error_util.h"\r
72  #include "hex-escape.h"\r
73 +#include "string-util.h"\r
74  \r
75  static const size_t default_buf_size = 1024;\r
76  \r
77 @@ -38,6 +39,12 @@ is_output (char c)\r
78      return (strchr (output_charset, c) != NULL);\r
79  }\r
80  \r
81 +size_t\r
82 +hex_invariant (const char *str, size_t len)\r
83 +{\r
84 +    return strnspn (str, len, output_charset);\r
85 +}\r
86 +\r
87  static int\r
88  maybe_realloc (void *ctx, size_t needed, char **out, size_t *out_size)\r
89  {\r
90 diff --git a/util/hex-escape.h b/util/hex-escape.h\r
91 index 5182042..e7d0b31 100644\r
92 --- a/util/hex-escape.h\r
93 +++ b/util/hex-escape.h\r
94 @@ -38,4 +38,12 @@ hex_decode (void *talloc_ctx, const char *in, char **out,\r
95   */\r
96  hex_status_t\r
97  hex_decode_inplace (char *s);\r
98 +\r
99 +/*\r
100 + * Calculate the length of the initial segment of str that would not\r
101 + * be changed by hex encoding. Consider at most `len' characters\r
102 + * (bytes) before stopping.\r
103 + */\r
104 +size_t\r
105 +hex_invariant (const char *str, size_t len);\r
106  #endif\r
107 -- \r
108 1.7.10.4\r
109 \r