--- /dev/null
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id A56B4431FBD\r
+ for <notmuch@notmuchmail.org>; Sun, 30 Dec 2012 22:42:52 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id jg16oMcRxCXj for <notmuch@notmuchmail.org>;\r
+ Sun, 30 Dec 2012 22:42:52 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
+ [18.9.25.15])\r
+ by olra.theworths.org (Postfix) with ESMTP id DD7EA431FAF\r
+ for <notmuch@notmuchmail.org>; Sun, 30 Dec 2012 22:42:51 -0800 (PST)\r
+X-AuditID: 1209190f-b7f016d000000e07-ae-50e133eb6114\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 9B.5C.03591.BE331E05; Mon, 31 Dec 2012 01:42:51 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id qBV6goqc026112; \r
+ Mon, 31 Dec 2012 01:42:50 -0500\r
+Received: from drake.dyndns.org (c-76-21-105-205.hsd1.ca.comcast.net\r
+ [76.21.105.205]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qBV6gkKq009878\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Mon, 31 Dec 2012 01:42:48 -0500 (EST)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1TpZ5B-0000id-Ou; Mon, 31 Dec 2012 01:42:45 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v4 0/5] Use Xapian query syntax for batch-tag dump/restore\r
+Date: Mon, 31 Dec 2012 01:42:37 -0500\r
+Message-Id: <1356936162-2589-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrPIsWRmVeSWpSXmKPExsUixG6nrvva+GGAwZw54hY3WrsZLZqmO1us\r
+ nstjcf3mTGaLNyvnsTqweuycdZfd4/DXhSwet+6/Zvd4tuoWs8eWQ++ZA1ijuGxSUnMyy1KL\r
+ 9O0SuDI6vu5jKjgvUXF391fWBsb/Ql2MnBwSAiYSm9dOZIawxSQu3FvP1sXIwSEksI9RYrlB\r
+ FyMXkLmBUeJ0z01GkBohgYtMEje31kAk5jJK3Fx6jg0kwSagIbFt/3KwIhEBaYmdd2ezgtjM\r
+ AnESKy8tZgexhQW8JG59nwq2jEVAVWLJyZ1MIDavgL3E7IeHmSCOUJTofjaBbQIj7wJGhlWM\r
+ sim5Vbq5iZk5xanJusXJiXl5qUW6Jnq5mSV6qSmlmxhB4cQpyb+D8dtBpUOMAhyMSjy8HEwP\r
+ A4RYE8uKK3MPMUpyMCmJ8j40AgrxJeWnVGYkFmfEF5XmpBYfYpTgYFYS4X2rBZTjTUmsrEot\r
+ yodJSXOwKInzXk256S8kkJ5YkpqdmlqQWgSTleHgUJLgLQYZKliUmp5akZaZU4KQZuLgBBnO\r
+ AzS8GqSGt7ggMbc4Mx0if4pRUUqcNxEkIQCSyCjNg+uFxfsrRnGgV4R5p4NU8QBTBVz3K6DB\r
+ TECDtRgegAwuSURISTUwSoumpRU8al7W9vaYf3LZqq83p1gYOiY9bzvl/VZCqz1Ea17w+k1X\r
+ y2o6JH49ezf326/tXUoaMqd7nNdv+f76t+eTZgNN1V6HX4qWWyY8eXfDuW1PKuspswtP4781\r
+ 7E/LslPkk9n110U59mvCkgcfPp28X7le+LyIbGk8l5Bm1yvfnDtMU+e9UWIpzkg01GIuKk4E\r
+ AJrCHQrSAgAA\r
+Cc: tomi.ollila@iki.fi\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 31 Dec 2012 06:42:52 -0000\r
+\r
+This obsoletes\r
+\r
+ id:1356719189-2837-1-git-send-email-amdragon@mit.edu\r
+\r
+This version accepts whitespace before and after boolean terms in\r
+parse_boolean_term and expands its documentation comment to describe\r
+what it accepts and how that relates to Xapian and make_boolean_term.\r
+\r
+The diff from v3 is below.\r
+\r
+diff --git a/util/string-util.c b/util/string-util.c\r
+index 83b4953..52c7781 100644\r
+--- a/util/string-util.c\r
++++ b/util/string-util.c\r
+@@ -22,6 +22,8 @@\r
+ #include "string-util.h"\r
+ #include "talloc.h"\r
+ \r
++#include <ctype.h>\r
++\r
+ char *\r
+ strtok_len (char *s, const char *delim, size_t *len)\r
+ {\r
+@@ -97,6 +99,14 @@ make_boolean_term (void *ctx, const char *prefix, const char *term,\r
+ return 0;\r
+ }\r
+ \r
++static const char*\r
++skip_space (const char *str)\r
++{\r
++ while (*str && isspace (*str))\r
++ ++str;\r
++ return str;\r
++}\r
++\r
+ int\r
+ parse_boolean_term (void *ctx, const char *str,\r
+ char **prefix_out, char **term_out)\r
+@@ -104,6 +114,7 @@ parse_boolean_term (void *ctx, const char *str,\r
+ *prefix_out = *term_out = NULL;\r
+ \r
+ /* Parse prefix */\r
++ str = skip_space (str);\r
+ const char *pos = strchr (str, ':');\r
+ if (! pos)\r
+ goto FAIL;\r
+@@ -123,6 +134,7 @@ parse_boolean_term (void *ctx, const char *str,\r
+ if (*pos != '"') {\r
+ /* Found the closing quote. */\r
+ closed = 1;\r
++ pos = skip_space (pos);\r
+ break;\r
+ }\r
+ }\r
+@@ -138,11 +150,11 @@ parse_boolean_term (void *ctx, const char *str,\r
+ /* Check for text after the boolean term. */\r
+ while (*pos > ' ' && *pos != ')')\r
+ ++pos;\r
+- if (*pos)\r
++ if (*skip_space (pos))\r
+ goto FAIL;\r
+ /* No trailing text; dup the string so the caller can free\r
+ * it. */\r
+- *term_out = talloc_strdup (ctx, start);\r
++ *term_out = talloc_strndup (ctx, start, pos - start);\r
+ }\r
+ return 0;\r
+ \r
+diff --git a/util/string-util.h b/util/string-util.h\r
+index 43d49d0..8b9fe50 100644\r
+--- a/util/string-util.h\r
++++ b/util/string-util.h\r
+@@ -33,12 +33,16 @@ char *strtok_len (char *s, const char *delim, size_t *len);\r
+ int make_boolean_term (void *talloc_ctx, const char *prefix, const char *term,\r
+ char **buf, size_t *len);\r
+ \r
+-/* Parse a boolean term query produced by make_boolean_term, returning\r
+- * the prefix in *prefix_out and the term in *term_out. *prefix_out\r
+- * and *term_out will be talloc'd with context ctx.\r
++/* Parse a boolean term query consisting of a prefix, a colon, and a\r
++ * term that may be quoted as described for make_boolean_term. If the\r
++ * term is not quoted, then it ends at the first whitespace or close\r
++ * parenthesis. str may containing leading or trailing whitespace,\r
++ * but anything else is considered a parse error. This is compatible\r
++ * with anything produced by make_boolean_term, and supports a subset\r
++ * of the quoting styles supported by Xapian (and hence notmuch).\r
++ * *prefix_out and *term_out will be talloc'd with context ctx.\r
+ *\r
+- * Return: 0 on success, non-zero on parse error (including trailing\r
+- * data in str).\r
++ * Return: 0 on success, non-zero on parse error.\r
+ */\r
+ int\r
+ parse_boolean_term (void *ctx, const char *str,\r
+ \r
+\r