1 Return-Path: <amdragon@mit.edu>
\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 A56B4431FBD
\r
6 for <notmuch@notmuchmail.org>; Sun, 30 Dec 2012 22:42:52 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 jg16oMcRxCXj for <notmuch@notmuchmail.org>;
\r
16 Sun, 30 Dec 2012 22:42:52 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id DD7EA431FAF
\r
20 for <notmuch@notmuchmail.org>; Sun, 30 Dec 2012 22:42:51 -0800 (PST)
\r
21 X-AuditID: 1209190f-b7f016d000000e07-ae-50e133eb6114
\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
23 by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 9B.5C.03591.BE331E05; Mon, 31 Dec 2012 01:42:51 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id qBV6goqc026112;
\r
27 Mon, 31 Dec 2012 01:42:50 -0500
\r
28 Received: from drake.dyndns.org (c-76-21-105-205.hsd1.ca.comcast.net
\r
29 [76.21.105.205]) (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qBV6gkKq009878
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Mon, 31 Dec 2012 01:42:48 -0500 (EST)
\r
34 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1TpZ5B-0000id-Ou; Mon, 31 Dec 2012 01:42:45 -0500
\r
37 From: Austin Clements <amdragon@MIT.EDU>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH v4 0/5] Use Xapian query syntax for batch-tag dump/restore
\r
40 Date: Mon, 31 Dec 2012 01:42:37 -0500
\r
41 Message-Id: <1356936162-2589-1-git-send-email-amdragon@mit.edu>
\r
42 X-Mailer: git-send-email 1.7.10.4
\r
43 X-Brightmail-Tracker:
\r
44 H4sIAAAAAAAAA+NgFtrPIsWRmVeSWpSXmKPExsUixG6nrvva+GGAwZw54hY3WrsZLZqmO1us
\r
45 nstjcf3mTGaLNyvnsTqweuycdZfd4/DXhSwet+6/Zvd4tuoWs8eWQ++ZA1ijuGxSUnMyy1KL
\r
46 9O0SuDI6vu5jKjgvUXF391fWBsb/Ql2MnBwSAiYSm9dOZIawxSQu3FvP1sXIwSEksI9RYrlB
\r
47 FyMXkLmBUeJ0z01GkBohgYtMEje31kAk5jJK3Fx6jg0kwSagIbFt/3KwIhEBaYmdd2ezgtjM
\r
48 AnESKy8tZgexhQW8JG59nwq2jEVAVWLJyZ1MIDavgL3E7IeHmSCOUJTofjaBbQIj7wJGhlWM
\r
49 sim5Vbq5iZk5xanJusXJiXl5qUW6Jnq5mSV6qSmlmxhB4cQpyb+D8dtBpUOMAhyMSjy8HEwP
\r
50 A4RYE8uKK3MPMUpyMCmJ8j40AgrxJeWnVGYkFmfEF5XmpBYfYpTgYFYS4X2rBZTjTUmsrEot
\r
51 yodJSXOwKInzXk256S8kkJ5YkpqdmlqQWgSTleHgUJLgLQYZKliUmp5akZaZU4KQZuLgBBnO
\r
52 AzS8GqSGt7ggMbc4Mx0if4pRUUqcNxEkIQCSyCjNg+uFxfsrRnGgV4R5p4NU8QBTBVz3K6DB
\r
53 TECDtRgegAwuSURISTUwSoumpRU8al7W9vaYf3LZqq83p1gYOiY9bzvl/VZCqz1Ea17w+k1X
\r
54 y2o6JH49ezf326/tXUoaMqd7nNdv+f76t+eTZgNN1V6HX4qWWyY8eXfDuW1PKuspswtP4781
\r
55 7E/LslPkk9n110U59mvCkgcfPp28X7le+LyIbGk8l5Bm1yvfnDtMU+e9UWIpzkg01GIuKk4E
\r
57 Cc: tomi.ollila@iki.fi
\r
58 X-BeenThere: notmuch@notmuchmail.org
\r
59 X-Mailman-Version: 2.1.13
\r
61 List-Id: "Use and development of the notmuch mail system."
\r
62 <notmuch.notmuchmail.org>
\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
66 List-Post: <mailto:notmuch@notmuchmail.org>
\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
70 X-List-Received-Date: Mon, 31 Dec 2012 06:42:52 -0000
\r
74 id:1356719189-2837-1-git-send-email-amdragon@mit.edu
\r
76 This version accepts whitespace before and after boolean terms in
\r
77 parse_boolean_term and expands its documentation comment to describe
\r
78 what it accepts and how that relates to Xapian and make_boolean_term.
\r
80 The diff from v3 is below.
\r
82 diff --git a/util/string-util.c b/util/string-util.c
\r
83 index 83b4953..52c7781 100644
\r
84 --- a/util/string-util.c
\r
85 +++ b/util/string-util.c
\r
87 #include "string-util.h"
\r
93 strtok_len (char *s, const char *delim, size_t *len)
\r
95 @@ -97,6 +99,14 @@ make_boolean_term (void *ctx, const char *prefix, const char *term,
\r
100 +skip_space (const char *str)
\r
102 + while (*str && isspace (*str))
\r
108 parse_boolean_term (void *ctx, const char *str,
\r
109 char **prefix_out, char **term_out)
\r
110 @@ -104,6 +114,7 @@ parse_boolean_term (void *ctx, const char *str,
\r
111 *prefix_out = *term_out = NULL;
\r
114 + str = skip_space (str);
\r
115 const char *pos = strchr (str, ':');
\r
118 @@ -123,6 +134,7 @@ parse_boolean_term (void *ctx, const char *str,
\r
120 /* Found the closing quote. */
\r
122 + pos = skip_space (pos);
\r
126 @@ -138,11 +150,11 @@ parse_boolean_term (void *ctx, const char *str,
\r
127 /* Check for text after the boolean term. */
\r
128 while (*pos > ' ' && *pos != ')')
\r
131 + if (*skip_space (pos))
\r
133 /* No trailing text; dup the string so the caller can free
\r
135 - *term_out = talloc_strdup (ctx, start);
\r
136 + *term_out = talloc_strndup (ctx, start, pos - start);
\r
140 diff --git a/util/string-util.h b/util/string-util.h
\r
141 index 43d49d0..8b9fe50 100644
\r
142 --- a/util/string-util.h
\r
143 +++ b/util/string-util.h
\r
144 @@ -33,12 +33,16 @@ char *strtok_len (char *s, const char *delim, size_t *len);
\r
145 int make_boolean_term (void *talloc_ctx, const char *prefix, const char *term,
\r
146 char **buf, size_t *len);
\r
148 -/* Parse a boolean term query produced by make_boolean_term, returning
\r
149 - * the prefix in *prefix_out and the term in *term_out. *prefix_out
\r
150 - * and *term_out will be talloc'd with context ctx.
\r
151 +/* Parse a boolean term query consisting of a prefix, a colon, and a
\r
152 + * term that may be quoted as described for make_boolean_term. If the
\r
153 + * term is not quoted, then it ends at the first whitespace or close
\r
154 + * parenthesis. str may containing leading or trailing whitespace,
\r
155 + * but anything else is considered a parse error. This is compatible
\r
156 + * with anything produced by make_boolean_term, and supports a subset
\r
157 + * of the quoting styles supported by Xapian (and hence notmuch).
\r
158 + * *prefix_out and *term_out will be talloc'd with context ctx.
\r
160 - * Return: 0 on success, non-zero on parse error (including trailing
\r
162 + * Return: 0 on success, non-zero on parse error.
\r
165 parse_boolean_term (void *ctx, const char *str,
\r