Re: [PATCH] Fix typo in Message.maildir_flags_to_tags
[notmuch-archives.git] / 6a / 68006c083793d039fa8e8db7fdf5dac5b2d6e3
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 08B3E431FAF\r
6         for <notmuch@notmuchmail.org>; Sat, 22 Dec 2012 18:59:44 -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 ARuTOxAfawyg for <notmuch@notmuchmail.org>;\r
16         Sat, 22 Dec 2012 18:59: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 59FD6431FAE\r
21         for <notmuch@notmuchmail.org>; Sat, 22 Dec 2012 18:59:44 -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 1Tmbmu-0007XI-VO; Sat, 22 Dec 2012 22:59:41 -0400\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)\r
29         (envelope-from <bremner@tethera.net>)\r
30         id 1Tmbmn-0007SI-0t; Sat, 22 Dec 2012 22:59:33 -0400\r
31 From: david@tethera.net\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH] simplify unhex_and_quote\r
34 Date: Sat, 22 Dec 2012 22:59:30 -0400\r
35 Message-Id: <1356231570-28232-1-git-send-email-david@tethera.net>\r
36 X-Mailer: git-send-email 1.7.10.4\r
37 In-Reply-To: <87txrdhd7g.fsf@oiva.home.nikula.org>\r
38 References: <87txrdhd7g.fsf@oiva.home.nikula.org>\r
39 X-Spam_bar: -\r
40 Cc: David Bremner <bremner@unb.ca>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\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: Sun, 23 Dec 2012 02:59:45 -0000\r
54 \r
55 From: David Bremner <bremner@unb.ca>\r
56 \r
57 the overgeneral definition of a prefix can be replaced by lower case\r
58 alphabetic, and still work fine with current notmuch query syntax.\r
59 \r
60 token_len++ is moved to the end, and we restore the delimiter just so\r
61 we can leave the string as as we found it.\r
62 ---\r
63 \r
64 As always, Jani has a keen eye for muddle. Except he's wrong about \r
65 tok_len - prefix_len, and Mark and I are right. Hopefully ;).\r
66 \r
67 Restoring the delimiter at the end might be pointless (since the rest\r
68 of the input line is modified), but it is one less surprise for somebody \r
69 repurposing the function.\r
70 \r
71 Patches 5 and 6 can be ignored now.\r
72  tag-util.c |   12 ++++++++----\r
73  1 file changed, 8 insertions(+), 4 deletions(-)\r
74 \r
75 diff --git a/tag-util.c b/tag-util.c\r
76 index b0a846b..ee28512 100644\r
77 --- a/tag-util.c\r
78 +++ b/tag-util.c\r
79 @@ -78,11 +78,13 @@ unhex_and_quote (void *ctx, char *encoded, const char *line_for_error,\r
80         size_t prefix_len;\r
81         char delim = *(tok + tok_len);\r
82  \r
83 -       *(tok + tok_len++) = '\0';\r
84 +       *(tok + tok_len) = '\0';\r
85  \r
86 -       prefix_len = hex_invariant (tok, tok_len);\r
87 +       /* The following matches a superset of prefixes currently\r
88 +        * used by notmuch */\r
89 +       prefix_len = strspn (tok, "abcdefghijklmnopqrstuvwxyz");\r
90  \r
91 -       if ((strcmp (tok, "*") == 0) || prefix_len >= tok_len - 1) {\r
92 +       if ((strcmp (tok, "*") == 0) || prefix_len == tok_len) {\r
93  \r
94             /* pass some things through without quoting or decoding.\r
95              * Note for '*' this is mandatory.\r
96 @@ -98,7 +100,7 @@ unhex_and_quote (void *ctx, char *encoded, const char *line_for_error,\r
97  \r
98         } else {\r
99             /* potential prefix: one for ':', then something after */\r
100 -           if ((tok_len - prefix_len > 2) && *(tok + prefix_len) == ':') {\r
101 +           if ((tok_len - prefix_len >= 2) && *(tok + prefix_len) == ':') {\r
102                 if (! (*query_string = talloc_strndup_append (*query_string,\r
103                                                               tok,\r
104                                                               prefix_len + 1))) {\r
105 @@ -129,6 +131,8 @@ unhex_and_quote (void *ctx, char *encoded, const char *line_for_error,\r
106                 goto DONE;\r
107             }\r
108         }\r
109 +       /* restore the string and skip delimiter */\r
110 +       *(tok + tok_len++) = delim;\r
111      }\r
112  \r
113    DONE:\r
114 -- \r
115 1.7.10.4\r
116 \r